kustomize

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 26 Imported by: 4

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 BuildKustomization

func BuildKustomization(fs filesys.FileSystem, dirPath string) (resmap.ResMap, error)

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

func SubstituteVariables(
	ctx context.Context,
	kubeClient client.Client,
	kustomization unstructured.Unstructured,
	res *resource.Resource) (*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(kustomization unstructured.Unstructured) *Generator

NewGenerator creates a new kustomize generator

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 responsability to clean up the directory by use 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 string `json:"kind"`
	Name string `json:"name"`
}

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