Documentation ¶
Index ¶
- Constants
- func CheckKnativeInstallation() (isInstalled bool, isOurs bool, err error)
- func GetHelmArchive(chartArchiveUri string) (*chart.Chart, error)
- func GetValuesFromFile(helmChart *chart.Chart, fileName string) (*chart.Config, error)
- func InstallManifest(manifest []byte, isDryRun bool) error
- func Kubectl(stdin io.Reader, args ...string) error
- func RenderChart(helmChart *chart.Chart, overrideValues *chart.Config, ...) ([]byte, error)
- func WaitForCrdsToBeRegistered(crds []string, timeout, interval time.Duration) error
- type ManifestFilterFunc
Constants ¶
const ( YamlDocumentSeparator = "\n---\n" CrdKindName = "CustomResourceDefinition" NotesFileName = "NOTES.txt" )
Variables ¶
This section is empty.
Functions ¶
func GetHelmArchive ¶
Returns the Helm chart archive located at the given URI (can be either an http(s) address or a file path)
func GetValuesFromFile ¶
Searches for the value file with the given name in the chart and returns its raw content. NOTE: this also sets the namespace.create attribute to 'true'.
func InstallManifest ¶
noinspection GoNameStartsWithPackageName
func RenderChart ¶
func RenderChart(helmChart *chart.Chart, overrideValues *chart.Config, renderOptions renderutil.Options, filterFunctions ...ManifestFilterFunc) ([]byte, error)
Renders the content of the given Helm chart archive:
- helmChart: the Gloo helm chart archive
- overrideValues: value to override the chart defaults. NOTE: passing `nil` means "ignore the chart's default values"!
- renderOptions: options to be used in the render
- filterFunctions: a collection of functions that can be used to filter and transform the contents of the manifest. Will be applied in the given order.
Types ¶
type ManifestFilterFunc ¶
This type represents a function that can be used to filter and transform a list of manifests. It returns three values:
- skip: if true, the input manifest will be excluded from the output
- content: if skip is false, this value will be included in the output manifest
- err: if != nil, the whole manifest retrieval operation will fail
var ExcludeCrds ManifestFilterFunc = func(input []manifest.Manifest) (output []manifest.Manifest, err error) { for _, man := range input { nonCrdDocs := make([]string, 0) for _, doc := range strings.Split(man.Content, "---") { // We need to define this ourselves, because if we unmarshal into `apiextensions.CustomResourceDefinition` // we don't get the ObjectMeta (in the yaml they are nested under `metadata`, but the k8s struct has // them as top level fields...) var resource struct { Metadata v1.ObjectMeta v1.TypeMeta } if err := yaml.Unmarshal([]byte(doc), &resource); err != nil { return nil, errors.Wrapf(err, "parsing resource: %s", doc) } if resource.TypeMeta.Kind != CrdKindName { nonCrdDocs = append(nonCrdDocs, doc) } } output = append(output, manifest.Manifest{ Name: man.Name, Head: man.Head, Content: strings.Join(nonCrdDocs, YamlDocumentSeparator), }) } return }
Filters out any CRD from each manifest
var ExcludeEmptyManifests ManifestFilterFunc = func(input []manifest.Manifest) ([]manifest.Manifest, error) { var output []manifest.Manifest for _, manifest := range input { if !isEmptyManifest(manifest.Content) { output = append(output, manifest) } } return output, nil }
Returns only non-empty manifests
var ExcludeNotes ManifestFilterFunc = func(input []manifest.Manifest) (output []manifest.Manifest, err error) { for _, man := range input { if strings.HasSuffix(man.Name, NotesFileName) { continue } output = append(output, man) } return }
Filters out NOTES.txt files
func GetKnativeResourceFilterFunction ¶
func GetKnativeResourceFilterFunction() (ManifestFilterFunc, error)
If this is not a knative deployment, skipKnativeInstall might still evaluate to true, but in that case Helm will filter out all the knative resources during template rendering.