app

package
v3.17.4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package app contains the main logic for the application.

Index

Constants

This section is empty.

Variables

View Source
var (
	True  = NullBool{HasValue: true, Value: true}
	False = NullBool{HasValue: true, Value: false}
)

truthy and falsy NullBool values

Functions

func Indent

func Indent(s, prefix string) string

Indent inserts prefix at the beginning of each non-empty line of s. The end-of-line marker is NL.

func Main

func Main() int

Main is the app main function

func NullBoolTransformer

func NullBoolTransformer(typ reflect.Type) func(dst, src reflect.Value) error

NullBoolTransformer is a custom imdario/mergo transformer for the NullBool type

func ToolExists

func ToolExists(tool string) bool

ToolExists returns true if the tool is present in the environment and false otherwise. It takes as input the tool's command to check if it is recognizable or not. e.g. helm or kubectl

Types

type ChartInfo

type ChartInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

type CmdPipe

type CmdPipe []Command

CmdPipe is a os/exec.Commnad wrapper for UNIX pipe

func (CmdPipe) Exec

func (p CmdPipe) Exec() (ExitStatus, error)

Exec pipes the executable commands and returns the exit code and execution result

func (CmdPipe) RetryExec

func (p CmdPipe) RetryExec(attempts int) (ExitStatus, error)

RetryExec runs piped commands with retry

func (CmdPipe) RetryExecWithThreshold

func (p CmdPipe) RetryExecWithThreshold(attempts, exitCodeThreshold int) (ExitStatus, error)

RetryExecWithThreshold runs piped commands with retry and allows specifying the threshold for the exit code to be considered erroneous

type Command

type Command struct {
	Cmd         string
	Args        []string
	Description string
}

Command type representing all executable commands Helmsman needs to execute in order to inspect the environment|releases|charts etc.

func (*Command) Exec

func (c *Command) Exec() (ExitStatus, error)

Exec executes the executable command and returns the exit code and execution result

func (*Command) RetryExec

func (c *Command) RetryExec(attempts int) (ExitStatus, error)

RetryExec runs exec command with retry

func (*Command) RetryExecWithThreshold

func (c *Command) RetryExecWithThreshold(attempts, exitCodeThreshold int) (ExitStatus, error)

RetryExecWithThreshold runs exec command with retry and allows specifying the threshold for the exit code to be considered erroneous

func (*Command) String

func (c *Command) String() string

type Config

type Config struct {
	// KubeContext is the kube context you want Helmsman to use or create
	KubeContext string `json:"kubeContext,omitempty"`
	// Username to be used for kubectl credentials
	Username string `json:"username,omitempty"`
	// Password to be used for kubectl credentials
	Password string `json:"password,omitempty"`
	// ClusterURI is the URI for your cluster API or the name of an environment variable (starting with `$`) containing the URI
	ClusterURI string `json:"clusterURI,omitempty"`
	// ServiceAccount to be used for tiller (deprecated)
	ServiceAccount string `json:"serviceAccount,omitempty"`
	// StorageBackend indicates the storage backened used by helm, defaults to secret
	StorageBackend string `json:"storageBackend,omitempty"`
	// SlackWebhook is the slack webhook URL for slack notifications
	SlackWebhook string `json:"slackWebhook,omitempty"`
	// MSTeamsWebhook is the Microsoft teams webhook URL for teams notifications
	MSTeamsWebhook string `json:"msTeamsWebhook,omitempty"`
	// ReverseDelete indicates if the applications should be deleted in reverse orderin relation to the installation order
	ReverseDelete bool `json:"reverseDelete,omitempty"`
	// BearerToken indicates whether you want helmsman to connect to the cluster using a bearer token
	BearerToken bool `json:"bearerToken,omitempty"`
	// BearerTokenPath allows specifying a custom path for the token
	BearerTokenPath string `json:"bearerTokenPath,omitempty"`
	// NamespaceLabelsAuthoritativei indicates whether helmsman should remove namespace labels that are not in the DSF
	NamespaceLabelsAuthoritative bool `json:"namespaceLabelsAuthoritative,omitempty"`
	// VaultEnabled indicates whether the helm vault plugin is used for encrypted files
	VaultEnabled bool `json:"vaultEnabled,omitempty"`
	// VaultDeliminator allows secret deliminator used when parsing to be overridden
	VaultDeliminator string `json:"vaultDeliminator,omitempty"`
	// VaultPath allows the secret mount location in Vault to be overridden
	VaultPath string `json:"vaultPath,omitempty"`
	// VaultMountPoint allows the Vault Mount Point to be overridden
	VaultMountPoint string `json:"vaultMountPoint,omitempty"`
	// VaultTemplate Substring with path to vault key instead of deliminator
	VaultTemplate string `json:"vaultTemplate,omitempty"`
	// VaultKvVersion The version of the KV secrets engine in Vault
	VaultKvVersion string `json:"vaultKvVersion,omitempty"`
	// VaultEnvironment Environment that secrets should be stored under
	VaultEnvironment string `json:"vaultEnvironment,omitempty"`
	// EyamlEnabled indicates whether eyaml is used for encrypted files
	EyamlEnabled bool `json:"eyamlEnabled,omitempty"`
	// EyamlPrivateKeyPath is the path to the eyaml private key
	EyamlPrivateKeyPath string `json:"eyamlPrivateKeyPath,omitempty"`
	// EyamlPublicKeyPath is the path to the eyaml public key
	EyamlPublicKeyPath string `json:"eyamlPublicKeyPath,omitempty"`
	// EyamlGkms indicates whether to use GKMS for eyaml
	EyamlGkms bool `json:"eyamlGkms,omitepty"`
	// EyamlGkmsProject is the GCP project where GKMS keys are stored
	EyamlGkmsProject string `json:"eyamlGkmsProject,omitempty"`
	// EyamlGkmsLocation is the KMS location
	EyamlGkmsLocation string `json:"eyamlGkmsLocation,omitempty"`
	// EyamlGkmsKeyring is the ID of the Cloud KMS key ring
	EyamlGkmsKeyring string `json:"eyamlGkmsKeyring,omitempty"`
	// EyamlGkmsCryptoKey is the ID of the key to use
	EyamlGkmsCryptoKey string `json:"eyamlGkmsCryptoKey,omitempty"`
	// GlobalHooks is a set of global lifecycle hooks
	GlobalHooks map[string]interface{} `json:"globalHooks,omitempty"`
	// GlobalMaxHistory sets the global max number of historical release revisions to keep
	GlobalMaxHistory int `json:"globalMaxHistory,omitempty"`
	// SkipIgnoredApps if set to true, ignored apps will not be considered in the plan
	SkipIgnoredApps bool `json:"skipIgnoredApps,omitempty"`
	// SkipPendingApps is set to true,apps in a pending state will be ignored
	SkipPendingApps bool `json:"skipPendingApps,omitempty"`
}

