config

package
v2.0.0-...-dbd0e5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	StorageArrayConfig     []StorageArrayConfig     `yaml:"storageArrays" mapstructure:"storageArrays"`
	ManagementServerConfig []ManagementServerConfig `yaml:"managementServers" mapstructure:"managementServers"`
}

Config - represents proxy configuration in the config file

type ConfigManager

type ConfigManager interface {
	// SetConfigFile designates the name of the file containing the configuration
	SetConfigName(string)

	// SetConfigType designates the type of the configuration. e.g. yaml, json
	SetConfigType(string)

	// AddConfigPath adds a path to look for the config file in
	// Can be called multiple times to define multiple search paths
	AddConfigPath(string)

	// ReadInConfig will discover and load the configuration file from disk
	// and key/value stores, searching in one of the defined paths.
	ReadInConfig() error

	// GetString returns the value associated with the key as a string.
	GetString(string) string
}

ConfigManager is an interface used for testing, satisfied by viper.Viper.

type ManagementServer

type ManagementServer struct {
	Endpoint                  url.URL
	StorageArrayIdentifiers   []string
	Credentials               common.Credentials
	CredentialSecret          string
	SkipCertificateValidation bool
	CertFile                  string
	CertSecret                string
	Limits                    common.Limits
	Username                  string
	Password                  string
}

ManagementServer - represents a Management Server (formed using ManagementServerConfig)

func (*ManagementServer) DeepCopy

func (ms *ManagementServer) DeepCopy() *ManagementServer

DeepCopy is used for creating a deep copy of Management Server

type ManagementServerConfig

type ManagementServerConfig struct {
	Endpoint                  string        `yaml:"endpoint"`
	ArrayCredentialSecret     string        `yaml:"arrayCredentialSecret,omitempty"`
	SkipCertificateValidation bool          `yaml:"skipCertificateValidation,omitempty"`
	CertSecret                string        `yaml:"certSecret,omitempty"`
	Limits                    common.Limits `yaml:"limits,omitempty" mapstructure:"limits"`
	Username                  string        `yaml:"username,omitempty"`
	Password                  string        `yaml:"password,omitempty"`
}

ManagementServerConfig - represents a management server configuration for the management server

type ParamsConfigMap

type ParamsConfigMap struct {
	Port      string `yaml:"csi_powermax_reverse_proxy_port" mapstructure:"csi_powermax_reverse_proxy_port,omitempty"`
	LogLevel  string `yaml:"csi_log_level" mapstructure:"csi_log_level,omitempty"`
	LogFormat string `yaml:"csi_log_format" mapstructure:"csi_log_format,omitempty"`
}

ParamsConfigMap - represents the config map for params

func ReadParamsConfigMapFromPath

func ReadParamsConfigMapFromPath(configFilePath string, vcp ConfigManager) (*ParamsConfigMap, error)

ReadParamsConfigMapFromPath - read config map for params

type ProxyConfig

type ProxyConfig struct {
	Port string
	// contains filtered or unexported fields
}

ProxyConfig - represents Proxy Config (formed using ProxyConfigMap OR ProxySecret)

func NewProxyConfig

func NewProxyConfig(configMap *ProxyConfigMap, k8sUtils k8sutils.UtilsInterface) (*ProxyConfig, error)

NewProxyConfig - returns a new proxy config given a proxy config map

func NewProxyConfigFromSecret

func NewProxyConfigFromSecret(proxySecret *ProxySecret, k8sUtils k8sutils.UtilsInterface) (*ProxyConfig, error)

NewProxyConfigFromSecret - new config using secret

func (*ProxyConfig) DeepCopy

func (pc *ProxyConfig) DeepCopy() *ProxyConfig

DeepCopy is used to create a deep copy of ProxyConfig

func (*ProxyConfig) GetAuthorizedArrays

func (pc *ProxyConfig) GetAuthorizedArrays(username, password string) []string

GetAuthorizedArrays - Given a credential, returns the list of authorized storage arrays

func (*ProxyConfig) GetManagedArraysAndServers

func (pc *ProxyConfig) GetManagedArraysAndServers() map[string]StorageArrayServer

GetManagedArraysAndServers returns a list of arrays with their corresponding management servers

func (*ProxyConfig) GetManagementServer

func (pc *ProxyConfig) GetManagementServer(url url.URL) (ManagementServer, bool)

GetManagementServer returns a management server corresponding to a URL

func (*ProxyConfig) GetManagementServerCredentials

func (pc *ProxyConfig) GetManagementServerCredentials(mgmtEndpoint url.URL) (common.Credentials, error)

GetManagementServerCredentials - Given a management server endoint, returns the associated credentials

func (*ProxyConfig) GetManagementServers

func (pc *ProxyConfig) GetManagementServers() []ManagementServer

GetManagementServers - Returns the list of management servers present in ProxyConfig

func (*ProxyConfig) GetStorageArray

func (pc *ProxyConfig) GetStorageArray(storageArrayID string) []StorageArray

GetStorageArray - Returns a list of storage array given a storage array id

func (*ProxyConfig) IsSecretConfiguredForArrays

func (pc *ProxyConfig) IsSecretConfiguredForArrays(secretName string) bool

IsSecretConfiguredForArrays - returns true if a given secret name has been configured as credential secret for a storage array

func (*ProxyConfig) IsSecretConfiguredForCerts

func (pc *ProxyConfig) IsSecretConfiguredForCerts(secretName string) bool

IsSecretConfiguredForCerts - returns true if the given secret name is configured for certificates

func (*ProxyConfig) IsUserAuthorized

