utils

package
v0.0.0-...-5017d72 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIfNotContained

func AddIfNotContained(s []string, e string) (sout []string)

AddIfNotContained adds a string to a slice if it is not contained in it and not empty

func AddRepository

func AddRepository(o AddRepositoryOptions) error

AddRepository adds a chart repository to the repositories file

func CheckCircularDependencies

func CheckCircularDependencies(releases []ReleaseSpec) bool

CheckCircularDependencies verifies that there are no circular dependencies between ReleaseSpecs

func Contains

func Contains(s []string, e string) bool

Contains checks if a slice contains a given value

func CountLinesPerPathFilter

func CountLinesPerPathFilter(pathFilter []string, changedPaths []string) (changedPathsPerFilter map[string]int, changedPathsPerFilterCount int)

CountLinesPerPathFilter get a list of path filters (regex=type) and counts matches from the paths that were changed

func CreateNamespace

func CreateNamespace(name, kubeContext string, print bool) error

CreateNamespace creates a namespace

func DeleteNamespace

func DeleteNamespace(name, kubeContext string, print bool) error

DeleteNamespace deletes a namespace

func DeleteRelease

func DeleteRelease(o DeleteReleaseOptions) error

DeleteRelease deletes a release from Kubernetes

func DeleteReleases

func DeleteReleases(o DeleteReleasesOptions) error

DeleteReleases deletes a list of releases in parallel

func DeployChartFromRepository

func DeployChartFromRepository(o DeployChartFromRepositoryOptions) error

DeployChartFromRepository deploys a Helm chart from a chart repository

func DeployChartsFromRepository

func DeployChartsFromRepository(o DeployChartsFromRepositoryOptions) error

DeployChartsFromRepository deploys a list of Helm charts from a repository in parallel

func Exec

func Exec(cmd []string) (string, error)

Exec takes a command as a string and executes it

func FetchChart

func FetchChart(o FetchChartOptions) error

FetchChart fetches a chart from chart repository by name and version and untars it in the local directory

func GetBoolEnvVar

func GetBoolEnvVar(name string, defVal bool) bool

GetBoolEnvVar returns the default value if the variable is empty or not true or false, else the value

func GetBuildTypeByPathFilters

func GetBuildTypeByPathFilters(defaultType string, changedPaths, pathFilter []string, allowMultipleTypes bool) string

GetBuildTypeByPathFilters determines the build type according to path filters

func GetChangedPaths

func GetChangedPaths(previousCommit string) []string

GetChangedPaths compares the current commit (HEAD) with the given commit and returns a list of the paths that were changed between them

func GetChartIndex

func GetChartIndex(charts []ReleaseSpec, name string) int

GetChartIndex returns the index of a desired release by its name

func GetClientToK8s

func GetClientToK8s() (*kubernetes.Clientset, error)

GetClientToK8s returns a k8s ClientSet

func GetIntEnvVar

func GetIntEnvVar(name string, defVal int) int

GetIntEnvVar returns 0 if the variable is empty or not int, else the value

func GetNamespace

func GetNamespace(name, kubeContext string) (*v1.Namespace, error)

GetNamespace gets a namespace

func GetStringEnvVar

func GetStringEnvVar(name, defVal string) string

GetStringEnvVar returns the default value if the variable is empty, else the value

func IsCommitError

func IsCommitError(commit, commitErrorIndicator string) bool

IsCommitError returns true if the commit string equals the error indicator

func IsEnvValid

func IsEnvValid(name, kubeContext string) (bool, error)

IsEnvValid validates the state of a namespace

func IsEnvValidWithLoopBackOff

func IsEnvValidWithLoopBackOff(name, kubeContext string) (bool, error)

IsEnvValidWithLoopBackOff validates the state of a namespace with back off loop

func IsMainlineOrReleaseRef

func IsMainlineOrReleaseRef(currentRef, mainRef, releaseRef string) bool

IsMainlineOrReleaseRef returns true if this is the mainline or a release branch

func Lint

func Lint(o LintOptions) error

Lint takes a path to a chart and runs a series of tests to verify that the chart is well-formed

func MapToString

func MapToString(m map[string]string) string

MapToString returns a string representation of a map

func NamespaceExists

func NamespaceExists(name, kubeContext string) (bool, error)

NamespaceExists returns true if the namespace exists

func PerformRequest

