config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: Apache-2.0 Imports: 13 Imported by: 21

Documentation

Overview

Package config provides tanzu cli runtime configs

Index

Constants

View Source
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"
)
View Source
const (
	LocalTanzuFileLock = ".tanzu.lock"
	// DefaultLockTimeout is the default time waiting on the filelock
	DefaultLockTimeout = 10 * time.Minute
)

Variables

View Source
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

func AddContext(c *configapi.Context, setCurrent bool) error

AddContext adds a Context to the config.

func AddServer

func AddServer(s *configapi.Server, setCurrent bool) error

AddServer adds a server to the config.

func ClientConfigPath

func ClientConfigPath() (path string, err error)

ClientConfigPath returns the tanzu config path, checking for environment overrides.

func ContextExists

func ContextExists(name string) (bool, error)

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

func EndpointFromContext(s *configapi.Context) (endpoint string, err error)

EndpointFromContext returns the endpoint from context.

func EndpointFromServer

func EndpointFromServer(s *configapi.Server) (endpoint string, err error)

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 GetContext

func GetContext(name string) (*configapi.Context, error)

GetContext by name.

func GetCurrentContext

func GetCurrentContext(ctxType configapi.ContextType) (c *configapi.Context, err error)

GetCurrentContext gets the current context.

func GetCurrentServer

func GetCurrentServer() (s *configapi.Server, err error)

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

func GetEdition() (string, error)

GetEdition returns the edition from the local configuration file

func GetEnvConfigurations

func GetEnvConfigurations() map[string]string

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 GetServer

func GetServer(name string) (s *configapi.Server, err error)

GetServer by name.

func IsFeatureActivated

func IsFeatureActivated(feature string) bool

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 LocalDir

func LocalDir() (path string, err error)

LocalDir returns the local directory in which tanzu state is stored.

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 PutServer

func PutServer(s *configapi.Server, setCurrent bool) error

PutServer adds or updates the server.

func ReleaseTanzuConfigLock

func ReleaseTanzuConfigLock()

ReleaseTanzuConfigLock releases the lock if the tanzuConfigLock was acquired

func RemoveContext

func RemoveContext(name string) error

RemoveContext removes a Context from the config.

func RemoveServer

func RemoveServer(name string) error

RemoveServer adds a server to the config.

func ServerExists

func ServerExists(name string) (bool, error)

ServerExists tells whether the server by the given name exists.

func SetCurrentContext

func SetCurrentContext(name string) error

SetCurrentContext sets the current Context.

func SetCurrentServer

func SetCurrentServer(name string) error

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.

Jump to

Keyboard shortcuts

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