tools

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tools implements the API to other tools like Helmfile, or Smallstep's 'step' CLI Initially I wanted to compile in the direct sources from their respective Go modules

However, Bazel struggles with compilation of the dependencies, mainly due to issues with the new 'bzlmod' dependency system

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSecretStepValues

func AddSecretStepValues(values *StepHelmValues, password, path string) (map[string]interface{}, error)

AddSecretStepValues adds the newly generated StepValues to the secret encrypted environment values managed via Helmfile

func AddSecretValue

func AddSecretValue(path string, data map[string]interface{}, unencrypted bool) (map[string]interface{}, error)

AddSecretValue initializes a data map to an existing data object

func DecryptFile

func DecryptFile(path string) error

DecryptFile decrypts a file using the Helm Secrets Plugin

func EncryptFile

func EncryptFile(path string) error

EncryptFile encrypts a file using the Helm Secrets Plugin

func Find

func Find() (map[Executable]string, error)

Find checks the system for the required executables. It returns the first error that occurs during the search, thereby setting the map return value to nil.

func GetSecretValue

func GetSecretValue(path, jsonPath string, unencrypted bool) (string, error)

GetSecretValue parses the file at the provided path, first checking whether it actually exists. If it does we check if it's encrypted and decrypt it if required. Afterwards the YAML file contents are read an returned via a JSONPath

func HelmPluginInstall

func HelmPluginInstall(p HelmPlugin, version string) error

func HelmPluginInstall installs a Helm Plugin from it's remote source

func HelmPluginRequiresUpdate

func HelmPluginRequiresUpdate(token string, plugins ...HelmPlugin) (map[HelmPlugin]bool, error)

HelmPluginRequiresUpdate determines if an update to a plugin is required

func HelmPluginUninstall

func HelmPluginUninstall(p HelmPlugin) error

func HelmPluginUninstall uninstalls a Helm Plugin

func HelmPluginVersion

func HelmPluginVersion(plugins ...HelmPlugin) (map[HelmPlugin]string, error)

HelmPluginVersion retrieves the versions for all or some of the required Helm Plugins

func ValidateHelmPlugins

func ValidateHelmPlugins(plugins ...HelmPlugin) error

ValidateHelmPlugins checks if the required Helm Plugins "diff" and "secrets" are currently installed

func WithAddress

func WithAddress(address string) func(cfg *StepValuesConfig)

func WithDeploymentType

func WithDeploymentType(deploymentType string) func(cfg *StepValuesConfig)

func WithHostname

func WithHostname(hostname string) func(cfg *StepValuesConfig)

func WithName

func WithName(name string) func(cfg *StepValuesConfig)

func WithProvisioner

func WithProvisioner(provisioner string) func(cfg *StepValuesConfig)

Types

type Executable

type Executable int

Executables represents and executables that either a Tool or another required programs depends on

func (Executable) Index

func (e Executable) Index() int

Index makes the current Executable index retrievable

func (Executable) String

func (e Executable) String() string

String implements the fmt.Stringer interface for the new Executable type

type FileState

type FileState int

func GetFileState

func GetFileState(path string) (FileState, error)

GetFileState checks the contents of a file for existing SOPS encryption and returns the current state of the file

func (FileState) String

func (f FileState) String() string

String implements the fmt.Stringer interface for the FileState type

type HelmPlugin

type HelmPlugin int

HelmPlugin represents a Helm plugin required for gopskit to work

func (HelmPlugin) Index

func (p HelmPlugin) Index() int

Index makes the current HelmPlugin index

func (HelmPlugin) String

func (p HelmPlugin) String() string

String implements the fmt.Stringer interface for the new HelmPlugin type

type SOPSContent

type SOPSContent struct {
	SOPS SOPSValues `json:"sops" yaml:"sops"`
}

A SOPS-encrypted file always has a 'sops' keys if it's currently encrypted

type SOPSValues