func PerformRequest(o PerformRequestOptions) []byte

PerformRequest performs an HTTP request to a given url with an expected status code (to support testing) and returns the body

func PrintDiff

func PrintDiff(o DiffOptions)

PrintDiff prints a table of differences between two environments

func PrintExec

func PrintExec(cmd []string, print bool) error

PrintExec takes a command and executes it, with or without printing

func PrintReleasesMarkdown

func PrintReleasesMarkdown(releases []ReleaseSpec)

PrintReleasesMarkdown prints releases in markdown format

func PrintReleasesTable

func PrintReleasesTable(releases []ReleaseSpec)

PrintReleasesTable prints releases in table format

func PrintReleasesYaml

func PrintReleasesYaml(releases []ReleaseSpec)

PrintReleasesYaml prints releases in yaml format

func PushChart

func PushChart(o PushChartOptions) error

PushChart pushes a helm chart to a chart repository

func PushChartToRepository

func PushChartToRepository(o PushChartToRepositoryOptions) error

PushChartToRepository packages and pushes a Helm chart to a chart repository

func ResetChartVersion

func ResetChartVersion(path, version string)

ResetChartVersion resets a chart version to a desired value

func SplitInTwo

func SplitInTwo(s, sep string) (string, string)

SplitInTwo splits a string to two parts by a delimeter

func UpdateChartDependencies

func UpdateChartDependencies(o UpdateChartDependenciesOptions) error

UpdateChartDependencies performs helm dependency update

func UpdateChartVersion

func UpdateChartVersion(path, append string) string

UpdateChartVersion updates a chart version with desired append value

func UpdateNamespace

func UpdateNamespace(name, kubeContext string, annotationsToUpdate, labelsToUpdate map[string]string, print bool) error

UpdateNamespace updates a namespace

func UpdateRepositories

func UpdateRepositories(print bool) error

UpdateRepositories updates helm repositories

func UpgradeRelease

func UpgradeRelease(o UpgradeReleaseOptions) error

UpgradeRelease performs helm upgrade -i

Types

type AddRepositoryOptions

type AddRepositoryOptions struct {
	Repo  string
	Print bool
}

AddRepositoryOptions are options passed to AddRepository

type BoundedWaitGroup

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

BoundedWaitGroup implements a sized WaitGroup

func NewBoundedWaitGroup

func NewBoundedWaitGroup(cap int) BoundedWaitGroup

NewBoundedWaitGroup initializes a new BoundedWaitGroup

func (*BoundedWaitGroup) Add

func (bwg *BoundedWaitGroup) Add(delta int)

Add performs a WaitGroup Add of a specified delta

func (*BoundedWaitGroup) Done

func (bwg *BoundedWaitGroup) Done()

Done performs a WaitGroup Add of -1

func (*BoundedWaitGroup) Wait

func (bwg *BoundedWaitGroup) Wait()

Wait performs a WaitGroup Wait

type ChartsFile

type ChartsFile struct {
	Releases []ReleaseSpec `yaml:"charts"`
}

ChartsFile represents the structure of a passed in charts file

type DeleteReleaseOptions

type DeleteReleaseOptions struct {
	ReleaseName  string
	KubeContext  string
	TLS          bool
	HelmTLSStore string
	Timeout      int
	Print        bool
}

DeleteReleaseOptions are options passed to DeleteRelease

type DeleteReleasesOptions

type DeleteReleasesOptions struct {
	ReleasesToDelete []ReleaseSpec
	KubeContext      string
	TLS              bool
	HelmTLSStore     string
	Parallel         int
	Timeout          int
}

DeleteReleasesOptions are options passed to DeleteReleases

type DeployChartFromRepositoryOptions

type DeployChartFromRepositoryOptions struct {
	ReleaseName  string
	Name         string
	Version      string
	KubeContext  string
	Namespace    string
	Repo         string
	TLS          bool
	HelmTLSStore string
	PackedValues []string
	SetValues    []string
	IsIsolated   bool
	Inject       bool
	Timeout      int
	Validate     bool
}

DeployChartFromRepositoryOptions are options passed to DeployChartFromRepository

type DeployChartsFromRepositoryOptions

type DeployChartsFromRepositoryOptions struct {
	ReleasesToInstall []ReleaseSpec
	KubeContext       string
	Namespace         string
	Repo              string
	TLS               bool
	HelmTLSStore      string
	PackedValues      []string
	SetValues         []string
	Inject            bool
	Parallel          int
	Timeout           int
}

