config

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config provides utility functions for managing the validator config.

Index

Constants

View Source
const (
	ConfigFile   = "validatorctl.yaml"
	TimeFormat   = "20060102150405"
	WorkspaceLoc = ".validator"

	ClusterConfigTemplate = "cluster-configuration.tmpl"
	KindImage             = "kindest/node"
	KindImageTag          = "v1.30.2"
	NoProxyPrompt         = "" /* 214-byte string literal not displayed */

	LocalFilepath = "Local Filepath"
	FileEditor    = "File Editor"

	// Validator constants
	ValidatorConfigFile      = "validator.yaml"
	ValidatorKindClusterName = "validator-kind-cluster"
	ValidatorHelmRegistry    = "https://validator-labs.github.io"
	ValidatorImageRegistry   = "quay.io"
	ValidatorImageRepository = "validator-labs"
	ValidatorHelmReleaseName = "validator-helm-release"

	ValidatorPluginAws     = "validator-plugin-aws"
	ValidatorPluginAzure   = "validator-plugin-azure"
	ValidatorPluginMaas    = "validator-plugin-maas"
	ValidatorPluginNetwork = "validator-plugin-network"
	ValidatorPluginOci     = "validator-plugin-oci"
	ValidatorPluginVsphere = "validator-plugin-vsphere"

	ValidatorPluginAwsKind     = "AwsValidator"
	ValidatorPluginAzureKind   = "AzureValidator"
	ValidatorPluginMaasKind    = "MaasValidator"
	ValidatorPluginNetworkKind = "NetworkValidator"
	ValidatorPluginOciKind     = "OciValidator"
	ValidatorPluginVsphereKind = "VsphereValidator"

	ValidatorPluginAwsTemplate     = "validator-rules-aws.tmpl"
	ValidatorPluginAzureTemplate   = "validator-rules-azure.tmpl"
	ValidatorPluginMaasTemplate    = "validator-rules-maas.tmpl"
	ValidatorPluginNetworkTemplate = "validator-rules-network.tmpl"
	ValidatorPluginOciTemplate     = "validator-rules-oci.tmpl"
	ValidatorPluginVsphereTemplate = "validator-rules-vsphere.tmpl"

	ValidatorVsphereVersionConstraint = ">= 6.0, < 9.0"
	ValidatorVspherePrivilegeFile     = "vsphere-privileges-7.x.yaml"

	AWSPolicyDocumentPrompt   = "" /* 147-byte string literal not displayed */
	AzurePermissionSetPrompt  = "" /* 148-byte string literal not displayed */
	AzureResourceSetPrompt    = "" /* 145-byte string literal not displayed */
	VcenterPrivilegePrompt    = "" /* 214-byte string literal not displayed */
	OciCreateNewAuthSecPrompt = "Create a new registry authentication secret"
	OciCreateNewSigSecPrompt  = "Create a new signature verification secret"

	// Embed dirs
	Kind      string = "kind"
	Validator string = "validator"

	// Regex
	DomainRegex          = "" /* 241-byte string literal not displayed */
	UsernameRegex        = "[a-zA-Z0-9]+(?:\\.[a-zA-Z0-9]+)*(?:-[a-zA-Z0-9]+)*(?:_[a-zA-Z0-9]+)*"
	VSphereUsernameRegex = "^" + UsernameRegex + "@" + DomainRegex + "$"
	CPUReqRegex          = "(^\\d+\\.?\\d*[M,G]Hz)"
	MemoryReqRegex       = "(^\\d+\\.?\\d*[M,G,T]i)"
	DiskReqRegex         = "(^\\d+\\.?\\d*[M,G,T]i)"
	PolicyArnRegex       = "^arn:aws:iam::.*:policy/.*$"

	// Env vars
	AwsAccessKey       = "AWS_ACCESS_KEY_ID"     // #nosec
	AwsSecretAccessKey = "AWS_SECRET_ACCESS_KEY" // #nosec
	AwsSessionToken    = "AWS_SESSION_TOKEN"     // #nosec
)

Variables

