Documentation ¶
Overview ¶
Package config provides functions for reading and writing client configuration.
Index ¶
- Constants
- Variables
- func AddServer(s *configv1alpha1.Server, setCurrent bool) error
- func ClientConfigPath() (path string, err error)
- func CopyLegacyConfigDir() error
- func DeleteClientConfig() error
- func EndpointFromServer(s *configv1alpha1.Server) (endpoint string, err error)
- func GetClientConfig() (cfg *configv1alpha1.ClientConfig, err error)
- func GetCurrentServer() (s *configv1alpha1.Server, err error)
- func GetServer(name string) (s *configv1alpha1.Server, err error)
- func IsContextAwareDiscoveryEnabled() bool
- func LocalDir() (path string, err error)
- func NewClientConfig() (*configv1alpha1.ClientConfig, error)
- func PutServer(s *configv1alpha1.Server, setCurrent bool) error
- func RemoveServer(name string) error
- func ServerExists(name string) (bool, error)
- func SetCurrentServer(name string) error
- func StoreClientConfig(cfg *configv1alpha1.ClientConfig) error
- type ClientConfigNotExistError
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 ( // NameHeader used by every client making an API call NameHeader = "x-client-name" // VersionHeader is the client version header. VersionHeader = "x-client-version" )
const AdvancedRepositoryName = "advanced"
AdvancedRepositoryName is the advanced repository name.
const CoreRepositoryName = "core"
CoreRepositoryName is the core repository name.
const DefaultVersionSelector = configv1alpha1.NoUnstableVersions
DefaultVersionSelector is to only use stable versions of plugins
Variables ¶
var AdvancedGCPBucketRepository = configv1alpha1.GCPPluginRepository{ BucketName: "tanzu-cli-advanced-plugins", Name: AdvancedRepositoryName, }
AdvancedGCPBucketRepository is the GCP bucket repository for advanced plugins.
var CoreBucketName = "tanzu-cli-framework"
CoreBucketName is the name of the core plugin repository bucket to use.
var CoreGCPBucketRepository = configv1alpha1.GCPPluginRepository{ BucketName: CoreBucketName, Name: CoreRepositoryName, }
CoreGCPBucketRepository is the default GCP bucket repository.
var ( DefaultCliFeatureFlags = map[string]bool{ "features.management-cluster.import": false, "features.management-cluster.export-from-config": false, "features.global.use-context-aware-discovery": common.IsContextAwareDiscoveryEnabled, } )
DefaultCliFeatureFlags is used to populate an initially empty config file with default values for feature flags. If a developer expects that their feature will be ready to release, they should create an entry here with a true value. If a developer has a beta feature they want to expose, but leave turned off by default, they should create an entry here with a false value. The keys MUST be in the format "features.<plugin>.<feature>" or initialization will fail. Note that "global" is a special value for <plugin> to be used for CLI-wide features.
var DefaultRepositories []configv1alpha1.PluginRepository = []configv1alpha1.PluginRepository{ { GCPPluginRepository: &CoreGCPBucketRepository, }, }
DefaultRepositories are the default repositories for the CLI.
var (
// LocalDirName is the name of the local directory in which tanzu state is stored.
LocalDirName = ".config/tanzu"
)
Functions ¶
func AddServer ¶
func AddServer(s *configv1alpha1.Server, setCurrent bool) error
AddServer adds a server to the config.
func ClientConfigPath ¶
ClientConfigPath returns the tanzu config path, checking for environment overrides.
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 EndpointFromServer ¶
func EndpointFromServer(s *configv1alpha1.Server) (endpoint string, err error)
EndpointFromServer returns the endpoint from server.
func GetClientConfig ¶
func GetClientConfig() (cfg *configv1alpha1.ClientConfig, err error)
GetClientConfig retrieves the config from the local directory.
func GetCurrentServer ¶
func GetCurrentServer() (s *configv1alpha1.Server, err error)
GetCurrentServer sets the current server.
func GetServer ¶
func GetServer(name string) (s *configv1alpha1.Server, err error)
GetServer by name.
func IsContextAwareDiscoveryEnabled ¶ added in v0.8.0
func IsContextAwareDiscoveryEnabled() bool
IsContextAwareDiscoveryEnabled returns true if context-aware discovery is enabled User can set this CLI feature flag using `tanzu config set features.global.use-context-aware-discovery true` This determines whether to use legacy way of discovering plugins or to use the new context-aware Plugin API based plugin discovery mechanism Users can set this featureflag so that we can have context-aware plugin discovery be opt-in for now.
func NewClientConfig ¶
func NewClientConfig() (*configv1alpha1.ClientConfig, error)
NewClientConfig returns a new config.
func PutServer ¶
func PutServer(s *configv1alpha1.Server, setCurrent bool) error
PutServer adds or updates the server.
func ServerExists ¶
ServerExists tells whether the server by the given name exists.
func SetCurrentServer ¶
SetCurrentServer sets the current server.
func StoreClientConfig ¶
func StoreClientConfig(cfg *configv1alpha1.ClientConfig) error
StoreClientConfig stores the config in the local directory.
Types ¶
type ClientConfigNotExistError ¶
type ClientConfigNotExistError struct {
// contains filtered or unexported fields
}
ClientConfigNotExistError is thrown when a tanzu config cannot be found.
func NewConfigNotExistError ¶
func NewConfigNotExistError(err error) *ClientConfigNotExistError
NewConfigNotExistError returns a new ClientConfigNotExistError.
func (*ClientConfigNotExistError) Error ¶
func (c *ClientConfigNotExistError) Error() string
Error is the error message.