Config type represents the settings fields

type CustomResource

type CustomResource struct {
	// Name of the custom resource
	Name string `json:"name,omitempty"`
	// Value of the custom resource
	Value string `json:"value,omitempty"`
}

custom resource type

type ExitStatus

type ExitStatus struct {
	// contains filtered or unexported fields
}

func (ExitStatus) String

func (e ExitStatus) String() string

type HelmTime

type HelmTime struct {
	time.Time
}

func (*HelmTime) IsSet

func (ht *HelmTime) IsSet() bool

func (*HelmTime) MarshalJSON

func (ht *HelmTime) MarshalJSON() ([]byte, error)

func (*HelmTime) UnmarshalJSON

func (ht *HelmTime) UnmarshalJSON(b []byte) (err error)

type Limit

type Limit struct {
	// Max defines the resource limits
	Max Resources `json:"max,omitempty"`
	// Min defines the resource request
	Min Resources `json:"min,omitempty"`
	// Default stes resource limits to pods without defined resource limits
	Default Resources `json:"default,omitempty"`
	// DefaultRequest sets the resource requests for pods without defined resource requests
	DefaultRequest Resources `json:"defaultRequest,omitempty"`
	// MaxLimitRequestRatio set the max limit request ratio
	MaxLimitRequestRatio Resources `json:"maxLimitRequestRatio,omitempty"`
	Type                 string    `json:"type"`
}

Limit represents a resource limit

type Limits

type Limits []Limit

Limits type

type Logger

type Logger struct {
	*logger.Logger
	SlackWebhook   string
	MSTeamsWebhook string
}

func (*Logger) Debug

func (l *Logger) Debug(message string)

func (*Logger) Error

func (l *Logger) Error(message string)

func (*Logger) Fatal

func (l *Logger) Fatal(message string)

func (*Logger) Verbose

func (l *Logger) Verbose(message string)

type MergoTransformer

type MergoTransformer func(typ reflect.Type) func(dst, src reflect.Value) error

func (MergoTransformer) Transformer