View Source
var (
	// Misc.
	DefaultPodCIDR          = "192.168.0.0/16"
	DefaultServiceIPRange   = "10.96.0.0/12"
	HTTPSchemes             = []string{"https://", "http://"}
	RegistryMirrors         = []string{"docker.io", "gcr.io", "ghcr.io", "k8s.gcr.io", "registry.k8s.io", "quay.io", "*"}
	RegistryMirrorSeparator = "::"
	FileInputs              = []string{LocalFilepath, FileEditor}
	DNSRecordTypes          = []string{"A", "AAAA", "CNAME", "TXT", "MX", "NS", "SRV", "SSHFP"}

	// Command dirs
	ValidatorSubdirs = []string{"logs", "manifests"}

	// Validator
	ValidatorImagePath = func() string {
		return ValidatorImageRegistry + "/" + ValidatorImageRepository
	}
	ValidatorWaitCmd       = []string{"wait", "--for=condition=available", "--timeout=600s", "deployment/validator-controller-manager", "-n", "validator"}
	ValidatorBasicAuthKeys = []string{"username", "password"}
	ValidatorSinkKeys      = map[vtypes.SinkType][]string{
		vtypes.SinkTypeAlertmanager: {"endpoint", "insecureSkipVerify", "username", "password", "caCert"},
		vtypes.SinkTypeSlack:        {"apiToken", "channelID"},
	}
	ValidatorPluginAwsKeys                     = []string{"AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"}
	ValidatorPluginAzureKeys                   = []string{"AZURE_TENANT_ID", "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET"}
	ValidatorPluginVsphereKeys                 = []string{"username", "password", "vcenterServer", "insecureSkipVerify"}
	ValidatorPluginOciSigVerificationKeysRegex = ".pub$"

	ValidatorPluginAwsServiceQuotas = []prompts.ChoiceItem{
		{
			ID:   "ec2",
			Name: "EC2-VPC Elastic IPs",
		},
		{
			ID:   "ec2",
			Name: "Public AMIs",
		},
		{
			ID:   "elasticfilesystem",
			Name: "File systems per account",
		},
		{
			ID:   "elasticloadbalancing",
			Name: "Application Load Balancers per Region",
		},
		{
			ID:   "elasticloadbalancing",
			Name: "Classic Load Balancers per Region",
		},
		{
			ID:   "elasticloadbalancing",
			Name: "Network Load Balancers per Region",
		},
		{
			ID:   "vpc",
			Name: "Internet gateways per Region",
		},
		{
			ID:   "vpc",
			Name: "Network interfaces per Region",
		},
		{
			ID:   "vpc",
			Name: "VPCs per Region",
		},
		{
			ID:   "vpc",
			Name: "Subnets per VPC",
		},
		{
			ID:   "vpc",
			Name: "NAT gateways per Availability Zone",
		},
	}

	ValidatorAzureClouds = []string{
		"AzureCloud",
		"AzureUSGovernment",
		"AzureChinaCloud",
	}
)
View Source
var ValidatorChartVersions = map[string]string{
	Validator:              "v0.1.13",
	ValidatorPluginAws:     "v0.1.10",
	ValidatorPluginAzure:   "v0.0.24",
	ValidatorPluginMaas:    "v0.0.12",
	ValidatorPluginNetwork: "v0.1.0",
	ValidatorPluginOci:     "v0.3.3",
	ValidatorPluginVsphere: "v0.1.4",
}

ValidatorChartVersions is a map of validator component names to their respective versions

Functions

func DefaultWorkspaceLoc

func DefaultWorkspaceLoc() (string, error)

DefaultWorkspaceLoc returns the default workspace location.

Types

type Config

type Config struct {
	RunLoc       string `yaml:"runLoc"`
	WorkspaceLoc string `yaml:"workspaceLoc"`
}

Config represents the validator config.

func NewConfig

func NewConfig() *Config

NewConfig creates a new Config object.

func (*Config) CreateWorkspace

func (c *Config) CreateWorkspace(folder string, subdirs []string, timestamped bool) error

CreateWorkspace creates a new workspace with the specified folder and subdirs.

func (*Config) Decrypt

func (c *Config) Decrypt() error

Decrypt decrypts the config.

func (*Config) Encrypt

func (c *Config) Encrypt() error

Encrypt encrypts the config.

func (*Config) Load

func (c *Config) Load() error

Load loads the decrypted config file.

func (*Config) Save

func (c *Config) Save(path string) error

Save saves the config to the specified path.

type TaskConfig

type TaskConfig struct {
	CliVersion       string
	ConfigFile       string
	CustomResources  string
	Apply            bool
	CreateConfigOnly bool
	DeleteCluster    bool
	Direct           bool
	Reconfigure      bool
	UpdatePasswords  bool
	Wait             bool
}

TaskConfig represents the validator task config. CLI flags are bound to this struct.

Directories

Path Synopsis
Package manager provides functions manage the validator config
Package manager provides functions manage the validator config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