kustomize

package module
v0.1.1-custom.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

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

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

func IsLocalRelativePath(path string) bool

func SecureBuild

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,
	dryRun bool) (*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. if dryRun is true, this means we should not attempt to talk to the cluster.

Types

type Action

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

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 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