config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// DefaultRoundTripperCount is the number of allowed round trips
	// before an error is returned.
	DefaultRoundTripperCount uint = 3

	// DefaultAPIBinding is the default ADDRESS:PORT binding used for
	// exposing the API service.
	DefaultAPIBinding string = ":43001"

	// DefaultK8sServiceAccount is the default name of the Kubernetes
	// service account.
	DefaultK8sServiceAccount string = "cloud-controller-manager"

	// DefaultVCenterPort is the default port used to access vCenter.
	DefaultVCenterPort string = "443"

	// DefaultSecretDirectory is the default path to the secrets directory.
	DefaultSecretDirectory string = "/etc/cloud/secrets"

	// IPv6Family string representation for IPv6
	IPv6Family = "ipv6"
	// IPv4Family string representation for IPv4
	IPv4Family = "ipv4"

	// DefaultIPFamily is the default IP addressing to use for networking
	DefaultIPFamily = IPv4Family
)

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")

	// ErrInvalidIPFamilyType is returned when an invalid IPFamily type is encountered
	ErrInvalidIPFamilyType = errors.New("Invalid IP Family type")
)

Errors

Functions

func FromEnv added in v0.2.0

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 username.
		User string `gcfg:"user"`
		// vCenter password in clear text.
		Password string `gcfg:"password"`
		// Deprecated. Use VirtualCenter to specify multiple vCenter Servers.
		// vCenter IP.
		VCenterIP string `gcfg:"server"`
		// 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"`
		// Soap round tripper count (retries = RoundTripper - 1)
		RoundTripperCount uint `gcfg:"soap-roundtrip-count"`
		// Specifies the path to a CA certificate in PEM format. Optional; if not
		// configured, the system's CA certificates will be used.
		CAFile string `gcfg:"ca-file"`
		// Thumbprint of the VCenter's certificate thumbprint
		Thumbprint string `gcfg:"thumbprint"`
		// Name of the secret were vCenter credentials are present.
		SecretName string `gcfg:"secret-name"`
		// Secret Namespace where secret will be present that has vCenter credentials.
		SecretNamespace string `gcfg:"secret-namespace"`
		// The kubernetes service account used to launch the cloud controller manager.
		// Default: cloud-controller-manager
		ServiceAccount string `gcfg:"service-account"`
		// Secret directory in the event that:
		// 1) we don't want to use the k8s API to listen for changes to secrets
		// 2) we are not in a k8s env, namely DC/OS, since CSI is CO agnostic
		// Default: /etc/cloud/credentials
		SecretsDirectory string `gcfg:"secrets-directory"`
		// Disable the vSphere CCM API
		// Default: true
		APIDisable bool `gcfg:"api-disable"`
		// Configurable vSphere CCM API port
		// Default: 43001
		APIBinding string `gcfg:"api-binding"`
		// IP Family enables the ability to support IPv4 or IPv6
		// Supported values are:
		// ipv4 - IPv4 addresses only (Default)
		// ipv6 - IPv6 addresses only
		IPFamily string `gcfg:"ip-family"`
	}

	// 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 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"`
	// Soap round tripper count (retries = RoundTripper - 1)
	RoundTripperCount uint `gcfg:"soap-roundtrip-count"`
	// Specifies the path to a CA certificate in PEM format. Optional; if not
	// configured, the system's CA certificates will be used.
	CAFile string `gcfg:"ca-file"`
	// Thumbprint of the VCenter's certificate thumbprint
	Thumbprint string `gcfg:"thumbprint"`
	// IP Family enables the ability to support IPv4 or IPv6
	// Supported values are:
	// ipv4 - IPv4 addresses only (Default)
	// ipv6 - IPv6 addresses only
	IPFamily string `gcfg:"ip-family"`
	// IPFamilyPriority the list/priority of IP versions
	IPFamilyPriority []string
}

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