config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureViper

func ConfigureViper(contextOverride string) error

ConfigureViper sets up Viper to behave correctly with regards to both context and configuration directory, taking into account all environment variables and parameters. Order of precedence is: override, environment variables, defaults

func DeleteClusterConfiguration

func DeleteClusterConfiguration(configDir, clusterName string) error

DeleteClusterConfiguration deletes a cluster configuration in the config directory. It will return an error if the cluster does not exist. The operation cannot be reverted

func DeleteContextConfiguration

func DeleteContextConfiguration(configDir, contextName string) error

DeleteContextConfiguration deletes a context configuration in the config directory. It will return an error if the context does not exist. The operation cannot be reverted

func GetConfigDir

func GetConfigDir() string

GetConfigDir returns the Config Dir based on the current status

func GetDefaultConfigDir

func GetDefaultConfigDir() string

GetDefaultConfigDir returns the default config directory

func ListClusterConfigurations

func ListClusterConfigurations(configDir string) ([]string, error)

ListClusterConfigurations returns a list of available cluster configurations

func ListContextConfigurations

func ListContextConfigurations(configDir string) ([]string, error)

ListContextConfigurations returns a list of available context configurations

func LoadBundleToDirectory

func LoadBundleToDirectory(bundle Bundle, configDir string, clusters, contexts []string, overwrite bool) error

LoadBundleToDirectory loads a bundle into a config directory, overwriting matching files, overwriting any overlapping entry. When failing, it might have partially loaded some of the entries in the file. Clusters and Contexts, when specified, are a list of clusters and contexts to load. An empty list means "all"

func SaveBaseConfiguration

func SaveBaseConfiguration(configDir string, configuration BaseConfigFile) error

SaveBaseConfiguration saves the base configuration in a config directory

func SaveClusterConfiguration

func SaveClusterConfiguration(configDir, clusterName string, configuration ClusterFile, overwrite bool) error

SaveClusterConfiguration saves a cluster configuration in the config directory

func SaveContextConfiguration

func SaveContextConfiguration(configDir, contextName string, configuration ContextFile, overwrite bool) error

SaveContextConfiguration saves a context configuration in the config directory

Types

type BaseConfigFile

type BaseConfigFile struct {
	// CurrentContext represents the context which should be used when no context is explicitly specified
	CurrentContext string `yaml:"context" json:"context"`
}

BaseConfigFile represents a base configuration for astartectl

func LoadBaseConfiguration

func LoadBaseConfiguration(configDir string) (BaseConfigFile, error)

LoadBaseConfiguration loads the base configuration from a config directory

type Bundle

type Bundle struct {
	// BaseConfig is the base config for astartectl
	BaseConfig BaseConfigFile `yaml:"config" json:"config"`
	// Clusters is the list of available clusters
	Clusters map[string]ClusterFile `yaml:"clusters" json:"clusters"`
	// Contexts is the list of available contexts
	Contexts map[string]ContextFile `yaml:"contexts" json:"contexts"`
}

Bundle represents a bundle encapsulating all configuration files

func CreateBundleFromDirectory

func CreateBundleFromDirectory(configDir string, clusters, contexts []string) (Bundle, error)

CreateBundleFromDirectory returns a bundle out of a config directory Clusters and Contexts, when specified, are a list of clusters and contexts to save. An empty list means "all"

type ClusterFile

type ClusterFile struct {
	// URL is the base API URL for the Cluster. Can be omitted when specifying individual URLs
	URL string `yaml:"url,omitempty" json:"url,omitempty"`
	// Housekeeping is the Cluster's Housekeeping configuration. Can be omitted if there is no such information
	Housekeeping HousekeepingConfiguration `yaml:"housekeeping,omitempty" json:"housekeeping,omitempty"`
	// IndividualURLs are the Cluster's individual API URLs. Should usually be omitted, and URL should
	// be used instead, but in case of exotic API server setups they are required. When specified, they
	// take precedence over URL
	IndividualURLs IndividualURLsConfiguration `yaml:"individual-urls,omitempty" json:"individual-urls,omitempty"`
}

ClusterFile represents a Cluster file

func LoadClusterConfiguration

func LoadClusterConfiguration(configDir, clusterName string) (ClusterFile, error)

LoadClusterConfiguration loads a cluster configuration from the config directory

type ContextFile

type ContextFile struct {
	// Cluster is the name of the cluster. It has to match an existing Cluster configuration
	Cluster string `yaml:"cluster" json:"cluster"`
	// Realm is the realm object. In case the Context refers to Housekeeping only, can be omitted
	Realm RealmConfiguration `yaml:"realm,omitempty" json:"realm,omitempty"`
}

ContextFile represents a Context file

func LoadContextConfiguration

func LoadContextConfiguration(configDir, contextName string) (ContextFile, error)

LoadContextConfiguration loads a context configuration from the config directory

type HousekeepingConfiguration

type HousekeepingConfiguration struct {
	// Key is the private key of the realm, encoded in base64
	Key string `yaml:"key,omitempty" json:"key,omitempty"`
	// Token is a token used to authenticate against the realm. When set, it takes precedence over key
	Token string `yaml:"token,omitempty" json:"token,omitempty"`
}

HousekeepingConfiguration represents configuration for housekeeping

type IndividualURLsConfiguration

type IndividualURLsConfiguration struct {
	// AppEngine is AppEngine API URL
	AppEngine string `yaml:"appengine,omitempty" json:"appengine,omitempty"`
	// Flow is Flow API URL
	Flow string `yaml:"flow,omitempty" json:"flow,omitempty"`
	// Housekeeping is Housekeeping API URL
	Housekeeping string `yaml:"housekeeping,omitempty" json:"housekeeping,omitempty"`
	// Pairing is Pairing API URL
	Pairing string `yaml:"pairing,omitempty" json:"pairing,omitempty"`
	// RealmManagement is Realm Management API URL
	RealmManagement string `yaml:"realm-management,omitempty" json:"realm-management,omitempty"`
}

IndividualURLsConfiguration represents configuration for Individual URLs. When present, URL is overridden and not used.

type RealmConfiguration

type RealmConfiguration struct {
	// Name is the name of the realm
	Name string `yaml:"name" json:"name"`
	// Key is the private key of the realm, encoded in base64. Can be omitted
	Key string `yaml:"key,omitempty" json:"key,omitempty"`
	// Token is a token used to authenticate against the realm. When set, it takes precedence over key
	Token string `yaml:"token,omitempty" json:"token,omitempty"`
}

RealmConfiguration represents configuration for a Realm

Jump to

Keyboard shortcuts

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