Documentation
¶
Overview ¶
Package config provides tanzu cli runtime configs
Index ¶
- Constants
- Variables
- func AcquireTanzuConfigLock()
- func AddContext(c *configapi.Context, setCurrent bool) error
- func AddServer(s *configapi.Server, setCurrent bool) error
- func ClientConfigPath() (path string, err error)
- func ContextExists(name string) (bool, error)
- func CopyLegacyConfigDir() error
- func DeleteClientConfig() error
- func EndpointFromContext(s *configapi.Context) (endpoint string, err error)
- func EndpointFromServer(s *configapi.Server) (endpoint string, err error)
- func GetClientConfig() (cfg *configapi.ClientConfig, err error)
- func GetClientConfigNoLock() (cfg *configapi.ClientConfig, err error)
- func GetContext(name string) (*configapi.Context, error)
- func GetCurrentContext(ctxType configapi.ContextType) (c *configapi.Context, err error)
- func GetCurrentServer() (s *configapi.Server, err error)
- func GetDiscoverySources(serverName string) []configapi.PluginDiscovery
- func GetEdition() (string, error)
- func GetEnvConfigurations() map[string]string
- func GetServer(name string) (s *configapi.Server, err error)
- func IsFeatureActivated(feature string) bool
- func IsTanzuConfigLockAcquired() bool
- func LocalDir() (path string, err error)
- func NewClientConfig() (*configapi.ClientConfig, error)
- func PopulateContexts(cfg *configapi.ClientConfig) bool
- func PutServer(s *configapi.Server, setCurrent bool) error
- func ReleaseTanzuConfigLock()
- func RemoveContext(name string) error
- func RemoveServer(name string) error
- func ServerExists(name string) (bool, error)
- func SetCurrentContext(name string) error
- func SetCurrentServer(name string) error
- func StoreClientConfig(cfg *configapi.ClientConfig) error
Constants ¶
const ( // EnvConfigKey is the environment variable that points to a tanzu config. EnvConfigKey = "TANZU_CONFIG" // 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" // ConfigName is the name of the config ConfigName = "config.yaml" )
const ( LocalTanzuFileLock = ".tanzu.lock" // DefaultLockTimeout is the default time waiting on the filelock DefaultLockTimeout = 10 * time.Minute )
Variables ¶
var (
// LocalDirName is the name of the local directory in which tanzu state is stored.
LocalDirName = ".config/tanzu"
)
Functions ¶
func AcquireTanzuConfigLock ¶
func AcquireTanzuConfigLock()
AcquireTanzuConfigLock tries to acquire lock to update tanzu config file with timeout
func AddContext ¶
AddContext adds a Context to the config.
func ClientConfigPath ¶
ClientConfigPath returns the tanzu config path, checking for environment overrides.
func ContextExists ¶
ContextExists tells whether the Context by the given name 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 DeleteClientConfig ¶
func DeleteClientConfig() error
DeleteClientConfig deletes the config from the local directory.
func EndpointFromContext ¶
EndpointFromContext returns the endpoint from context.
func EndpointFromServer ¶
EndpointFromServer returns the endpoint from server.
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 GetCurrentContext ¶
func GetCurrentContext(ctxType configapi.ContextType) (c *configapi.Context, err error)
GetCurrentContext gets the current context.
func GetCurrentServer ¶
GetCurrentServer gets the current server.
func GetDiscoverySources ¶
func GetDiscoverySources(serverName string) []configapi.PluginDiscovery
GetDiscoverySources returns all discovery sources Includes standalone discovery sources and if server is available it also includes context based discovery sources as well
func GetEdition ¶
GetEdition returns the edition from the local configuration file
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 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 IsTanzuConfigLockAcquired ¶
func IsTanzuConfigLockAcquired() bool
IsTanzuConfigLockAcquired checks the lock status and returns true if the lock is acquired by the current process or returns false otherwise
func NewClientConfig ¶
func NewClientConfig() (*configapi.ClientConfig, error)
NewClientConfig returns a new config.
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 RemoveContext ¶
RemoveContext removes a Context from the config.
func ServerExists ¶
ServerExists tells whether the server by the given name exists.
func SetCurrentContext ¶
SetCurrentContext sets the current Context.
func SetCurrentServer ¶
SetCurrentServer sets the current server.
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
Types ¶
This section is empty.