DeployChartsFromRepositoryOptions are options passed to DeployChartsFromRepository

type DiffOptions

type DiffOptions struct {
	KubeContextLeft   string
	EnvNameLeft       string
	KubeContextRight  string
	EnvNameRight      string
	ReleasesSpecLeft  []ReleaseSpec
	ReleasesSpecRight []ReleaseSpec
	Output            string
}

DiffOptions are options passed to PrintDiffTable

type FetchChartOptions

type FetchChartOptions struct {
	Repo    string
	Name    string
	Version string
	Dir     string
	Print   bool
}

FetchChartOptions are options passed to FetchChart

type GetInstalledReleasesOptions

type GetInstalledReleasesOptions struct {
	KubeContext   string
	Namespace     string
	IncludeFailed bool
}

GetInstalledReleasesOptions are options passed to GetInstalledReleases

type LintOptions

type LintOptions struct {
	Path  string
	Print bool
}

LintOptions are options passed to Lint

type PerformRequestOptions

type PerformRequestOptions struct {
	Method             string
	URL                string
	Headers            []string
	ExpectedStatusCode int
	Data               io.Reader
}

PerformRequestOptions are options passed to PerformRequest

type PushChartOptions

type PushChartOptions struct {
	Repo  string
	Path  string
	Print bool
}

PushChartOptions are options passed to PushChart

type PushChartToRepositoryOptions

type PushChartToRepositoryOptions struct {
	Path   string
	Append string
	Repo   string
	Lint   bool
	Print  bool
}

PushChartToRepositoryOptions are options passed to PushChartToRepository

type ReleaseSpec

type ReleaseSpec struct {
	ReleaseName  string   `yaml:"release_name,omitempty"`
	ChartName    string   `yaml:"name,omitempty"`
	ChartVersion string   `yaml:"version,omitempty"`
	Dependencies []string `yaml:"depends_on,omitempty"`
}

ReleaseSpec holds data relevant to deploying a release

func GetInstalledReleases

func GetInstalledReleases(o GetInstalledReleasesOptions) ([]ReleaseSpec, error)

GetInstalledReleases gets the installed Helm releases in a given namespace

func GetReleasesDelta

func GetReleasesDelta(fromReleases, toReleases []ReleaseSpec) []ReleaseSpec

GetReleasesDelta returns the delta between two slices of ReleaseSpec

func InitReleases

func InitReleases(env string, releases []string) []ReleaseSpec

InitReleases initializes a slice of ReleaseSpec from a string slice

func InitReleasesFromChartsFile

func InitReleasesFromChartsFile(file, env string) []ReleaseSpec

InitReleasesFromChartsFile initializes a slice of ReleaseSpec from a yaml formatted charts file

func OverrideReleases

func OverrideReleases(releases []ReleaseSpec, overrides []string, env string) []ReleaseSpec

OverrideReleases overrides versions of specified overrides

func RemoveChartFromCharts

func RemoveChartFromCharts(charts []ReleaseSpec, index int) []ReleaseSpec

RemoveChartFromCharts removes a ReleaseSpec from a slice of ReleaseSpec

func RemoveChartFromDependencies

func RemoveChartFromDependencies(charts []ReleaseSpec, name string) []ReleaseSpec

RemoveChartFromDependencies removes a release from other releases ReleaseSpec depends_on field

func (ReleaseSpec) Equals

func (r ReleaseSpec) Equals(b ReleaseSpec) bool

Equals compares two ReleaseSpecs

func (ReleaseSpec) Print

func (r ReleaseSpec) Print()

Print prints a ReleaseSpec

type UpdateChartDependenciesOptions

type UpdateChartDependenciesOptions struct {
	Path  string
	Print bool
}

UpdateChartDependenciesOptions are options passed to UpdateChartDependencies

type UpgradeReleaseOptions

type UpgradeReleaseOptions struct {
	Name         string
	ReleaseName  string
	KubeContext  string
	Namespace    string
	Values       []string
	Set          []string
	TLS          bool
	HelmTLSStore string
	Dir          string
	Print        bool
	Inject       bool
	Timeout      int
}

UpgradeReleaseOptions are options passed to UpgradeRelease

Jump to

Keyboard shortcuts

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