config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultK8sServiceAccount is the default name of the Kubernetes
	// service account for csi controller.
	DefaultK8sServiceAccount string = "vsphere-csi-controller"
	// DefaultVCenterPort is the default port used to access vCenter.
	DefaultVCenterPort string = "443"
	// DefaultCloudConfigPath is the default path of csi config file
	DefaultCloudConfigPath = "/etc/cloud/csi-vsphere.conf"
	// EnvCloudConfig contains the path to the CSI vSphere Config
	EnvCloudConfig = "VSPHERE_CSI_CONFIG"
)

Variables

View Source
var (
	// ErrUsernameMissing is returned when the provided username is empty.
	ErrUsernameMissing = errors.New("Username is missing")

	// ErrPasswordMissing is returned when the provided password is empty.
	ErrPasswordMissing = errors.New("Password is missing")

	// ErrInvalidVCenterIP is returned when the provided vCenter IP address is
	// missing from the provided configuration.
	ErrInvalidVCenterIP = errors.New("vsphere.conf does not have the VirtualCenter IP address specified")

	// ErrMissingVCenter is returned when the provided configuration does not
	// define any vCenters.
	ErrMissingVCenter = errors.New("No Virtual Center hosts defined")
)

Errors

Functions

func FromEnv

func FromEnv(cfg *Config) error

FromEnv initializes the provided configuratoin object with values obtained from environment variables. If an environment variable is set for a property that's already initialized, the environment variable's value takes precedence.

Types

type Config

type Config struct {
	Global struct {
		//vCenter IP address or FQDN
		VCenterIP string
		// Kubernetes Cluster ID
		ClusterID string `gcfg:"cluster-id"`
		// vCenter username.
		User string `gcfg:"user"`
		// vCenter password in clear text.
		Password string `gcfg:"password"`
		// vCenter port.
		VCenterPort string `gcfg:"port"`
		// Specifies whether to verify the server's certificate chain. Set to true to
		// skip verification.
		InsecureFlag bool `gcfg:"insecure-flag"`
		// Specifies the path to a CA certificate in PEM format. This has no effect if
		// InsecureFlag is enabled. Optional; if not configured, the system's CA
		// certificates will be used.
		CAFile string `gcfg:"ca-file"`
		// Datacenter in which Node VMs are located.
		Datacenters string `gcfg:"datacenters"`
	}

	// Virtual Center configurations
	VirtualCenter map[string]*VirtualCenterConfig

	// Tag categories and tags which correspond to "built-in node labels: zones and region"
	Labels struct {
		Zone   string `gcfg:"zone"`
		Region string `gcfg:"region"`
	}
}

Config is used to read and store information from the cloud configuration file

func FromEnvOrSim

func FromEnvOrSim() (*Config, func())

FromEnvOrSim return a vsphere config from either environment variables or simulates them

func GetCnsconfig

func GetCnsconfig(cfgPath string) (*Config, error)

GetCnsconfig returns Config from specified config file path

func ReadConfig

func ReadConfig(config io.Reader) (*Config, error)

ReadConfig parses vSphere cloud config file and stores it into VSphereConfig. Environment variables are also checked

type VirtualCenterConfig

type VirtualCenterConfig struct {
	// vCenter username.
	User string `gcfg:"user"`
	// vCenter password in clear text.
	Password string `gcfg:"password"`
	// vCenter port.
	VCenterPort string `gcfg:"port"`
	// True if vCenter uses self-signed cert.
	InsecureFlag bool `gcfg:"insecure-flag"`
	// Datacenter in which VMs are located.
	Datacenters string `gcfg:"datacenters"`
}

VirtualCenterConfig contains information used to access a remote vCenter endpoint.

Jump to

Keyboard shortcuts

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