Documentation
¶
Overview ¶
Package config Provide API methods to Read/Write specific stanza of config file
Package config Provide API methods to Read/Write specific stanza of config file
Package config Provide API methods to Read/Write specific stanza of config file
Package config Provide API methods to Read/Write specific stanza of config file
Index ¶
- Constants
- Variables
- func AcquireTanzuConfigLock()
- func AcquireTanzuConfigNextGenLock()
- func AcquireTanzuMetadataLock()
- func AddContext(c *configtypes.Context, setCurrent bool) error
- func AddServer(s *configtypes.Server, setCurrent bool) error
- func CfgMetadataFilePath() (path string, err error)
- func ClientConfigNextGenPath() (path string, err error)
- func ClientConfigPath() (path string, err error)
- func ConfigureDefaultFeatureFlagsIfMissing(plugin string, defaultFeatureFlags map[string]bool) error
- func ContextExists(name string) (bool, error)
- func CopyLegacyConfigDir() error
- func DeleteCLIDiscoverySource(name string) error
- func DeleteCLIRepository(name string) error
- func DeleteClientConfig() error
- func DeleteClientConfigNextGen() error
- func DeleteConfigMetadataSetting(key string) error
- func DeleteContext(name string) error
- func DeleteEnv(key string) error
- func DeleteFeature(plugin, key string) error
- func DeleteServer(name string) error
- func EndpointFromContext(s *configtypes.Context) (endpoint string, err error)
- func EndpointFromServer(s *configtypes.Server) (endpoint string, err error)
- func GetAllCurrentContextsList() ([]string, error)
- func GetAllCurrentContextsMap() (map[configtypes.Target]*configtypes.Context, error)
- func GetAllEnvs() (map[string]string, error)
- func GetCLIDiscoverySource(name string) (*configtypes.PluginDiscovery, error)
- func GetCLIDiscoverySources() ([]configtypes.PluginDiscovery, error)
- func GetCLIRepositories() ([]configtypes.PluginRepository, error)
- func GetCLIRepository(name string) (*configtypes.PluginRepository, error)
- func GetClientConfig() (cfg *configtypes.ClientConfig, err error)
- func GetClientConfigNoLock() (cfg *configtypes.ClientConfig, err error)
- func GetConfigMetadata() (*configtypes.ConfigMetadata, error)
- func GetConfigMetadataPatchStrategy() (map[string]string, error)
- func GetConfigMetadataSetting(key string) (string, error)
- func GetConfigMetadataSettings() (map[string]string, error)
- func GetContext(name string) (*configtypes.Context, error)
- func GetCurrentContext(target configtypes.Target) (c *configtypes.Context, err error)
- func GetCurrentServer() (*configtypes.Server, error)
- func GetEdition() (string, error)
- func GetEnv(key string) (string, error)
- func GetEnvConfigurations() map[string]string
- func GetMetadata() (*configtypes.Metadata, error)
- func GetServer(name string) (*configtypes.Server, error)
- func IsConfigMetadataSettingsEnabled(key string) (bool, error)
- func IsFeatureActivated(feature string) bool
- func IsFeatureEnabled(plugin, key string) (bool, error)
- func LocalDir() (path string, err error)
- func PopulateContexts(cfg *configtypes.ClientConfig) bool
- func PutServer(s *configtypes.Server, setCurrent bool) error
- func ReleaseTanzuConfigLock()
- func ReleaseTanzuConfigNextGenLock()
- func ReleaseTanzuMetadataLock()
- func RemoveContext(name string) error
- func RemoveCurrentContext(target configtypes.Target) error
- func RemoveCurrentServer(name string) error
- func RemoveServer(name string) error
- func ServerExists(name string) (bool, error)
- func SetCLIDiscoverySource(discoverySource configtypes.PluginDiscovery) (err error)
- func SetCLIDiscoverySources(discoverySources []configtypes.PluginDiscovery) (err error)
- func SetCLIRepository(repository configtypes.PluginRepository) (err error)
- func SetConfigMetadataPatchStrategies(patchStrategies map[string]string) error
- func SetConfigMetadataPatchStrategy(key, value string) error
- func SetConfigMetadataSetting(key, value string) (err error)
- func SetContext(c *configtypes.Context, setCurrent bool) error
- func SetCurrentContext(name string) error
- func SetCurrentServer(name string) error
- func SetEdition(val string) (err error)
- func SetEnv(key, value string) (err error)
- func SetFeature(plugin, key, value string) (err error)
- func SetServer(s *configtypes.Server, setCurrent bool) error
- func StoreClientConfig(cfg *configtypes.ClientConfig) error
- func UseUnifiedConfig() (bool, error)
- type CfgOptions
- type CfgOpts
Constants ¶
const ( // EnvConfigKey is the environment variable that points to a tanzu config. EnvConfigKey = "TANZU_CONFIG" // ConfigName is the name of the config ConfigName = "config.yaml" )
const ( // EnvConfigNextGenKey is the environment variable that points to a tanzu config. EnvConfigNextGenKey = "TANZU_CONFIG_NEXT_GEN" // CfgNextGenName is the name of the config metadata CfgNextGenName = "config-ng.yaml" )
const ( LocalTanzuConfigNextGenFileLock = ".tanzu-config-ng.lock" // DefaultConfigNextGenLockTimeout is the default time waiting on the filelock DefaultConfigNextGenLockTimeout = 10 * time.Minute )
const ( // EnvEndpointKey is the environment variable that overrides the tanzu endpoint. EnvEndpointKey = "TANZU_ENDPOINT" //nolint:gosec // Avoid "hardcoded credentials" false positive. // EnvAPITokenKey is the environment variable that overrides the tanzu API token for global auth. EnvAPITokenKey = "TANZU_API_TOKEN" )
const ( KeyServers = "servers" KeyContexts = "contexts" KeyCurrentServer = "current" KeyCurrentContext = "currentContext" KeyClientOptions = "clientOptions" KeyCLI = "cli" KeyFeatures = "features" KeyEnv = "env" KeyDiscoverySources = "discoverySources" KeyRepositories = "repositories" KeyUnstableVersionSelector = "unstableVersionSelector" KeyEdition = "edition" KeyKind = "kind" KeyMetadata = "metadata" KeyAPIVersion = "apiVersion" KeyBomRepo = "bomRepo" KeyCompatibilityFilePath = "compatibilityFilePath" )
Keys used to parse the yaml node to retrieve specific stanza of the config file
const ( DiscoveryTypeOCI = "oci" DiscoveryTypeLocal = "local" DiscoveryTypeGCP = "gcp" DiscoveryTypeKubernetes = "kubernetes" DiscoveryTypeREST = "rest" )
DiscoveryType constants
const ( LocalTanzuFileLock = ".tanzu.lock" // DefaultLockTimeout is the default time waiting on the filelock DefaultLockTimeout = 10 * time.Minute )
const ( // EnvConfigMetadataKey is the environment variable that points to a tanzu config. EnvConfigMetadataKey = "TANZU_CONFIG_METADATA" // CfgMetadataName is the name of the config metadata hidden file CfgMetadataName = ".config-metadata.yaml" )
const ( KeyConfigMetadata = "configMetadata" KeyPatchStrategy = "patchStrategy" KeySettings = "settings" )
Keys used to parse the yaml node to retrieve specific stanza of the config file
const ( LocalTanzuMetadataFileLock = ".tanzu-metadata.lock" // DefaultMetadataLockTimeout is the default time waiting on the filelock DefaultMetadataLockTimeout = 10 * time.Minute )
const (
Default = "default"
)
const (
SettingUseUnifiedConfig = "useUnifiedConfig"
)
Variables ¶
var ( // LocalDirName is the name of the local directory in which tanzu state is stored. LocalDirName = ".config/tanzu" // TestLocalDirName is the name of the local directory in which tanzu state is stored for testing. TestLocalDirName = ".tanzu-test" )
var DiscardedConfigNodeKeys = []string{ KeyContexts, KeyCurrentContext, }
var LegacyConfigNodeKeys = []string{ KeyAPIVersion, KeyKind, KeyMetadata, KeyClientOptions, KeyServers, KeyCurrentServer, }
LegacyConfigNodeKeys config nodes that goes to config.yaml
Functions ¶
func AcquireTanzuConfigLock ¶
func AcquireTanzuConfigLock()
AcquireTanzuConfigLock tries to acquire lock to update tanzu config file with timeout
func AcquireTanzuConfigNextGenLock ¶ added in v0.0.2
func AcquireTanzuConfigNextGenLock()
AcquireTanzuConfigNextGenLock tries to acquire lock to update tanzu config file with timeout
func AcquireTanzuMetadataLock ¶ added in v0.0.2
func AcquireTanzuMetadataLock()
AcquireTanzuMetadataLock tries to acquire lock to update tanzu config metadata file with timeout
func AddContext ¶
func AddContext(c *configtypes.Context, setCurrent bool) error
AddContext add or update context and currentContext
func AddServer ¶
func AddServer(s *configtypes.Server, setCurrent bool) error
AddServer add or update server and currentServer
func CfgMetadataFilePath ¶ added in v0.0.2
func ClientConfigNextGenPath ¶ added in v0.0.2
ClientConfigNextGenPath retrieved config-alt file path
func ClientConfigPath ¶
ClientConfigPath returns the tanzu config path, checking for environment overrides.
func ConfigureDefaultFeatureFlagsIfMissing ¶ added in v0.0.2
func ConfigureDefaultFeatureFlagsIfMissing(plugin string, defaultFeatureFlags map[string]bool) error
ConfigureDefaultFeatureFlagsIfMissing add or update plugin features based on specified default feature flags
func ContextExists ¶
ContextExists checks if context by name already exists
func CopyLegacyConfigDir ¶
func CopyLegacyConfigDir() error
CopyLegacyConfigDir copies configuration files from legacy config dir to the new location. This is a no-op if the legacy dir does not exist or if the new config dir already exists.
func DeleteCLIDiscoverySource ¶ added in v0.0.2
DeleteCLIDiscoverySource delete cli discoverySource by name
func DeleteCLIRepository ¶ added in v0.0.2
DeleteCLIRepository delete a cli repository by name
func DeleteClientConfig ¶
func DeleteClientConfig() error
DeleteClientConfig deletes the config yaml from the local directory.
func DeleteClientConfigNextGen ¶ added in v0.0.2
func DeleteClientConfigNextGen() error
DeleteClientConfigNextGen deletes the config-ng yaml from the local directory.
func DeleteConfigMetadataSetting ¶ added in v0.0.2
DeleteConfigMetadataSetting delete the env entry of specified key
func DeleteContext ¶ added in v0.0.2
DeleteContext delete a context by name
func DeleteFeature ¶ added in v0.0.2
DeleteFeature deletes the specified plugin key
func DeleteServer ¶ added in v0.0.2
DeleteServer deletes the server specified by name
func EndpointFromContext ¶
func EndpointFromContext(s *configtypes.Context) (endpoint string, err error)
EndpointFromContext retrieved the endpoint from the specified context
func EndpointFromServer ¶
func EndpointFromServer(s *configtypes.Server) (endpoint string, err error)
EndpointFromServer returns the endpoint from server.
func GetAllCurrentContextsList ¶ added in v0.0.2
GetAllCurrentContextsList returns all current context names as list
func GetAllCurrentContextsMap ¶ added in v0.0.2
func GetAllCurrentContextsMap() (map[configtypes.Target]*configtypes.Context, error)
GetAllCurrentContextsMap returns all current context per Target
func GetAllEnvs ¶ added in v0.0.2
GetAllEnvs retrieves all env values from config
func GetCLIDiscoverySource ¶ added in v0.0.2
func GetCLIDiscoverySource(name string) (*configtypes.PluginDiscovery, error)
GetCLIDiscoverySource retrieves cli discovery source by name assuming that there should only be one source with the name, returns the first match
func GetCLIDiscoverySources ¶ added in v0.0.2
func GetCLIDiscoverySources() ([]configtypes.PluginDiscovery, error)
GetCLIDiscoverySources retrieves cli discovery sources
func GetCLIRepositories ¶ added in v0.0.2
func GetCLIRepositories() ([]configtypes.PluginRepository, error)
GetCLIRepositories retrieves cli repositories
func GetCLIRepository ¶ added in v0.0.2
func GetCLIRepository(name string) (*configtypes.PluginRepository, error)
GetCLIRepository retrieves cli repository by name
func GetClientConfig ¶
func GetClientConfig() (cfg *configtypes.ClientConfig, err error)
GetClientConfig retrieves the config from the local directory with file lock
func GetClientConfigNoLock ¶
func GetClientConfigNoLock() (cfg *configtypes.ClientConfig, err error)
GetClientConfigNoLock retrieves the config from the local directory without acquiring the lock
func GetConfigMetadata ¶ added in v0.0.2
func GetConfigMetadata() (*configtypes.ConfigMetadata, error)
GetConfigMetadata retrieves configMetadata
func GetConfigMetadataPatchStrategy ¶ added in v0.0.2
GetConfigMetadataPatchStrategy retrieves patch strategies
func GetConfigMetadataSetting ¶ added in v0.0.2
func GetConfigMetadataSettings ¶ added in v0.0.2
GetConfigMetadataSettings retrieves feature flags
func GetContext ¶
func GetContext(name string) (*configtypes.Context, error)
GetContext retrieves the context by name
func GetCurrentContext ¶
func GetCurrentContext(target configtypes.Target) (c *configtypes.Context, err error)
GetCurrentContext retrieves the current context for the specified target
func GetCurrentServer ¶
func GetCurrentServer() (*configtypes.Server, error)
GetCurrentServer retrieves the current server
func GetEnvConfigurations ¶
GetEnvConfigurations returns a map of configured environment variables to values as part of tanzu configuration file it returns nil if configuration is not yet defined
func GetMetadata ¶ added in v0.0.2
func GetMetadata() (*configtypes.Metadata, error)
GetMetadata retrieves Metadata
func GetServer ¶
func GetServer(name string) (*configtypes.Server, error)
GetServer retrieves server by name
func IsConfigMetadataSettingsEnabled ¶ added in v0.0.2
IsConfigMetadataSettingsEnabled checks and returns whether specific plugin and key is true
func IsFeatureActivated ¶
IsFeatureActivated returns true if the given feature is activated User can set this CLI feature flag using `tanzu config set features.global.<feature> true`
func IsFeatureEnabled ¶ added in v0.0.2
IsFeatureEnabled checks and returns whether specific plugin and key is true
func PopulateContexts ¶
func PopulateContexts(cfg *configtypes.ClientConfig) bool
PopulateContexts converts the known servers that are missing in contexts. This is needed when reading the config file persisted by an older core or plugin, so that it is forwards compatible with a new core plugin. Returns true if there was any delta.
func PutServer ¶
func PutServer(s *configtypes.Server, setCurrent bool) error
PutServer add or update server and currentServer
func ReleaseTanzuConfigLock ¶
func ReleaseTanzuConfigLock()
ReleaseTanzuConfigLock releases the lock if the tanzuConfigLock was acquired
func ReleaseTanzuConfigNextGenLock ¶ added in v0.0.2
func ReleaseTanzuConfigNextGenLock()
ReleaseTanzuConfigNextGenLock releases the lock if the tanzuConfigLock was acquired
func ReleaseTanzuMetadataLock ¶ added in v0.0.2
func ReleaseTanzuMetadataLock()
ReleaseTanzuMetadataLock releases the lock if the tanzuMetadataLock was acquired
func RemoveCurrentContext ¶ added in v0.0.2
func RemoveCurrentContext(target configtypes.Target) error
RemoveCurrentContext removed the current context of specified context type
func RemoveCurrentServer ¶ added in v0.0.2
RemoveCurrentServer removes the current server if server exists by specified name
func ServerExists ¶
ServerExists checks if server by specified name is present in config
func SetCLIDiscoverySource ¶ added in v0.0.2
func SetCLIDiscoverySource(discoverySource configtypes.PluginDiscovery) (err error)
SetCLIDiscoverySource add or update a cli discoverySource
func SetCLIDiscoverySources ¶ added in v0.0.2
func SetCLIDiscoverySources(discoverySources []configtypes.PluginDiscovery) (err error)
SetCLIDiscoverySources Add/Update array of cli discovery sources to the yaml node
func SetCLIRepository ¶ added in v0.0.2
func SetCLIRepository(repository configtypes.PluginRepository) (err error)
SetCLIRepository add or update a repository
func SetConfigMetadataPatchStrategies ¶ added in v0.0.2
SetConfigMetadataPatchStrategies add or update map of patch strategies
func SetConfigMetadataPatchStrategy ¶ added in v0.0.2
SetConfigMetadataPatchStrategy add or update patch strategy specified by key-value pair
func SetConfigMetadataSetting ¶ added in v0.0.2
SetConfigMetadataSetting add or update a env key and value
func SetContext ¶ added in v0.0.2
func SetContext(c *configtypes.Context, setCurrent bool) error
SetContext add or update context and currentContext
func SetCurrentContext ¶
SetCurrentContext sets the current context to the specified name if context is present
func SetCurrentServer ¶
SetCurrentServer add or update current server
func SetEdition ¶ added in v0.0.2
SetEdition adds or updates edition value
func SetFeature ¶ added in v0.0.2
SetFeature add or update plugin key value
func SetServer ¶ added in v0.0.2
func SetServer(s *configtypes.Server, setCurrent bool) error
SetServer add or update server and currentServer
func StoreClientConfig ¶
func StoreClientConfig(cfg *configtypes.ClientConfig) error
StoreClientConfig stores the config in the local directory. Make sure to Acquire and Release tanzu lock when reading/writing to the tanzu client configuration Deprecated: StoreClientConfig is deprecated. Avoid using this method for Delete operations. Use New Config API methods.
func UseUnifiedConfig ¶ added in v0.0.2
UseUnifiedConfig checks useUnifiedConfig feature flag
Types ¶
type CfgOptions ¶ added in v0.0.2
type CfgOptions struct {
CfgPath string // file path to the config file
}
type CfgOpts ¶ added in v0.0.2
type CfgOpts func(config *CfgOptions)
func WithCfgPath ¶ added in v0.0.2
Source Files
¶
- cli_discovery_sources.go
- cli_options.go
- cli_repositories.go
- clientconfig_factory.go
- clientconfig_filesystem.go
- clientconfignextgen_factory.go
- clientconfignextgen_filesystem.go
- clientconfignextgen_lock.go
- config_factory.go
- config_filesystem.go
- config_keys.go
- config_types.go
- contexts.go
- conversion.go
- discovery_sources_node.go
- envs.go
- features.go
- fileutil.go
- legacy_clientconfig.go
- legacy_clientconfig_factory.go
- legacy_clientconfig_filesystem.go
- lock.go
- metadata_api.go
- metadata_factory.go
- metadata_filesystem.go
- metadata_keys.go
- metadata_lock.go
- metadata_settings_api.go
- servers.go
Directories
¶
Path | Synopsis |
---|---|
Package collectionutils provide helper functions to operate on collections like array, map
|
Package collectionutils provide helper functions to operate on collections like array, map |
Package nodeutils provides utility methods to perform operations on yaml node
|
Package nodeutils provides utility methods to perform operations on yaml node |
Package types specifies the types for clientconfig
|
Package types specifies the types for clientconfig |