Documentation
¶
Overview ¶
package util contains tools for working with charts.
Charts are described in the chart package (pkg/chart). This package provides utilities for serializing and deserializing charts.
A chart can be represented on the file system in one of two ways:
- As a directory that contains a Chart.yaml file and other chart things.
- As a tarred gzipped file containing a directory that then contains a Chart.yaml file.
This package provides utilities for working with those file formats.
The preferred way of loading a chart is using 'loader.Load`:
chart, err := loader.Load(filename)
This will attempt to discover whether the file at 'filename' is a directory or a chart archive. It will then load accordingly.
For accepting raw compressed tar file data from an io.Reader, the 'loader.LoadArchive()' will read in the data, uncompress it, and unpack it into a Chart.
When creating charts in memory, use the 'github.com/werf/nelm/v2/pkg/helm/pkg/chart' package directly.
Index ¶
- Constants
- Variables
- func Create(name, dir string) (string, error)
- func CreateFrom(chartfile *chart.Metadata, dest, src string) error
- func Expand(dir string, r io.Reader) error
- func ExpandFile(dest, src string) error
- func IsChartDir(dirName string) (bool, error)
- func IsCompatibleRange(constraint, ver string) bool
- func LoadChartfile(filename string) (*chart.Metadata, error)
- func ProcessDependencies(c *chart.Chart, v common.Values) error
- func ProcessDependenciesWithMergedValues(c *chart.Chart, v common.Values) error
- func Save(c *chart.Chart, outDir string) (string, error)
- func SaveChartfile(filename string, cf *chart.Metadata) error
- func SaveDir(c *chart.Chart, dest string) error
- func StrictLoadChartfile(filename string) (*chart.Metadata, error)
- func ValidateMetadataName(name string) errordeprecated
- func ValidateReleaseName(name string) error
Constants ¶
const ( // ChartfileName is the default Chart file name. ChartfileName = "Chart.yaml" // ValuesfileName is the default values file name. ValuesfileName = "values.yaml" // SchemafileName is the default values schema file name. SchemafileName = "values.schema.json" // TemplatesDir is the relative directory name for templates. TemplatesDir = "templates" // ChartsDir is the relative directory name for charts dependencies. ChartsDir = "charts" // TemplatesTestsDir is the relative directory name for tests. TemplatesTestsDir = TemplatesDir + sep + "tests" // IgnorefileName is the name of the Helm ignore file. IgnorefileName = ".helmignore" // IngressFileName is the name of the example ingress file. IngressFileName = TemplatesDir + sep + "ingress.yaml" // HTTPRouteFileName is the name of the example HTTPRoute file. HTTPRouteFileName = TemplatesDir + sep + "httproute.yaml" // DeploymentName is the name of the example deployment file. DeploymentName = TemplatesDir + sep + "deployment.yaml" // ServiceName is the name of the example service file. ServiceName = TemplatesDir + sep + "service.yaml" // ServiceAccountName is the name of the example serviceaccount file. ServiceAccountName = TemplatesDir + sep + "serviceaccount.yaml" // HorizontalPodAutoscalerName is the name of the example hpa file. HorizontalPodAutoscalerName = TemplatesDir + sep + "hpa.yaml" // NotesName is the name of the example NOTES.txt file. NotesName = TemplatesDir + sep + "NOTES.txt" // HelpersName is the name of the example helpers file. HelpersName = TemplatesDir + sep + "_helpers.tpl" // TestConnectionName is the name of the example test file. TestConnectionName = TemplatesTestsDir + sep + "test-connection.yaml" )
Variables ¶
var Stderr io.Writer = os.Stderr
Stderr is an io.Writer to which error messages can be written
In Helm 4, this will be replaced. It is needed in Helm 3 to preserve API backward compatibility.
Functions ¶
func Create ¶
Create creates a new chart in a directory.
Inside of dir, this will create a directory based on the name of chartfile.Name. It will then write the Chart.yaml into this directory and create the (empty) appropriate directories.
The returned string will point to the newly created directory. It will be an absolute path, even if the provided base directory was relative.
If dir does not exist, this will return an error. If Chart.yaml or any directories cannot be created, this will return an error. In such a case, this will attempt to clean up by removing the new chart directory.
func CreateFrom ¶
CreateFrom creates a new chart, but scaffolds it from the src chart.
func ExpandFile ¶
ExpandFile expands the src file into the dest directory.
func IsCompatibleRange ¶
IsCompatibleRange compares a version to a constraint. It returns true if the version matches the constraint, and false in all other cases.
func LoadChartfile ¶
LoadChartfile loads a Chart.yaml file into a *chart.Metadata.
func ProcessDependencies ¶
ProcessDependencies checks through this chart's dependencies, processing accordingly. The service values and the custom secret values of the chart override v.
func ProcessDependenciesWithMergedValues ¶ added in v2.2.1
ProcessDependenciesWithMergedValues processes dependencies like ProcessDependencies, except that v must already contain the service values and the custom secret values.
func Save ¶
Save creates an archived chart to the given directory.
This takes an existing chart and a destination directory.
If the directory is /foo, and the chart is named bar, with version 1.0.0, this will generate /foo/bar-1.0.0.tgz.
This returns the absolute path to the chart archive file.
func SaveChartfile ¶
SaveChartfile saves the given metadata as a Chart.yaml file at the given path.
'filename' should be the complete path and filename ('foo/Chart.yaml')
func SaveDir ¶
SaveDir saves a chart as files in a directory.
This takes the chart name, and creates a new subdirectory inside of the given dest directory, writing the chart's contents to that subdirectory.
func StrictLoadChartfile ¶
StrictLoadChartfile loads a Chart.yaml into a *chart.Metadata using a strict unmarshaling
func ValidateMetadataName
deprecated
ValidateMetadataName validates the name field of a Kubernetes metadata object.
Empty strings, strings longer than 253 chars, or strings that don't match the regexp will fail.
According to the Kubernetes help text, the regular expression it uses is:
[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*
This follows the above regular expression (but requires a full string match, not partial).
The Kubernetes documentation is here, though it is not entirely correct: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
Deprecated: remove in Helm 4. Name validation now uses rules defined in pkg/lint/rules.validateMetadataNameFunc()
func ValidateReleaseName ¶
ValidateReleaseName performs checks for an entry for a Helm release name
For Helm to allow a name, it must be below a certain character count (53) and also match a regular expression.
According to the Kubernetes help text, the regular expression it uses is:
[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*
This follows the above regular expression (but requires a full string match, not partial).
The Kubernetes documentation is here, though it is not entirely correct: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
Types ¶
This section is empty.