func (m MergoTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error

type Namespace

type Namespace struct {
	// Protected if set to true no changes can be applied to the namespace
	Protected bool `json:"protected"`
	// Limits to set on the namespace
	Limits Limits `json:"limits,omitempty"`
	// Labels to set to the namespace
	Labels map[string]string `json:"labels,omitempty"`
	// Annotations to set on the namespace
	Annotations map[string]string `json:"annotations,omitempty"`
	// Quotas to set on the namespace
	Quotas *Quotas `json:"quotas,omitempty"`
	// contains filtered or unexported fields
}

Namespace type represents the fields of a Namespace

func (*Namespace) Disable

func (n *Namespace) Disable()

type NullBool

type NullBool struct {
	Value    bool
	HasValue bool // true if bool is not null
}

NullBool represents a bool that may be null.

func (NullBool) JSONSchema

func (NullBool) JSONSchema() *jsonschema.Schema

JSONSchema instructs the jsonschema generator to represent NullBool type as boolean

func (NullBool) MarshalJSON

func (b NullBool) MarshalJSON() ([]byte, error)

func (*NullBool) UnmarshalJSON

func (b *NullBool) UnmarshalJSON(data []byte) error

func (*NullBool) UnmarshalText

func (b *NullBool) UnmarshalText(text []byte) error

type Quotas

type Quotas struct {
	// Pods is the pods quota
	Pods string `json:"pods,omitempty"`
	// CPULimits is the CPU quota
	CPULimits string `json:"limits.cpu,omitempty"`
	// CPURequests is the CPU requests quota
	CPURequests string `json:"requests.cpu,omitempty"`
	// MemoryLimits is the memory quota
	MemoryLimits string `json:"limits.memory,omitempty"`
	// MemoryRequests is the memory requests quota
	MemoryRequests string `json:"requests.memory,omitempty"`
	// CustomResource is a list of custom resource quotas
	CustomQuotas []CustomResource `json:"customQuotas,omitempty"`
}

quota type

type Release

type Release struct {
	// Name is the helm release name
	Name string `json:"name"`
	// Description is a user friendly description of the helm release
	Description string `json:"description,omitempty"`
	// Namespace where to deploy the helm release
	Namespace string `json:"namespace"`
	// Enabled can be used to togle a helm release
	Enabled NullBool `json:"enabled"`
	Group   string   `json:"group,omitempty"`
	Chart   string   `json:"chart"`
	// Version of the helm chart to deploy
	Version string `json:"version"`
	// ValuesFile is the path for a values file for the helm release
	ValuesFile string `json:"valuesFile,omitempty"`
	// ValuesFiles is a list of paths a values files for the helm release
	ValuesFiles []string `json:"valuesFiles,omitempty"`
	// SecretsFile is the path for an encrypted values file for the helm release
	SecretsFile string `json:"secretsFile,omitempty"`
	// SecretsFiles is a list of paths for encrypted values files for the helm release
	SecretsFiles []string `json:"secretsFiles,omitempty"`
	// PostRenderer is the path to an executable to be used for post rendering
	PostRenderer string `json:"postRenderer,omitempty"`
	// Test indicates if the chart tests should be executed
	Test NullBool `json:"test,omitempty"`
	// Protected defines if the release should be protected against changes
	Protected NullBool `json:"protected,omitempty"`
	// Wait defines whether helm should block execution until all k8s resources are in a ready state
	Wait NullBool `json:"wait,omitempty"`
	// Priority allows defining the execution order, releases with the same priority can be executed in parallel
	Priority int `json:"priority,omitempty"`
	// Set can be used to overwrite the chart values
	Set map[string]string `json:"set,omitempty"`
	// SetString can be used to overwrite string values
	SetString map[string]string `json:"setString,omitempty"`
	// SetFile can be used to overwrite the chart values
	SetFile map[string]string `json:"setFile,omitempty"`
	// HelmFlags is a list of additional flags to pass to the helm command
	HelmFlags []string `json:"helmFlags,omitempty"`
	// HelmDiffFlags is a list of cli flags to pass to helm diff
	HelmDiffFlags []string `json:"helmDiffFlags,omitempty"`
	// NoHooks can be used to disable the execution of helm hooks
	NoHooks NullBool `json:"noHooks,omitempty"`
	// Timeout is the number of seconds to wait for the release to complete
	Timeout int `json:"timeout,omitempty"`
	// Hooks can be used to define lifecycle hooks specific to this release
	Hooks map[string]interface{} `json:"hooks,omitempty"`
	// MaxHistory is the maximum number of histoical releases to keep
	MaxHistory int `json:"maxHistory,omitempty"`
	// contains filtered or unexported fields
}

Release type representing Helm releases which are described in the desired state

func (*Release) Disable

func (r *Release) Disable()

type Resources

type Resources struct {
	// CPU is the number of CPU cores
	CPU string `json:"cpu,omitempty"`
	// Memory is the amount of memory
	Memory string `json:"memory,omitempty"`
}

Resources type

type State

type State struct {
	// Metadata for human reader of the desired state file
	Metadata map[string]string `json:"metadata,omitempty"`
	// Certificates are used to connect kubectl to a cluster
	Certificates map[string]string `json:"certificates,omitempty"`
	// Settings for configuring helmsman
	Settings Config `json:"settings,omitempty"`
	// Context defines an helmsman scope
	Context string `json:"context,omitempty"`
	// HelmRepos from where to find the application helm charts
	HelmRepos map[string]string `json:"helmRepos,omitempty"`
	// PreconfiguredHelmRepos is a list of helm repos that are configured outside of the DSF
	PreconfiguredHelmRepos []string `json:"preconfiguredHelmRepos,omitempty"`
	// Namespaces where helmsman will deploy applications
	Namespaces map[string]*Namespace `json:"namespaces"`
	// Apps holds the configuration for each helm release managed by helmsman
	Apps map[string]*Release `json:"apps"`
	// AppsTemplates allow defining YAML objects thatcan be used as a reference with YAML anchors to keep the configuration DRY
	AppsTemplates map[string]*Release `json:"appsTemplates,omitempty"`
	// contains filtered or unexported fields
}

State type represents the desired State of applications on a k8s cluster.

type StateFiles

type StateFiles struct {
	StateFiles []StatePath `json:"stateFiles"`
}

type StatePath

type StatePath struct {
	Path string `json:"path"`
}

Jump to

Keyboard shortcuts

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