Documentation
¶
Index ¶
- Constants
- Variables
- func AddHelmRepoIfMissing(helmer Helmer, helmURL, repoName, username, password string) (string, error)
- func AppendMyValues(valueFiles []string) ([]string, error)
- func CombineValueFilesToFile(outFile string, inputFiles []string, chartName string, ...) error
- func FindChartFileName(dir string) (string, error)
- func FindRequirementsFileName(dir string) (string, error)
- func FindTemplatesDirName(dir string) (string, error)
- func FindValuesFileName(dir string) (string, error)
- func FindValuesFileNameForChart(dir string, chartName string) (string, error)
- func GenerateReadmeForChart(name string, version string, description string, chartRepo string, ...) string
- func HandleExternalFileRefs(element interface{}, possibles map[string]string, jsonPath string, ...) error
- func InspectChart(chart string, version string, repo string, username string, password string, ...) error
- func IsLocal(chart string) bool
- func IsZeroOfUnderlyingType(x interface{}) bool
- func LoadChart(data []byte) (*chart.Metadata, error)
- func LoadChartFile(fileName string) (*chart.Metadata, error)
- func LoadChartName(chartFile string) (string, error)
- func LoadChartNameAndVersion(chartFile string) (string, string, error)
- func LoadParametersValuesFile(dir string) (map[string]interface{}, error)
- func LoadTemplatesDir(dirName string) (map[string]string, error)
- func LoadValues(data []byte) (map[string]interface{}, error)
- func LoadValuesFile(fileName string) (map[string]interface{}, error)
- func ModifyChart(chartFile string, fn func(chart *chart.Metadata) error) error
- func RenderReleasesAsTable(releases map[string]ReleaseSummary, sortedKeys []string) (string, error)
- func SaveFile(fileName string, contents interface{}) error
- func SetChartVersion(chartFile string, version string) error
- func SetValuesToMap(setValues []string) map[string]interface{}
- func UpdateImagesInValuesToNewVersion(data []byte, name string, newVersion string) ([]byte, []string)
- func UpdateRequirementsToNewVersion(requirements *Requirements, name string, newVersion string) []string
- type ChartSummary
- type DepSorter
- type Dependency
- type ErrNoRequirementsFile
- type FakeHelmer
- func (f *FakeHelmer) AddRepo(repo, repoURL, username, password string) error
- func (f *FakeHelmer) BuildDependency() error
- func (f *FakeHelmer) DecryptSecrets(location string) error
- func (f *FakeHelmer) DeleteRelease(ns, releaseName string, purge bool) error
- func (f *FakeHelmer) Env() map[string]string
- func (f *FakeHelmer) FetchChart(chart, version string, untar bool, untardir, repo, username, password string) error
- func (f *FakeHelmer) FindChart() (string, error)
- func (f *FakeHelmer) HelmBinary() string
- func (f *FakeHelmer) InstallChart(chart, releaseName, ns, version string, timeout int, ...) error
- func (f *FakeHelmer) IsRepoMissing(repoURL string) (bool, string, error)
- func (f *FakeHelmer) Lint(valuesFiles []string) (string, error)
- func (f *FakeHelmer) ListReleases(ns string) (map[string]ReleaseSummary, []string, error)
- func (f *FakeHelmer) ListRepos() (map[string]string, error)
- func (f *FakeHelmer) PackageChart() error
- func (f *FakeHelmer) RemoveRepo(repo string) error
- func (f *FakeHelmer) RemoveRequirementsLock() error
- func (f *FakeHelmer) SearchCharts(filter string, allVersions bool) ([]ChartSummary, error)
- func (f *FakeHelmer) SetCWD(dir string)
- func (f *FakeHelmer) StatusRelease(ns, releaseName string) error
- func (f *FakeHelmer) StatusReleaseWithOutput(ns, releaseName, format string) (string, error)
- func (f *FakeHelmer) Template(chartDir, releaseName, ns, outputDir string, upgrade bool, ...) error
- func (f *FakeHelmer) UpdateRepo() error
- func (f *FakeHelmer) UpgradeChart(chart, releaseName, ns, version string, install bool, timeout int, ...) error
- func (f *FakeHelmer) Version(tls bool) (string, error)
- type HelmCLI
- func (h *HelmCLI) AddRepo(repoName, repoURL, username, password string) error
- func (h *HelmCLI) BuildDependency() error
- func (h *HelmCLI) DecryptSecrets(location string) error
- func (h *HelmCLI) DeleteRelease(ns, releaseName string, purge bool) error
- func (h *HelmCLI) Env() map[string]string
- func (h *HelmCLI) FetchChart(chart, version string, untar bool, untardir, repo, username, password string) error
- func (h *HelmCLI) FindChart() (string, error)
- func (h *HelmCLI) HelmBinary() string
- func (h *HelmCLI) Init(clientOnly bool, serviceAccount, tillerNamespace string, upgrade bool) error
- func (h *HelmCLI) InstallChart(chart, releaseName, ns, version string, timeout int, ...) error
- func (h *HelmCLI) IsRepoMissing(repoURL string) (bool, string, error)
- func (h *HelmCLI) Lint(valuesFiles []string) (string, error)
- func (h *HelmCLI) ListReleases(ns string) (map[string]ReleaseSummary, []string, error)
- func (h *HelmCLI) ListRepos() (map[string]string, error)
- func (h *HelmCLI) PackageChart() error
- func (h *HelmCLI) RemoveRepo(repo string) error
- func (h *HelmCLI) RemoveRequirementsLock() error
- func (h *HelmCLI) SearchCharts(filter string, allVersions bool) ([]ChartSummary, error)
- func (h *HelmCLI) SetCWD(dir string)
- func (h *HelmCLI) SetHelmBinary(binary string)
- func (h *HelmCLI) StatusRelease(ns, releaseName string) error
- func (h *HelmCLI) StatusReleaseWithOutput(ns, releaseName, outputFormat string) (string, error)
- func (h *HelmCLI) Template(chart, releaseName, ns, outDir string, upgrade bool, ...) error
- func (h *HelmCLI) UpdateRepo() error
- func (h *HelmCLI) UpgradeChart(chart, releaseName, ns, version string, install bool, timeout int, ...) error
- func (h *HelmCLI) Version(tls bool) (string, error)
- func (h *HelmCLI) VersionWithArgs(tls bool, extraArgs ...string) (string, error)
- type HelmRepoCredential
- type HelmRepoCredentials
- type Helmer
- type InstallChartOptions
- type ReleaseSummary
- type Requirements
Constants ¶
const ( // ChartFileName file name for a chart ChartFileName = "Chart.yaml" // RequirementsFileName the file name for helm requirements RequirementsFileName = "requirements.yaml" // SecretsFileName the file name for secrets SecretsFileName = "secrets.yaml" // ValuesFileName the file name for values ValuesFileName = "values.yaml" // ValuesTemplateFileName a templated values.yaml file which can refer to parameter expressions ValuesTemplateFileName = "values.tmpl.yaml" // TemplatesDirName is the default name for the templates directory TemplatesDirName = "templates" // ParametersYAMLFile contains logical parameters (values or secrets) which can be fetched from a Secret URL or // inlined if not a secret which can be referenced from a 'values.yaml` file via a `{{ .Parameters.foo.bar }}` expression ParametersYAMLFile = "parameters.yaml" // FakeChartmusuem is the url for the fake chart museum used in tests FakeChartmusuem = "http://fake.chartmuseum" // DefaultEnvironmentChartDir is the default environment path where charts are stored DefaultEnvironmentChartDir = "env" //RepoVaultPath is the path to the repo credentials in Vault RepoVaultPath = "helm/repos" // JX3ChartRepository the default charts repo for the jx3 charts JX3ChartRepository = "https://storage.googleapis.com/jenkinsxio/charts" // AnnotationChartName stores the chart name AnnotationChartName = "jenkins.io/chart" // AnnotationAppVersion stores the chart's app version AnnotationAppVersion = "jenkins.io/chart-app-version" // AnnotationAppDescription stores the chart's app version AnnotationAppDescription = "jenkins.io/chart-description" // AnnotationAppRepository stores the chart's app repository AnnotationAppRepository = "jenkins.io/chart-repository" // LabelReleaseName stores the chart release name LabelReleaseName = "jenkins.io/chart-release" // LabelNamespace stores the chart namespace for cluster wide resources LabelNamespace = "jenkins.io/namespace" // LabelReleaseChartVersion stores the version of a chart installation in a label LabelReleaseChartVersion = "jenkins.io/version" // LabelAppName stores the chart's app name LabelAppName = "jenkins.io/app-name" // LabelAppVersion stores the chart's app version LabelAppVersion = "jenkins.io/app-version" )
Variables ¶
var DefaultValuesTreeIgnores = []string{
"templates/*",
}
DefaultValuesTreeIgnores is the default set of ignored files for collapsing the values tree which are used if ignores is nil
Functions ¶
func AddHelmRepoIfMissing ¶
func AddHelmRepoIfMissing(helmer Helmer, helmURL, repoName, username, password string) (string, error)
AddHelmRepoIfMissing will add the helm repo if there is no helm repo with that url present. It will generate the repoName from the url (using the host name) if the repoName is empty. The repo name may have a suffix added in order to prevent name collisions, and is returned for this reason. The username and password will be stored in vault for the URL (if vault is enabled).
func AppendMyValues ¶ added in v1.0.60
func CombineValueFilesToFile ¶ added in v1.0.60
func CombineValueFilesToFile(outFile string, inputFiles []string, chartName string, extraValues map[string]interface{}) error
CombineValueFilesToFile iterates through the input files and combines them into a single Values object and then write it to the output file nested inside the chartName
func FindChartFileName ¶ added in v1.0.60
FindChartFileName returns the default chart.yaml file name
func FindRequirementsFileName ¶ added in v1.0.60
FindRequirementsFileName returns the default requirements.yaml file name
func FindTemplatesDirName ¶ added in v1.0.60
FindTemplatesDirName returns the default templates/ dir name
func FindValuesFileName ¶ added in v1.0.60
FindValuesFileName returns the default values.yaml file name
func FindValuesFileNameForChart ¶ added in v1.0.60
FindValuesFileNameForChart returns the values.yaml file name for a given chart within the environment or the default if the chart name is empty
func GenerateReadmeForChart ¶ added in v1.0.60
func GenerateReadmeForChart(name string, version string, description string, chartRepo string, gitRepo string, releaseNotesURL string, appReadme string) string
GenerateReadmeForChart generates a string that can be used as a README.MD, and includes info on the chart.
func HandleExternalFileRefs ¶ added in v1.0.60
func HandleExternalFileRefs(element interface{}, possibles map[string]string, jsonPath string, handler func(path string, element map[string]interface{}, key string) error) error
HandleExternalFileRefs recursively scans the element map structure, looking for nested maps. If it finds keys that match any key-value pair in possibles it will call the handler. The jsonPath is used for referencing the path in the map structure when reporting errors.
func InspectChart ¶ added in v1.0.60
func InspectChart(chart string, version string, repo string, username string, password string, helmer Helmer, inspector func(dir string) error) error
InspectChart fetches the specified chart in a repo using helmer, and then calls the closure on it, before cleaning up
func IsLocal ¶ added in v1.0.60
IsLocal returns whether this chart is being installed from the local filesystem or not
func IsZeroOfUnderlyingType ¶ added in v1.0.60
func IsZeroOfUnderlyingType(x interface{}) bool
IsZeroOfUnderlyingType checks if the underlying type of the interface is set to it's zero value
func LoadChartFile ¶ added in v1.0.60
LoadChartFile loads the chart file or creates empty chart if the file does not exist
func LoadChartName ¶ added in v1.0.60
func LoadChartNameAndVersion ¶ added in v1.0.60
func LoadParametersValuesFile ¶ added in v1.0.60
LoadParametersValuesFile loads the parameters values file or creates empty map if the file does not exist
func LoadTemplatesDir ¶ added in v1.0.60
LoadTemplatesDir loads the files in the templates dir or creates empty map if none exist
func LoadValues ¶ added in v1.0.60
LoadValues loads the values from some data
func LoadValuesFile ¶ added in v1.0.60
LoadValuesFile loads the values file or creates empty map if the file does not exist
func ModifyChart ¶ added in v1.0.60
ModifyChart modifies the given chart using a callback
func RenderReleasesAsTable ¶ added in v1.0.60
func RenderReleasesAsTable(releases map[string]ReleaseSummary, sortedKeys []string) (string, error)
RenderReleasesAsTable lists the current releases in a table
func SetChartVersion ¶ added in v1.0.60
SetChartVersion modifies the given chart file to update the version
func SetValuesToMap ¶ added in v1.0.60
SetValuesToMap converts the set of values of the form "foo.bar=123" into a helm values.yaml map structure
func UpdateImagesInValuesToNewVersion ¶ added in v1.0.60
func UpdateImagesInValuesToNewVersion(data []byte, name string, newVersion string) ([]byte, []string)
UpdateImagesInValuesToNewVersion update a (values) file, replacing that start with "Image: <name>:" to "Image: <name>:<newVersion>", returning the oldVersions
func UpdateRequirementsToNewVersion ¶ added in v1.0.60
func UpdateRequirementsToNewVersion(requirements *Requirements, name string, newVersion string) []string
UpdateRequirementsToNewVersion update dependencies with name to newVersion, returning the oldVersions
Types ¶
type ChartSummary ¶
ChartSummary contains a chart summary
func FindLatestChart ¶ added in v1.0.60
func FindLatestChart(name string, helmer Helmer) (*ChartSummary, error)
FindLatestChart uses helmer to find the latest chart for name
type DepSorter ¶ added in v1.0.60
type DepSorter []*Dependency
DepSorter Used to avoid merge conflicts by sorting deps by name
type Dependency ¶ added in v1.0.60
type Dependency struct { // Name is the name of the dependency. // // This must mach the name in the dependency's Chart.yaml. Name string `json:"name"` // Version is the version (range) of this chart. // // A lock file will always produce a single version, while a dependency // may contain a semantic version range. Version string `json:"version,omitempty"` // The URL to the repository. // // Appending `index.yaml` to this string should result in a URL that can be // used to fetch the repository index. Repository string `json:"repository"` // A yaml path that resolves to a boolean, used for enabling/disabling charts (e.g. subchart1.enabled ) Condition string `json:"condition,omitempty"` // Tags can be used to group charts for enabling/disabling together Tags []string `json:"tags,omitempty"` // Enabled bool determines if chart should be loaded Enabled bool `json:"enabled,omitempty"` // ImportValues holds the mapping of source values to parent key to be imported. Each item can be a // string or pair of child/parent sublist items. ImportValues []interface{} `json:"import-values,omitempty"` // Alias usable alias to be used for the chart Alias string `json:"alias,omitempty"` }
Dependency describes a chart upon which another chart depends.
Dependencies can be used to express developer intent, or to capture the state of a chart.
type ErrNoRequirementsFile ¶ added in v1.0.60
type ErrNoRequirementsFile error
ErrNoRequirementsFile to detect error condition
type FakeHelmer ¶
FakeHelmer a fake helmer
func (*FakeHelmer) AddRepo ¶
func (f *FakeHelmer) AddRepo(repo, repoURL, username, password string) error
func (*FakeHelmer) BuildDependency ¶
func (f *FakeHelmer) BuildDependency() error
func (*FakeHelmer) DecryptSecrets ¶
func (f *FakeHelmer) DecryptSecrets(location string) error
func (*FakeHelmer) DeleteRelease ¶
func (f *FakeHelmer) DeleteRelease(ns, releaseName string, purge bool) error
func (*FakeHelmer) Env ¶
func (f *FakeHelmer) Env() map[string]string
func (*FakeHelmer) FetchChart ¶
func (f *FakeHelmer) FetchChart(chart, version string, untar bool, untardir, repo, username, password string) error
func (*FakeHelmer) FindChart ¶
func (f *FakeHelmer) FindChart() (string, error)
func (*FakeHelmer) HelmBinary ¶
func (f *FakeHelmer) HelmBinary() string
func (*FakeHelmer) InstallChart ¶
func (*FakeHelmer) IsRepoMissing ¶
func (f *FakeHelmer) IsRepoMissing(repoURL string) (bool, string, error)
func (*FakeHelmer) ListReleases ¶
func (f *FakeHelmer) ListReleases(ns string) (map[string]ReleaseSummary, []string, error)
func (*FakeHelmer) PackageChart ¶
func (f *FakeHelmer) PackageChart() error
func (*FakeHelmer) RemoveRepo ¶
func (f *FakeHelmer) RemoveRepo(repo string) error
func (*FakeHelmer) RemoveRequirementsLock ¶
func (f *FakeHelmer) RemoveRequirementsLock() error
func (*FakeHelmer) SearchCharts ¶
func (f *FakeHelmer) SearchCharts(filter string, allVersions bool) ([]ChartSummary, error)
func (*FakeHelmer) SetCWD ¶
func (f *FakeHelmer) SetCWD(dir string)
func (*FakeHelmer) StatusRelease ¶
func (f *FakeHelmer) StatusRelease(ns, releaseName string) error
func (*FakeHelmer) StatusReleaseWithOutput ¶
func (f *FakeHelmer) StatusReleaseWithOutput(ns, releaseName, format string) (string, error)
func (*FakeHelmer) Template ¶
func (f *FakeHelmer) Template(chartDir, releaseName, ns, outputDir string, upgrade bool, values, valueStrings, valueFiles []string) error
func (*FakeHelmer) UpdateRepo ¶
func (f *FakeHelmer) UpdateRepo() error
func (*FakeHelmer) UpgradeChart ¶
type HelmCLI ¶
type HelmCLI struct { Binary string CWD string Runner cmdrunner.CommandRunner Command *cmdrunner.Command Debug bool }
HelmCLI implements common helm actions based on helm CLI
func NewHelmCLIWithRunner ¶
func NewHelmCLIWithRunner(runner cmdrunner.CommandRunner, binary, cwd string, debug bool) *HelmCLI
NewHelmCLIWithRunner creates a new HelmCLI interface for the given runner
func (*HelmCLI) BuildDependency ¶
BuildDependency builds the helm dependencies of the helm chart from the current working directory
func (*HelmCLI) DecryptSecrets ¶
DecryptSecrets decrypt secrets
func (*HelmCLI) DeleteRelease ¶
DeleteRelease removes the given release
func (*HelmCLI) FetchChart ¶
func (h *HelmCLI) FetchChart(chart, version string, untar bool, untardir, repo, username, password string) error
FetchChart fetches a Helm Chart
func (*HelmCLI) FindChart ¶
FindChart find a chart in the current working directory, if no chart file is found an error is returned
func (*HelmCLI) HelmBinary ¶
HelmBinary return the configured helm CLI
func (*HelmCLI) InstallChart ¶
func (h *HelmCLI) InstallChart(chart, releaseName, ns, version string, timeout int, values, valueStrings, valueFiles []string, repo, username, password string) error
InstallChart installs a helm chart according with the given flags
func (*HelmCLI) IsRepoMissing ¶
IsRepoMissing checks if the repository with the given URL is missing from helm. If the repo is found, the name of the repo will be returned
func (*HelmCLI) Lint ¶
Lint lints the helm chart from the current working directory and returns the warnings in the output
func (*HelmCLI) ListReleases ¶
ListReleases lists the releases in ns
func (*HelmCLI) PackageChart ¶
PackageChart packages the chart from the current working directory
func (*HelmCLI) RemoveRepo ¶
RemoveRepo removes the given repo from helm
func (*HelmCLI) RemoveRequirementsLock ¶
RemoveRequirementsLock removes the requirements.lock file from the current working directory
func (*HelmCLI) SearchCharts ¶
func (h *HelmCLI) SearchCharts(filter string, allVersions bool) ([]ChartSummary, error)
SearchCharts searches for all the charts matching the given filter
func (*HelmCLI) SetHelmBinary ¶
SetHelmBinary configure a new helm CLI
func (*HelmCLI) StatusRelease ¶
StatusRelease returns the output of the helm status command for a given release
func (*HelmCLI) StatusReleaseWithOutput ¶
StatusReleaseWithOutput returns the output of the helm status command for a given release
func (*HelmCLI) Template ¶
func (h *HelmCLI) Template(chart, releaseName, ns, outDir string, upgrade bool, values, valueStrings, valueFiles []string) error
Template generates the YAML from the chart template to the given directory
func (*HelmCLI) UpdateRepo ¶
UpdateRepo updates the helm repositories
func (*HelmCLI) UpgradeChart ¶
func (h *HelmCLI) UpgradeChart(chart, releaseName, ns, version string, install bool, timeout int, force, wait bool, values, valueStrings, valueFiles []string, repo, username, password string) error
UpgradeChart upgrades a helm chart according with given helm flags
type HelmRepoCredential ¶ added in v1.0.60
type HelmRepoCredential struct { Username string `json:"username"` Password string `json:"password"` }
HelmRepoCredential is a username and password pair that can ben used to authenticated against a Helm repo
type HelmRepoCredentials ¶ added in v1.0.60
type HelmRepoCredentials map[string]HelmRepoCredential
HelmRepoCredentials is a map of repositories to HelmRepoCredential that stores all the helm repo credentials for the cluster
type Helmer ¶
type Helmer interface { SetCWD(dir string) HelmBinary() string AddRepo(repo, URL, username, password string) error RemoveRepo(repo string) error ListRepos() (map[string]string, error) UpdateRepo() error IsRepoMissing(URL string) (bool, string, error) RemoveRequirementsLock() error BuildDependency() error InstallChart(chart string, releaseName string, ns string, version string, timeout int, values []string, valueStrings []string, valueFiles []string, repo string, username string, password string) error UpgradeChart(chart string, releaseName string, ns string, version string, install bool, timeout int, force bool, wait bool, values []string, valueStrings []string, valueFiles []string, repo string, username string, password string) error FetchChart(chart string, version string, untar bool, untardir string, repo string, username string, password string) error DeleteRelease(ns string, releaseName string, purge bool) error ListReleases(ns string) (map[string]ReleaseSummary, []string, error) FindChart() (string, error) PackageChart() error StatusRelease(ns string, releaseName string) error StatusReleaseWithOutput(ns string, releaseName string, format string) (string, error) Lint(valuesFiles []string) (string, error) Version(tls bool) (string, error) SearchCharts(filter string, allVersions bool) ([]ChartSummary, error) Env() map[string]string DecryptSecrets(location string) error Template(chartDir string, releaseName string, ns string, outputDir string, upgrade bool, values []string, valueStrings []string, valueFiles []string) error }
Helmer defines common helm actions used within Jenkins X
type InstallChartOptions ¶ added in v1.0.60
type InstallChartOptions struct { Dir string ReleaseName string Chart string Version string Ns string HelmUpdate bool SetValues []string SetStrings []string ValueFiles []string Repository string Username string Password string VersionsDir string VersionsGitURL string VersionsGitRef string InstallOnly bool NoForce bool Wait bool UpgradeOnly bool }
type ReleaseSummary ¶
type ReleaseSummary struct { ReleaseName string Revision string Updated string Status string ChartFullName string Chart string ChartVersion string AppVersion string Namespace string }
ReleaseSummary is the information about a release in Helm
type Requirements ¶ added in v1.0.60
type Requirements struct {
Dependencies []*Dependency `json:"dependencies"`
}
Requirements is a list of requirements for a chart.
Requirements are charts upon which this chart depends. This expresses developer intent.
func LoadRequirements ¶ added in v1.0.60
func LoadRequirements(data []byte) (*Requirements, error)
LoadRequirements loads the requirements from some data
func LoadRequirementsFile ¶ added in v1.0.60
func LoadRequirementsFile(fileName string) (*Requirements, error)
LoadRequirementsFile loads the requirements file or creates empty requirements if the file does not exist
func (*Requirements) RemoveApplication ¶ added in v1.0.60
func (r *Requirements) RemoveApplication(app string) bool
RemoveApplication removes the given app name. Returns true if a dependency was removed
func (*Requirements) SetAppVersion ¶ added in v1.0.60
func (r *Requirements) SetAppVersion(app string, version string, repository string, alias string)
SetAppVersion sets the version of the app to use