parent
437841c8dd
commit
84b64b7d80
@ -1,12 +1,39 @@
|
|||||||
## Version 1.2.1
|
## Version 1.3.0
|
||||||
|
|
||||||
### Bug fixes
|
### Features
|
||||||
|
|
||||||
#### Legacy Client
|
- Created CloudAPI/CloudBroker filtering, sorting and serialization functions for List requests.
|
||||||
|
- Every handler with present List request has available FilterBy functions. Filtering by ID, Name is common for each handler.
|
||||||
|
- In case user needs to filter response by uncommon field FilterFunc with user-specified predicate is also available.
|
||||||
|
- CloudAPI/CloudBroker computes, disks and lb also have specific Filter methods predefined, to name a few:
|
||||||
|
- computes:
|
||||||
|
- FilterByK8SID, used to filter computes used by specified k8s cluster;
|
||||||
|
- FilterByK8SMasters, FilterByK8SWorkers, used to filter master/workers nodes. Best used after FilterByK8SID call;
|
||||||
|
- FilterByLBID, used to filter computes used by specified load balancer;
|
||||||
|
|
||||||
- Fixed password and username encoding
|
- disks:
|
||||||
- Fixed request params absence in HTTP Transport
|
- FilterByK8SID, used to filter disks attached to computes inside specified k8s cluster;
|
||||||
|
- FilterByLBID, used to filter disks attached to computes inside specified load balancer;
|
||||||
|
|
||||||
#### All
|
- lb:
|
||||||
|
- FilterByK8SID, used to filter load balancers used by specified k8s cluster;
|
||||||
|
|
||||||
|
- Reinvented request validation using go-validator. Made easier to manipulate and add on to.
|
||||||
|
- Request/Config validation now uses tags instead of hard-coded validation functions;
|
||||||
|
|
||||||
|
- Added ability to parse client configuration from JSON or YAML formatted files.
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Fixed SSO_URL trailing slash possibly breaking authentication process.
|
||||||
|
- Fixed cloudbroker/vins/nat_rule_add request model types.
|
||||||
|
- Fixed cloudbroker/grid DiskSize field type
|
||||||
|
- Fixed TasksResult, InfoResult in cloudbroker/cloudapi/tasks/models JSON unmarshalling.
|
||||||
|
|
||||||
|
### Tests
|
||||||
|
|
||||||
|
- Covered CloudAPI/CloudBroker filters with unit tests.
|
||||||
|
|
||||||
|
### Other
|
||||||
|
|
||||||
- Updated module to new repository
|
- Updated module to new repository
|
||||||
|
@ -1,39 +1,95 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
// Configuration for creating request to platform
|
// Configuration for creating request to platform
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// JWT platform token
|
// JWT platform token
|
||||||
// Required: false
|
// Required: false
|
||||||
// Example: "qwqwdfwv68979we0q9bfv7e9sbvd89798qrwv97ff"
|
// Example: "qwqwdfwv68979we0q9bfv7e9sbvd89798qrwv97ff"
|
||||||
Token string
|
Token string `json:"token" yaml:"token"`
|
||||||
|
|
||||||
// Application (client) identifier for authorization
|
// Application (client) identifier for authorization
|
||||||
// in the cloud platform controller in oauth2 mode.
|
// in the cloud platform controller in oauth2 mode.
|
||||||
// Required: true
|
// Required: true
|
||||||
// Example: "ewqfrvea7s890avw804389qwguf234h0otfi3w4eiu"
|
// Example: "ewqfrvea7s890avw804389qwguf234h0otfi3w4eiu"
|
||||||
AppID string
|
AppID string `json:"appId" yaml:"appId" validate:"required"`
|
||||||
|
|
||||||
// Application (client) secret code for authorization
|
// Application (client) secret code for authorization
|
||||||
// in the cloud platform controller in oauth2 mode.
|
// in the cloud platform controller in oauth2 mode.
|
||||||
// Example: "frvet09rvesfis0c9erv9fsov0vsdfi09ovds0f"
|
// Example: "frvet09rvesfis0c9erv9fsov0vsdfi09ovds0f"
|
||||||
AppSecret string
|
AppSecret string `json:"appSecret" yaml:"appSecret" validate:"required"`
|
||||||
|
|
||||||
// Platform authentication service address
|
// Platform authentication service address
|
||||||
// Required: true
|
// Required: true
|
||||||
// Example: "https://sso.digitalenergy.online"
|
// Example: "https://sso.digitalenergy.online"
|
||||||
SSOURL string
|
SSOURL string `json:"ssoUrl" yaml:"ssoUrl" validate:"url"`
|
||||||
|
|
||||||
// The address of the platform on which the actions are planned
|
// The address of the platform on which the actions are planned
|
||||||
// Required: true
|
// Required: true
|
||||||
// Example: "https://mr4.digitalenergy.online"
|
// Example: "https://mr4.digitalenergy.online"
|
||||||
DecortURL string
|
DecortURL string `json:"decortUrl" yaml:"decortUrl" validate:"url"`
|
||||||
|
|
||||||
// Amount platform request attempts
|
// Amount platform request attempts
|
||||||
// Default value: 5
|
// Default value: 5
|
||||||
// Required: false
|
// Required: false
|
||||||
Retries uint64
|
Retries uint64 `json:"retries" yaml:"retries"`
|
||||||
|
|
||||||
// Skip verify, true by default
|
// Skip verify, true by default
|
||||||
// Required: false
|
// Required: false
|
||||||
SSLSkipVerify bool
|
SSLSkipVerify bool `json:"sslSkipVerify" yaml:"sslSkipVerify"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseConfigJSON parses Config from specified JSON-formatted file.
|
||||||
|
func ParseConfigJSON(path string) (Config, error) {
|
||||||
|
file, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return Config{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var config Config
|
||||||
|
|
||||||
|
err = json.Unmarshal(file, &config)
|
||||||
|
if err != nil {
|
||||||
|
return Config{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validators.ValidateConfig(config)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return Config{}, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseConfigYAML parses Config from specified YAML-formatted file.
|
||||||
|
func ParseConfigYAML(path string) (Config, error) {
|
||||||
|
file, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return Config{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var config Config
|
||||||
|
|
||||||
|
err = yaml.Unmarshal(file, &config)
|
||||||
|
if err != nil {
|
||||||
|
return Config{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validators.ValidateConfig(config)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return Config{}, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,89 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
// Legacy client configuration
|
// Legacy client configuration
|
||||||
type LegacyConfig struct {
|
type LegacyConfig struct {
|
||||||
// ServiceAccount username
|
// ServiceAccount username
|
||||||
// Required: true
|
// Required: true
|
||||||
// Example : "osh_mikoev"
|
// Example : "osh_mikoev"
|
||||||
Username string
|
Username string `json:"username" yaml:"username" validate:"required"`
|
||||||
|
|
||||||
// ServiceAccount password
|
// ServiceAccount password
|
||||||
// Required: true
|
// Required: true
|
||||||
// Example: "[1o>hYkjnJr)HI78q7t&#%8Lm"
|
// Example: "[1o>hYkjnJr)HI78q7t&#%8Lm"
|
||||||
Password string
|
Password string `json:"password" yaml:"password" validate:"required"`
|
||||||
|
|
||||||
// Platform token
|
// Platform token
|
||||||
// Required: false
|
// Required: false
|
||||||
// Example: "158e76424b0d4810b6086hgbhj928fc4a6bc06e"
|
// Example: "158e76424b0d4810b6086hgbhj928fc4a6bc06e"
|
||||||
Token string
|
Token string `json:"token" yaml:"token"`
|
||||||
|
|
||||||
// Address of the platform on which the actions are planned
|
// Address of the platform on which the actions are planned
|
||||||
// Required: true
|
// Required: true
|
||||||
// Example: "https://mr4.digitalenergy.online"
|
// Example: "https://mr4.digitalenergy.online"
|
||||||
DecortURL string
|
DecortURL string `json:"decortUrl" yaml:"decortUrl" validate:"url"`
|
||||||
|
|
||||||
// Amount platform request attempts
|
// Amount platform request attempts
|
||||||
// Default value: 5
|
// Default value: 5
|
||||||
// Required: false
|
// Required: false
|
||||||
Retries uint64
|
Retries uint64 `json:"retries" yaml:"retries"`
|
||||||
|
|
||||||
// Skip verify, true by default
|
// Skip verify, true by default
|
||||||
// Required: false
|
// Required: false
|
||||||
SSLSkipVerify bool
|
SSLSkipVerify bool `json:"sslSkipVerify" yaml:"sslSkipVerify"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseLegacyConfigJSON parses LegacyConfig from specified JSON-formatted file.
|
||||||
|
func ParseLegacyConfigJSON(path string) (LegacyConfig, error) {
|
||||||
|
file, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return LegacyConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var config LegacyConfig
|
||||||
|
|
||||||
|
err = json.Unmarshal(file, &config)
|
||||||
|
if err != nil {
|
||||||
|
return LegacyConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validators.ValidateConfig(config)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return LegacyConfig{}, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseLegacyConfigYAML parses LegacyConfig from specified YAML-formatted file.
|
||||||
|
func ParseLegacyConfigYAML(path string) (LegacyConfig, error) {
|
||||||
|
file, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return LegacyConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var config LegacyConfig
|
||||||
|
|
||||||
|
err = yaml.Unmarshal(file, &config)
|
||||||
|
if err != nil {
|
||||||
|
return LegacyConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = validators.ValidateConfig(config)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return LegacyConfig{}, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return config, nil
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue