config

package
v0.0.0-...-fe3d3e7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config contains the primary configuration options that are used when doing operations in the tanzu package.

Index

Constants

View Source
const (
	ClusterConfigFile = "ClusterConfigFile"
	Tty               = "Tty"

	// UnmanagedClusterConfig option keys
	ClusterName               = "ClusterName"
	KubeconfigPath            = "KubeconfigPath"
	ExistingClusterKubeconfig = "ExistingClusterKubeconfig"
	NodeImage                 = "NodeImage"
	Provider                  = "Provider"
	Cni                       = "Cni"
	PodCIDR                   = "PodCidr"
	ServiceCIDR               = "ServiceCidr"
	TKRLocation               = "TkrLocation"
	AdditionalPackageRepos    = "AdditionalPackageRepos"
	PortsToForward            = "PortsToForward"
	SkipPreflightChecks       = "SkipPreflightChecks"
	ControlPlaneNodeCount     = "ControlPlaneNodeCount"
	WorkerNodeCount           = "WorkerNodeCount"
	InstallPackages           = "InstallPackages"
	LogFile                   = "LogFile"

	ProtocolTCP  = "tcp"
	ProtocolUDP  = "udp"
	ProtocolSCTP = "sctp"

	ProviderKind     = "kind"
	ProviderMinikube = "minikube"
	ProviderNone     = "none"
)

Variables

This section is empty.

Functions

func GetTanzuConfigPath

func GetTanzuConfigPath() (string, error)

GetTanzuConfigPath returns the filepath to the config directory. For example, on linux, "~/.config/tanzu/" Returns an error if the user home directory path cannot be resolved

func GetTanzuTkgConfigPath

func GetTanzuTkgConfigPath() (string, error)

GetTanzuTkgConfigPath returns the filepath to the tanzu tkg config directory. For example, on linux, "~/.config/tanzu/tkg" Returns an error if the path cannot be resolved

func GetUnmanagedConfigPath

func GetUnmanagedConfigPath() (string, error)

GetUnmanagedConfigPath returns the filepath to the unmanaged config directory. For example, on linux, "~/.config/tanzu/tkg/unmanaged" Returns an error if the path cannot be resolved

func RenderConfigToFile

func RenderConfigToFile(filePath string, config interface{}) error

RenderConfigToFile take a file path and serializes the configuration data to that path. It expects the path to not exist, if it does, an error is returned.

Types

type InstallPackage

type InstallPackage struct {
	Name    string `yaml:"name,omitempty"`
	Config  string `yaml:"config,omitempty"`
	Version string `yaml:"version,omitempty"`
}

func ParseInstallPackageMappings

func ParseInstallPackageMappings(installPackageMaps []string) ([]InstallPackage, error)

ParseInstallPackageMappings creates a slice of InstallPackages that maps a package name, version, and config file path based on user provided mapping.

installPackageMaps is a slice of InstallPackage mappings. Since users can provide multiple install-package flags, and cobra supports this workflow, we need to be able to parse multiple strings that are each individually a set of installPackage maps

A string in installPackageMaps is expected to be of the following format where each mapping is delimitted by a `,`:

mapping-0,mapping-1, ... ,mapping-N

Each mapping is expected to be in the following format: where each field is delimited by a `:`. If more than 2 `:` are found, an error is returned:

package-name:package-version:package-config

Both version and config are optional. It is possible to only provide a package name This function will create a InstallPackage that has an empty version and config with the name given in the installPackageMaps string.

See tests for further examples.

type PortMap

type PortMap struct {
	// ListenAddress is the listening address to attach on the host machine
	ListenAddress string `yaml:"ListenAddress,omitempty"`
	// HostPort is the port on the host machine.
	HostPort int `yaml:"HostPort,omitempty"`
	// ContainerPort is the port on the container to map to.
	ContainerPort int `yaml:"ContainerPort"`
	// Protocol is the IP protocol (TCP, UDP, SCTP).
	Protocol string `yaml:"Protocol,omitempty"`
}

PortMap is the mapping between a host port and a container port.

func ParsePortMappings

func ParsePortMappings(portMappings []string) ([]PortMap, error)

ParsePortMappings parses a slice of the command line string format into a slice of PortMap structs. Supported formats are just container port ("80"), container port to host port ("80:80"), container port to host port with protocol ("80:80/tcp"), or adding listen address prefixed to the above options ("127.0.0.1:80:80/tcp")

type UnmanagedClusterConfig

type UnmanagedClusterConfig struct {
	// ClusterName is the name of the cluster.
	ClusterName string `yaml:"ClusterName"`
	// KubeconfigPath is the location where the Kubeconfig will be persisted
	// after the cluster is created.
	KubeconfigPath string `yaml:"KubeconfigPath"`
	// ExistingClusterKubeconfig is the serialized path to the kubeconfig to use of an existing cluster.
	ExistingClusterKubeconfig string `yaml:"ExistingClusterKubeconfig"`
	// NodeImage is the host OS image to use for Kubernetes nodes.
	// It is typically resolved, automatically, in the Taznu Kubernetes Release (TKR) BOM,
	// but also can be overridden in configuration.
	NodeImage string `yaml:"NodeImage"`
	// Provider is the unmanaged infrastructure provider to use (e.g. kind).
	Provider string `yaml:"Provider"`
	// ProviderConfiguration offers optional provider-specific configuration.
	// The exact keys and values accepted are determined by the provider.
	ProviderConfiguration map[string]interface{} `yaml:"ProviderConfiguration"`
	// CNI is the networking CNI to use in the cluster. Default is calico.
	Cni string `yaml:"Cni"`
	// CNIConfiguration offers optional cni-plugin specific configuration.
	// The exact keys and values accepted are determined by the CNI choice.
	CNIConfiguration map[string]interface{} `yaml:"CniConfiguration"`
	// PodCidr is the Pod CIDR range to assign pod IP addresses.
	PodCidr string `yaml:"PodCidr"`
	// ServiceCidr is the Service CIDR range to assign service IP addresses.
	ServiceCidr string `yaml:"ServiceCidr"`
	// TkrLocation is the path to the Tanzu Kubernetes Release (TKR) data.
	TkrLocation string `yaml:"TkrLocation"`
	// AdditionalPackageRepos are the extra package repositories to install during bootstrapping
	AdditionalPackageRepos []string `yaml:"AdditionalPackageRepos"`
	// PortsToForward contains a mapping of host to container ports that should
	// be exposed.
	PortsToForward []PortMap `yaml:"PortsToForward"`
	// SkipPreflightChecks determines whether preflight checks are performed prior
	// to attempting to deploy the cluster.
	SkipPreflightChecks bool `yaml:"SkipPreflightChecks"`
	// ControlPlaneNodeCount is the number of control plane nodes to deploy for the cluster.
	// Default is 1
	ControlPlaneNodeCount string `yaml:"ControlPlaneNodeCount"`
	// WorkerNodeCount is the number of worker nodes to deploy for the cluster.
	// Default is 0
	WorkerNodeCount string `yaml:"WorkerNodeCount"`
	// InstallPackages is a set of packages to install, including the package name, (optional) version, (optional) config
	InstallPackages []InstallPackage `yaml:"InstallPackages"`
	// LogFile is the log file to send provider bootstrapping logs to
	// should be a fully qualified path
	LogFile string `yaml:"LogFile"`
}

UnmanagedClusterConfig contains all the configuration settings for creating a unmanaged Tanzu cluster.

func GenerateDefaultConfig

func GenerateDefaultConfig() *UnmanagedClusterConfig

func InitializeConfiguration

func InitializeConfiguration(commandArgs map[string]interface{}) (*UnmanagedClusterConfig, error)

InitializeConfiguration determines the configuration to use for cluster creation.

There are three places where configuration comes from: - default settings - configuration file - environment variables - command line arguments

The effective configuration is determined by combining these sources, in ascending order of preference listed. So env variables override values in the config file, and explicit CLI arguments override config file and env variable values.

func RenderFileToConfig

func RenderFileToConfig(filePath string) (*UnmanagedClusterConfig, error)

RenderFileToConfig reads in configuration from a file and returns the UnmanagedClusterConfig structure based on it. If the file does not exist or there is a problem reading the configuration from it an error is returned.

func (*UnmanagedClusterConfig) KubeConfigPath

func (scc *UnmanagedClusterConfig) KubeConfigPath() (string, error)

KubeConfigPath gets the full path to the KubeConfig for this unmanaged cluster.

Jump to

Keyboard shortcuts

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