tkgconfigupdater

package
v0.0.0-...-b25b198 Latest Latest
Warning

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

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

Documentation

Overview

Package tkgconfigupdater provides utilities to update tkg configs

Index

Constants

This section is empty.

Variables

DefaultConfigMap default configuration map

KeysToEncode all keys to encode

KeysToNeverPersist are all keys that should never be persisted NOTE: AWS users should persist credentials by creating named profiles using AWS CLI: aws configure --profile <name>, and then use the AWS_PROFILE variable. Temporary static credentials last at most 12 hours, and AWS red-flags partner products that save static credentials, so we do not save them. This is different than vSphere and Azure where static credentials are the norm.

Functions

func CreateConfigMap

func CreateConfigMap(configObj interface{}) (map[string]string, error)

CreateConfigMap transforms a configuration object into a map

func GetNodeIndex

func GetNodeIndex(node []*yaml.Node, key string) int

GetNodeIndex returns index of the node

func SaveConfig

func SaveConfig(clusterConfigPath string, tkgConfigReaderWriter tkgconfigreaderwriter.TKGConfigReaderWriter, configObj interface{}) error

SaveConfig saves configuration to ReaderWriter and/or to File allows clusterConfigPath to be empty, in which case no file is written allows TKGConfigReaderWriter to be empty, in which case no update is made to that writer (allows both to be empty, in which case the method does nothing)

func SetConfig

func SetConfig(data map[string]string, clusterConfigPath string) error

SetConfig saves map of key-value pairs to config file (creating if nec)

Types

type Client

type Client interface {
	// EnsureTKGConfigFile ensures creating settings file
	EnsureTKGConfigFile() (string, error)
	// EnsureConfigImages ensures that `images:“ config exists and is up-to-date in tkg settings file
	// images:
	//   all:
	//      repository: projects-stg.registry.vmware.com/tkg/cluster-api
	//   cert-manager:
	//      repository: projects-stg.registry.vmware.com/tkg
	//      tag: v0.16.1_vmware.1
	EnsureConfigImages() error

	// DecodeCredentialsInViper decode the credentials stored in viper
	DecodeCredentialsInViper() error

	CheckInfrastructureVersion(providerName string) (string, error)

	GetDefaultInfrastructureVersion(providerName string) (string, error)

	EnsureProviderTemplates() error

	SetDefaultConfiguration()

	// CheckProviderTemplatesNeedUpdate checks if .tkg/providers is up-to-date.
	CheckProviderTemplatesNeedUpdate() (bool, error)
	// CheckBOMsNeedUpdate checks if bom files are up-to-date.
	// returns true if $HOME/.tkg/bom directory exists, not empty and doesn't contain the defaultBoM file
	CheckBOMsNeedUpdate() (bool, error)
	// EnsureBOMFiles ensures the local BOM files. If forceUpdate option is set, TKG compatibility file would fetched
	// from the registry and would update BOM files if the latest TKG compatibility file version points to new BOM files
	EnsureBOMFiles(forceUpdate bool) error
	// EnsureTKGCompatibilityFile ensures the TKG compatibility file. If forceUpdate option is set,TKG compatibility would fetched
	// TKG compatibility file would fetched from the registry though local copy exists
	EnsureTKGCompatibilityFile(forceUpdate bool) error

	// EnsureCredEncoding ensures the credentials encoding
	EnsureCredEncoding(tkgConfigNode *yaml.Node)
	EnsureImages(needUpdate bool, tkgConfigNode *yaml.Node) error
	// EnsureProvidersInConfig ensures the providers section in tkgconfig exisits and it is synchronized with the latest providers
	EnsureProvidersInConfig(needUpdate bool, tkgConfigNode *yaml.Node) error
	// EnsureTemplateFiles ensures that $HOME/.tkg/providers exists and it is up-to-date
	EnsureTemplateFiles() (bool, error)
	// GetProvidersChecksum calculates and returns the checksum calculated from all the template yaml files in the providers directory
	GetProvidersChecksum() (string, error)
	// GetPopulatedProvidersChecksumFromFile reads and returns the checksum from providers.sha256sum file in the providers directory
	GetPopulatedProvidersChecksumFromFile() (string, error)
}

Client implements TKG configuration updater functions

func New

func New(configDir string, providerGetter providerinterface.ProviderInterface,
	tkgConfigReaderWriter tkgconfigreaderwriter.TKGConfigReaderWriter) Client

New creates new tkgconfig updater client

Jump to

Keyboard shortcuts

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