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 ConfigureEnvVariables()
- 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 GetDefaultStandaloneDiscoveryImage() string
- func GetDefaultStandaloneDiscoveryLocalPath() string
- func GetDefaultStandaloneDiscoveryType() string
- func GetDiscoverySources(serverName string) []configv1alpha1.PluginDiscovery
- func GetEdition() (string, error)
- func GetEnvConfigurations() map[string]string
- func GetServer(name string) (s *configv1alpha1.Server, err error)
- func GetTrustedRegistries() []string
- func IsFeatureActivated(feature string) 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 ( // FeatureContextAwareCLIForPlugins 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. FeatureContextAwareCLIForPlugins = "features.global.context-aware-cli-for-plugins" // DualStack feature flags determine whether it is permitted to create // clusters with a dualstack TKG_IP_FAMILY. There are separate flags for // each primary, "ipv4,ipv6" vs "ipv6,ipv4", and flags for management vs // workload cluster plugins. FeatureFlagManagementClusterDualStackIPv4Primary = "features.management-cluster.dual-stack-ipv4-primary" FeatureFlagManagementClusterDualStackIPv6Primary = "features.management-cluster.dual-stack-ipv6-primary" FeatureFlagClusterDualStackIPv4Primary = "features.cluster.dual-stack-ipv4-primary" FeatureFlagClusterDualStackIPv6Primary = "features.cluster.dual-stack-ipv6-primary" // Custom Nameserver feature flags determine whether it is permitted to // provide the CONTROL_PLANE_NODE_NAMESERVERS and WORKER_NODE_NAMESERVERS // when creating a cluster. FeatureFlagManagementClusterCustomNameservers = "features.management-cluster.custom-nameservers" FeatureFlagClusterCustomNameservers = "features.cluster.custom-nameservers" // Network Separation feature flags determine whether it is permitted to // provide the AVI_MANAGEMENT_CLUSTER_SERVICE_ENGINE_GROUP, AVI_CONTROL_PLANE_NETWORK, AVI_CONTROL_PLANE_NETWORK_CIDR, // AVI_MANAGEMENT_CLUSTER_CONTROL_PLANE_VIP_NETWORK_NAME and AVI_MANAGEMENT_CLUSTER_CONTROL_PLANE_VIP_NETWORK_CIDR // when creating a cluster. FeatureFlagManagementClusterNetworkSeparation = "features.management-cluster.network-separation-beta" )
This block is for global feature constants, to allow them to be used more broadly
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 DefaultEdition = "tkg"
DefaultEdition is the edition assumed when there is no value in the local config file
const DefaultVersionSelector = configv1alpha1.NoUnstableVersions
DefaultVersionSelector is to only use stable versions of plugins
Variables ¶
var ( DefaultStandaloneDiscoveryRepository = "" DefaultStandaloneDiscoveryImagePath = "" DefaultStandaloneDiscoveryImageTag = "" DefaultStandaloneDiscoveryName = "default" DefaultStandaloneDiscoveryNameLocal = "default-local" DefaultStandaloneDiscoveryType = common.DistributionTypeOCI DefaultStandaloneDiscoveryLocalPath = "" )
Default Standalone Discovery configuration Value of this variables gets assigned during build time
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{ FeatureContextAwareCLIForPlugins: common.ContextAwareDiscoveryEnabled(), "features.management-cluster.import": false, "features.management-cluster.export-from-confirm": true, "features.management-cluster.standalone-cluster-mode": false, FeatureFlagManagementClusterDualStackIPv4Primary: false, FeatureFlagManagementClusterDualStackIPv6Primary: false, FeatureFlagClusterDualStackIPv4Primary: false, FeatureFlagClusterDualStackIPv6Primary: false, FeatureFlagManagementClusterCustomNameservers: false, FeatureFlagClusterCustomNameservers: false, FeatureFlagManagementClusterNetworkSeparation: false, } )
DefaultCliFeatureFlags is used to populate an initially empty config file with default values for feature flags. 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.
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. WE HIGHLY RECOMMEND the use of a SEPARATE flag for beta use; one that ends in "-beta". Thus, if you plan to eventually release a feature with a flag named "features.cluster.foo-bar", you should consider releasing the beta version with "features.cluster.foo-bar-beta". This will make it much easier when it comes time for mainstreaming the feature (with a default true value) under the flag name "features.cluster.foo-bar", as there will be no conflict with previous installs (that have a false value for the entry "features.cluster.foo-bar-beta").
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 ConfigureEnvVariables ¶ added in v0.11.0
func ConfigureEnvVariables()
ConfigureEnvVariables reads and configures provided environment variables as part of tanzu configuration file
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 GetDefaultStandaloneDiscoveryImage ¶ added in v0.11.0
func GetDefaultStandaloneDiscoveryImage() string
GetDefaultStandaloneDiscoveryImage returns the default Standalone Discovery image from the configured build time variables
func GetDefaultStandaloneDiscoveryLocalPath ¶ added in v0.11.0
func GetDefaultStandaloneDiscoveryLocalPath() string
GetDefaultStandaloneDiscoveryLocalPath returns default standalone discovery local path
func GetDefaultStandaloneDiscoveryType ¶ added in v0.11.0
func GetDefaultStandaloneDiscoveryType() string
GetDefaultStandaloneDiscoveryType returns the default standalone discovery type
func GetDiscoverySources ¶ added in v0.11.0
func GetDiscoverySources(serverName string) []configv1alpha1.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 ¶ added in v0.16.0
GetEdition returns the edition from the local configuration file
func GetEnvConfigurations ¶ added in v0.11.0
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 *configv1alpha1.Server, err error)
GetServer by name.
func GetTrustedRegistries ¶ added in v0.11.2
func GetTrustedRegistries() []string
GetTrustedRegistries returns the list of trusted registries that can be used for downloading the CLIPlugins
func IsFeatureActivated ¶ added in v0.9.0
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 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.