config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config provides functions for reading and writing client configuration.

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 (
	// NameHeader used by every client making an API call
	NameHeader = "x-client-name"

	// VersionHeader is the client version header.
	VersionHeader = "x-client-version"
)
View Source
const AdvancedRepositoryName = "advanced"

AdvancedRepositoryName is the advanced repository name.

View Source
const CoreRepositoryName = "core"

CoreRepositoryName is the core repository name.

View Source
const DefaultVersionSelector = configv1alpha1.NoUnstableVersions

DefaultVersionSelector is to only use stable versions of plugins

Variables

View Source
var AdvancedGCPBucketRepository = configv1alpha1.GCPPluginRepository{
	BucketName: "tanzu-cli-advanced-plugins",
	Name:       AdvancedRepositoryName,
}

AdvancedGCPBucketRepository is the GCP bucket repository for advanced plugins.

View Source
var CoreBucketName = "tanzu-cli-framework"

CoreBucketName is the name of the core plugin repository bucket to use.

View Source
var CoreGCPBucketRepository = configv1alpha1.GCPPluginRepository{
	BucketName: CoreBucketName,
	Name:       CoreRepositoryName,
}

CoreGCPBucketRepository is the default GCP bucket repository.

View Source
var DefaultRepositories []configv1alpha1.PluginRepository = []configv1alpha1.PluginRepository{
	{
		GCPPluginRepository: &CoreGCPBucketRepository,
	},
}

DefaultRepositories are the default repositories for the CLI.

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

func ClientConfigPath() (path string, err error)

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 LocalDir

func LocalDir() (path string, err error)

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

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 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 SetCurrentServer

func SetCurrentServer(name string) error

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.

Jump to

Keyboard shortcuts

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