func (pc *ProxyConfig) IsUserAuthorized(username, password, storageArrayID string) (bool, error)

IsUserAuthorized - Returns if a given user is authorized to access a specific storage array

func (*ProxyConfig) Log

func (pc *ProxyConfig) Log()

Log - logs the Proxy Config

func (*ProxyConfig) ParseConfig

func (pc *ProxyConfig) ParseConfig(proxyConfigMap ProxyConfigMap, k8sUtils k8sutils.UtilsInterface) error

ParseConfig - Parses a given proxy config map

func (*ProxyConfig) ParseConfigFromSecret

func (pc *ProxyConfig) ParseConfigFromSecret(proxySecret ProxySecret, k8sUtils k8sutils.UtilsInterface) error

ParseConfigFromSecret - Parses a given proxy secret

func (*ProxyConfig) UpdateCerts

func (pc *ProxyConfig) UpdateCerts(secretName, certFileName string) bool

UpdateCerts - Given a secret name and cert file name, updates the management server

func (*ProxyConfig) UpdateCertsAndCredentials

func (pc *ProxyConfig) UpdateCertsAndCredentials(k8sUtils k8sutils.UtilsInterface, secret *corev1.Secret) (bool, error)

UpdateCertsAndCredentials - Updates certs and credentials given a secret and returns a boolean to indicate if any updates was done

func (*ProxyConfig) UpdateCreds

func (pc *ProxyConfig) UpdateCreds(secretName string, credentials *common.Credentials) bool

UpdateCreds - Given a secret name and credentials, updates management servers and storage array proxy credentials

func (*ProxyConfig) UpdateManagedArrays

func (pc *ProxyConfig) UpdateManagedArrays(config *ProxyConfig)

UpdateManagedArrays - updates the set of managed arrays

func (*ProxyConfig) UpdateManagementServers

func (pc *ProxyConfig) UpdateManagementServers(config *ProxyConfig) ([]ManagementServer, []ManagementServer, error)

UpdateManagementServers - Updates the list of management servers

type ProxyConfigMap

type ProxyConfigMap struct {
	Port      string  `yaml:"port,omitempty"`
	LogLevel  string  `yaml:"logLevel,omitempty"`
	LogFormat string  `yaml:"logFormat,omitempty"`
	Config    *Config `yaml:"config,omitempty" mapstructure:"config"`
}

ProxyConfigMap - represents the configuration file

func ReadConfig

func ReadConfig(configFile, configPath string, vcm *viper.Viper) (*ProxyConfigMap, error)

ReadConfig - uses viper to read the config from the config map

func (*ProxyConfigMap) CustomUnmarshal

func (c *ProxyConfigMap) CustomUnmarshal(vcm *viper.Viper) error

CustomUnmarshal - Custom unmarshal function for config map

Since the common ManagementServerConfig and StorageArrayConfig have been modified to use Endpoint instead of URL,
viper has an issue unmarshalling those in to the struct for ConfigMap which uses URLs (ex.primaryURL, backupURL in config map definition).
Hence a custom function is needed to make sure that they are parsed correctly.
This method also uses a custom hook to decode int to string as the default mapstructure.decode cannot natively do that.
Note: This function only used for unmarshalling configMap to structures.

type ProxyCredentialSecret

type ProxyCredentialSecret struct {
	Credentials      common.Credentials
	CredentialSecret string
}

ProxyCredentialSecret is used for storing a credential for a secret

type ProxySecret

type ProxySecret struct {
	StorageArrayConfig     []StorageArrayConfig     `yaml:"storageArrays" mapstructure:"storageArrays"`
	ManagementServerConfig []ManagementServerConfig `yaml:"managementServers" mapstructure:"managementServers"`
}

ProxySecret - represents the configuration file

func ReadConfigFromSecret

func ReadConfigFromSecret(vs *viper.Viper) (*ProxySecret, error)

ReadConfigFromSecret - read config using secret

type ProxyUser

type ProxyUser struct {
	StorageArrayIdentifiers []string
	ProxyCredential         common.Credentials
}

ProxyUser - used for storing a proxy user and list of associated storage array identifiers

func (*ProxyUser) DeepClone

func (pu *ProxyUser) DeepClone() *ProxyUser

DeepClone is used to create a deep copy of Proxy User

type StorageArray

type StorageArray struct {
	StorageArrayIdentifier string
	PrimaryEndpoint        url.URL
	SecondaryEndpoint      url.URL
	ProxyCredentialSecrets map[string]ProxyCredentialSecret
	Labels                 map[string]string
	Parameters             map[string]string
}

StorageArray represents a StorageArray (formed using StorageArrayConfig)

func (*StorageArray) DeepCopy

func (sa *StorageArray) DeepCopy() *StorageArray

DeepCopy - used for deep copy of StorageArray

type StorageArrayConfig

type StorageArrayConfig struct {
	StorageArrayID         string            `yaml:"storageArrayId"`
	PrimaryEndpoint        string            `yaml:"primaryEndpoint"`
	BackupEndpoint         string            `yaml:"backupEndpoint,omitempty"`
	ProxyCredentialSecrets []string          `yaml:"proxyCredentialSecrets"`
	Labels                 map[string]string `yaml:"labels,omitempty"`
	Parameters             map[string]string `yaml:"parameters,omitempty"`
}

StorageArrayConfig represents the configuration of a storage array in the config file

type StorageArrayServer

type StorageArrayServer struct {
	Array         StorageArray
	PrimaryServer ManagementServer
	BackupServer  *ManagementServer
}

StorageArrayServer represents an array with its primary and backup management server

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL