kustomize

package module
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 32 Imported by: 3

Documentation

Overview

Package kustomize contains generic helpers for use with kustomize-controller and flux cli.

Index

Constants

View Source
const (
	DisabledValue = "disabled"
)

Variables

This section is empty.

Functions

func Build added in v0.10.0

func Build(fs filesys.FileSystem, dirPath string) (res resmap.ResMap, err error)

Build wraps krusty.MakeKustomizer with the following settings: - load files from outside the kustomization.yaml root - disable plugins except for the builtin ones

func CleanDirectory

func CleanDirectory(dirPath string, action Action) error

CleanDirectory removes the kustomization.yaml file from the given directory.

func IsLocalRelativePath added in v0.11.0

func IsLocalRelativePath(path string) bool

func SecureBuild added in v0.10.0

func SecureBuild(root, dirPath string, allowRemoteBases bool) (res resmap.ResMap, err error)

Secure Build wraps krusty.MakeKustomizer with the following settings:

  • secure on-disk FS denying operations outside root
  • load files from outside the kustomization dir path (but not outside root)
  • disable plugins except for the builtin ones

func SubstituteVariables

func SubstituteVariables(
	ctx context.Context,
	kubeClient client.Client,
	kustomization unstructured.Unstructured,
	res *resource.Resource,
	opts ...SubstituteOption) (*resource.Resource, error)

SubstituteVariables replaces the vars with their values in the specified resource. If a resource is labeled or annotated with 'kustomize.toolkit.fluxcd.io/substitute: disabled' the substitution is skipped.

Types

type Action added in v0.0.2

type Action string

Action is the action that was taken on the kustomization file

const (
	// CreatedAction is the action that was taken when creating the kustomization file
	CreatedAction Action = "created"
	// UnchangedAction is the action that was taken when the kustomization file was unchanged
	UnchangedAction Action = "unchanged"
)

type Generator

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

Generator is a kustomize generator It is responsible for generating a kustomization.yaml file from - a directory path and a kustomization object

func NewGenerator

func NewGenerator(root string, kustomization unstructured.Unstructured) *Generator

NewGenerator creates a new kustomize generator It takes a root directory and a kustomization object If the root is empty, no enforcement of the root directory will be done when handling paths.

func NewGeneratorWithIgnore added in v1.1.0

func NewGeneratorWithIgnore(root, ignore string, kustomization unstructured.Unstructured) *Generator

NewGeneratorWithIgnore creates a new kustomize generator It takes a root directory, a kustomization object and a string of files to ignore The generator will combine the ignore files with the default ignore files i.e. .sourceignoreÒ

func (*Generator) WriteFile

func (g *Generator) WriteFile(dirPath string, opts ...SavingOptions) (Action, error)

WriteFile generates a kustomization.yaml in the given directory if it does not exist. It apply the flux kustomize resources to the kustomization.yaml and then write the updated kustomization.yaml to the directory. It returns an action that indicates if the kustomization.yaml was created or not. It is the caller's responsability to clean up the directory by using the provided function CleanDirectory. example: err := CleanDirectory(dirPath, action)

if err != nil {
	log.Fatal(err)
}

type SavingOptions

type SavingOptions func(dirPath, file string, action Action) error

SavingOptions is a function that can be used to apply saving options to a kustomization

func WithSaveOriginalKustomization

func WithSaveOriginalKustomization() SavingOptions

WithSaveOriginalKustomization will save the original kustomization file

type SubstituteOption added in v1.9.0

type SubstituteOption func(a *SubstituteOptions)

func SubstituteWithDryRun added in v1.9.0

func SubstituteWithDryRun(dryRun bool) SubstituteOption

SubstituteWithDryRun sets the dryRun option. When dryRun is true, the substitution process will not attempt to talk to the cluster.

func SubstituteWithStrict added in v1.9.0

func SubstituteWithStrict(strict bool) SubstituteOption

SubstituteWithStrict sets the strict option. When strict is true, the substitution process will fail if a var without a default value is declared in files but is missing from the input vars.

type SubstituteOptions added in v1.9.0

type SubstituteOptions struct {
	DryRun bool
	Strict bool
}

SubstituteOptions defines the options for the variable substitutions operation.

type SubstituteReference

type SubstituteReference struct {
	// Kind of the values referent, valid values are ('Secret', 'ConfigMap').
	Kind string `json:"kind"`

	// Name of the values referent. Should reside in the same namespace as the
	// referring resource.
	Name string `json:"name"`

	// Optional indicates whether the referenced resource must exist, or whether to
	// tolerate its absence. If true and the referenced resource is absent, proceed
	// as if the resource was present but empty, without any variables defined.
	Optional bool `json:"optional,omitempty"`
}

SubstituteReference contains a reference to a resource containing the variables name and value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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