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 *configapi.Context, setCurrent bool) error
- func AddServer(s *configapi.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 *configapi.Context) (endpoint string, err error)
- func EndpointFromServer(s *configapi.Server) (endpoint string, err error)
- func GetAllCurrentContextsList() ([]string, error)
- func GetAllCurrentContextsMap() (map[cliapi.Target]*configapi.Context, error)
- func GetAllEnvs() (map[string]string, error)
- func GetCLIDiscoverySource(name string) (*configapi.PluginDiscovery, error)
- func GetCLIDiscoverySources() ([]configapi.PluginDiscovery, error)
- func GetCLIRepositories() ([]configapi.PluginRepository, error)
- func GetCLIRepository(name string) (*configapi.PluginRepository, error)
- func GetClientConfig() (cfg *configapi.ClientConfig, err error)
- func GetClientConfigNoLock() (cfg *configapi.ClientConfig, err error)
- func GetConfigMetadata() (*configapi.ConfigMetadata, error)
- func GetConfigMetadataPatchStrategy() (map[string]string, error)
- func GetConfigMetadataSetting(key string) (string, error)
- func GetConfigMetadataSettings() (map[string]string, error)
- func GetContext(name string) (*configapi.Context, error)
- func GetCurrentContext(target cliapi.Target) (c *configapi.Context, err error)
- func GetCurrentServer() (*configapi.Server, error)
- func GetEdition() (string, error)
- func GetEnv(key string) (string, error)
- func GetEnvConfigurations() map[string]string
- func GetMetadata() (*configapi.Metadata, error)
- func GetServer(name string) (*configapi.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 *configapi.ClientConfig) bool
- func PutServer(s *configapi.Server, setCurrent bool) error
- func ReleaseTanzuConfigLock()
- func ReleaseTanzuConfigNextGenLock()
- func ReleaseTanzuMetadataLock()
- func RemoveContext(name string) error
- func RemoveCurrentContext(target cliapi.Target) error
- func RemoveCurrentServer(name string) error
- func RemoveServer(name string) error
- func ServerExists(name string) (bool, error)
- func SetCLIDiscoverySource(discoverySource configapi.PluginDiscovery) (err error)
- func SetCLIDiscoverySources(discoverySources []configapi.PluginDiscovery) (err error)
- func SetCLIRepository(repository configapi.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 *configapi.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 *configapi.Server, setCurrent bool) error
- func StoreClientConfig(cfg *configapi.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 ¶
func AcquireTanzuConfigNextGenLock()
AcquireTanzuConfigNextGenLock tries to acquire lock to update tanzu config file with timeout
func AcquireTanzuMetadataLock ¶
func AcquireTanzuMetadataLock()
AcquireTanzuMetadataLock tries to acquire lock to update tanzu config metadata file with timeout
func AddContext ¶
AddContext add or update context and currentContext
func CfgMetadataFilePath ¶
func ClientConfigNextGenPath ¶
ClientConfigNextGenPath retrieved config-alt file path
func ClientConfigPath ¶
ClientConfigPath returns the tanzu config path, checking for environment overrides.
func ConfigureDefaultFeatureFlagsIfMissing ¶
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 ¶
DeleteCLIDiscoverySource delete cli discoverySource by name
func DeleteCLIRepository ¶
DeleteCLIRepository delete a cli repository by name
func DeleteClientConfig ¶
func DeleteClientConfig() error
DeleteClientConfig deletes the config yaml from the local directory.
func DeleteClientConfigNextGen ¶
func DeleteClientConfigNextGen() error
DeleteClientConfigNextGen deletes the config-ng yaml from the local directory.
func DeleteConfigMetadataSetting ¶
DeleteConfigMetadataSetting delete the env entry of specified key
func DeleteFeature ¶
DeleteFeature deletes the specified plugin key
func DeleteServer ¶
DeleteServer deletes the server specified by name
func EndpointFromContext ¶
EndpointFromContext retrieved the endpoint from the specified context
func EndpointFromServer ¶
EndpointFromServer returns the endpoint from server.
func GetAllCurrentContextsList ¶
GetAllCurrentContextsList returns all current context names as list
func GetAllCurrentContextsMap ¶
GetAllCurrentContextsMap returns all current context per Target
func GetAllEnvs ¶
GetAllEnvs retrieves all env values from config
func GetCLIDiscoverySource ¶
func GetCLIDiscoverySource(name string) (*configapi.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 ¶
func GetCLIDiscoverySources() ([]configapi.PluginDiscovery, error)
GetCLIDiscoverySources retrieves cli discovery sources
func GetCLIRepositories ¶
func GetCLIRepositories() ([]configapi.PluginRepository, error)
GetCLIRepositories retrieves cli repositories
func GetCLIRepository ¶
func GetCLIRepository(name string) (*configapi.PluginRepository, error)
GetCLIRepository retrieves cli repository by name
func GetClientConfig ¶
func GetClientConfig() (cfg *configapi.ClientConfig, err error)
GetClientConfig retrieves the config from the local directory with file lock
func GetClientConfigNoLock ¶
func GetClientConfigNoLock() (cfg *configapi.ClientConfig, err error)
GetClientConfigNoLock retrieves the config from the local directory without acquiring the lock
func GetConfigMetadata ¶
func GetConfigMetadata() (*configapi.ConfigMetadata, error)
GetConfigMetadata retrieves configMetadata
func GetConfigMetadataPatchStrategy ¶
GetConfigMetadataPatchStrategy retrieves patch strategies
func GetConfigMetadataSettings ¶
GetConfigMetadataSettings retrieves feature flags
func GetContext ¶
GetContext retrieves the context by name
func GetCurrentContext ¶
GetCurrentContext retrieves the current context for the specified target
func GetCurrentServer ¶
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 IsConfigMetadataSettingsEnabled ¶
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 ¶
IsFeatureEnabled checks and returns whether specific plugin and key is true
func PopulateContexts ¶
func PopulateContexts(cfg *configapi.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 ReleaseTanzuConfigLock ¶
func ReleaseTanzuConfigLock()
ReleaseTanzuConfigLock releases the lock if the tanzuConfigLock was acquired
func ReleaseTanzuConfigNextGenLock ¶
func ReleaseTanzuConfigNextGenLock()
ReleaseTanzuConfigNextGenLock releases the lock if the tanzuConfigLock was acquired
func ReleaseTanzuMetadataLock ¶
func ReleaseTanzuMetadataLock()
ReleaseTanzuMetadataLock releases the lock if the tanzuMetadataLock was acquired
func RemoveCurrentContext ¶
RemoveCurrentContext removed the current context of specified context type
func RemoveCurrentServer ¶
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 ¶
func SetCLIDiscoverySource(discoverySource configapi.PluginDiscovery) (err error)
SetCLIDiscoverySource add or update a cli discoverySource
func SetCLIDiscoverySources ¶
func SetCLIDiscoverySources(discoverySources []configapi.PluginDiscovery) (err error)
SetCLIDiscoverySources Add/Update array of cli discovery sources to the yaml node
func SetCLIRepository ¶
func SetCLIRepository(repository configapi.PluginRepository) (err error)
SetCLIRepository add or update a repository
func SetConfigMetadataPatchStrategies ¶
SetConfigMetadataPatchStrategies add or update map of patch strategies
func SetConfigMetadataPatchStrategy ¶
SetConfigMetadataPatchStrategy add or update patch strategy specified by key-value pair
func SetConfigMetadataSetting ¶
SetConfigMetadataSetting add or update a env key and value
func SetContext ¶
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 SetFeature ¶
SetFeature add or update plugin key value
func StoreClientConfig ¶
func StoreClientConfig(cfg *configapi.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 ¶
UseUnifiedConfig checks useUnifiedConfig feature flag
Types ¶
type CfgOptions ¶
type CfgOptions struct {
CfgPath string // file path to the config file
}
Source Files ¶
- cli_discovery_sources.go
- cli_options.go
- cli_repositories.go
- clientconfig_factory.go
- clientconfig_filesystem.go
- clientconfig_typemeta.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 |