type SOPSValues struct {
	KMS               []yaml.Node `json:"kms" yaml:"kms"`
	GCP_KMS           []yaml.Node `json:"gcp_kms" yaml:"gcp_kms"`
	AZURE_KV          []yaml.Node `json:"azure_kv" yaml:"azure_kv"`
	HC_VAULT          []yaml.Node `json:"hc_vault" yaml:"hc_vault"`
	AGE               []yaml.Node `json:"age" yaml:"age"`
	LastModified      string      `json:"lastmodified" yaml:"lastmodified"`
	Mac               string      `json:"mac" yaml:"mac"`
	PGP               []yaml.Node `json:"pgp" yaml:"pgp"`
	UnencryptedSuffix string      `json:"unencrypted_suffix" yaml:"unencrypted_suffix"`
	Version           string      `json:"version" yaml:"version"`
}

type StepHelmValues

type StepHelmValues struct {
	Inject struct {
		Enabled bool `yaml:"enabled"`
		Config  struct {
			Files struct {
				CaJSON struct {
					Root          string        `yaml:"root"`
					FederateRoots []interface{} `yaml:"federateRoots"`
					Crt           string        `yaml:"crt"`
					Key           string        `yaml:"key"`
					Address       string        `yaml:"address"`
					DNSNames      []string      `yaml:"dnsNames"`
					Logger        struct {
						Format string `yaml:"format"`
					} `yaml:"logger"`
					Db struct {
						Type       string `yaml:"type"`
						DataSource string `yaml:"dataSource"`
					} `yaml:"db"`
					Authority struct {
						EnableAdmin  bool `yaml:"enableAdmin"`
						Provisioners []struct {
							Type string `yaml:"type"`
							Name string `yaml:"name"`
							Key  struct {
								Use string `yaml:"use"`
								Kty string `yaml:"kty"`
								Kid string `yaml:"kid"`
								Crv string `yaml:"crv"`
								Alg string `yaml:"alg"`
								X   string `yaml:"x"`
								Y   string `yaml:"y"`
							} `yaml:"key"`
							EncryptedKey string `yaml:"encryptedKey"`
							Options      struct {
								X509 struct {
								} `yaml:"x509"`
								SSH struct {
								} `yaml:"ssh"`
							} `yaml:"options"`
						} `yaml:"provisioners"`
					} `yaml:"authority"`
					TLS struct {
						CipherSuites  []string `yaml:"cipherSuites"`
						MinVersion    float64  `yaml:"minVersion"`
						MaxVersion    float64  `yaml:"maxVersion"`
						Renegotiation bool     `yaml:"renegotiation"`
					} `yaml:"tls"`
				} `yaml:"ca.json"`
				DefaultsJSON struct {
					CaURL       string `yaml:"ca-url"`
					CaConfig    string `yaml:"ca-config"`
					Fingerprint string `yaml:"fingerprint"`
					Root        string `yaml:"root"`
				} `yaml:"defaults.json"`
			} `yaml:"files"`
		} `yaml:"config"`
		Certificates struct {
			IntermediateCa string `yaml:"intermediate_ca"`
			RootCa         string `yaml:"root_ca"`
		} `yaml:"certificates"`
		Secrets struct {
			CaPassword          interface{} `yaml:"ca_password"`
			ProvisionerPassword interface{} `yaml:"provisioner_password"`
			X509                struct {
				IntermediateCaKey string `yaml:"intermediate_ca_key"`
				RootCaKey         string `yaml:"root_ca_key"`
			} `yaml:"x509"`
		} `yaml:"secrets"`
	} `yaml:"inject"`
}

StepHelmValues is the Go struct representation of the Smallstep (CLI)'s YAML template for Helm. See `smallstep/cli` on GitHub for more information.

func GenerateStepValues

func GenerateStepValues(opts ...StepValuesOpt) (*StepHelmValues, error)

type StepValuesConfig

type StepValuesConfig struct {
	Name           string
	Hostname       string
	Address        string
	Provisioner    string
	DeploymentType string
}

type StepValuesOpt

type StepValuesOpt func(cfg *StepValuesConfig)

Jump to

Keyboard shortcuts

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