yamls

package
v0.0.0-...-8540621 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPatchesToYAML

func AddPatchesToYAML(inputYAML string, patches map[string]string) (string, error)

AddPatchesToYAML takes a K8s YAML and adds the given patches using a strategic merge.

func ConcatYAMLs

func ConcatYAMLs(y1 string, y2 string) string

ConcatYAMLs concatenates two separate YAMLs.

func ExtractYAMLs

func ExtractYAMLs(yamls []*YAMLFile, extractPath string, yamlDir string, format ExtractYAMLFormat) error

ExtractYAMLs writes the generated YAMLs to a tar at the given path in the given format.

func NamespaceScopeMatcher

func NamespaceScopeMatcher(obj map[string]interface{}, resourceKind string) bool

NamespaceScopeMatcher matches the resource if the resource is contained within a namespace.

func TemplateScopeMatcher

func TemplateScopeMatcher(obj map[string]interface{}, resourceKind string) bool

TemplateScopeMatcher matches the resource definition contains a template for deploying other resources.

func TemplatizeK8sYAML

func TemplatizeK8sYAML(inputYAML string, tmplOpts []*K8sTemplateOptions) (string, error)

TemplatizeK8sYAML takes a K8s YAML and templatizes the provided fields.

Types

type ExtractYAMLFormat

type ExtractYAMLFormat int

ExtractYAMLFormat represents the types of formats we can extract YAMLs to.

const (
	// UnknownExtractYAMLFormat is an extraction format.
	UnknownExtractYAMLFormat ExtractYAMLFormat = iota
	// SingleFileExtractYAMLFormat extracts YAMLs to single file.
	SingleFileExtractYAMLFormat
	// MultiFileExtractYAMLFormat extract YAMLs into multiple files, according to type.
	MultiFileExtractYAMLFormat
)

type K8sTemplateOptions

type K8sTemplateOptions struct {
	// TemplateMatcher is a function that returns whether or not the template should be applied to the resource.
	TemplateMatcher TemplateMatchFn
	// The JSON that should be patched in, with the placeholder values.
	Patch string
	// Placeholder is the string in the YAML which should be replaced with the template value.
	Placeholder string
	// TemplateValue is the template string that should replace the placeholder.
	TemplateValue string
}

K8sTemplateOptions specifies how the templated YAML should be constructed, by specifying selectors for which resources should contain the template, how the placeholder should be patched in, and what that placeholder should be replaced with.

type TemplateMatchFn

type TemplateMatchFn func(obj map[string]interface{}, resourceKind string) bool

TemplateMatchFn is a function used to determine whether or not the given resource should have the template applied.

func GenerateContainerNameMatcherFn

func GenerateContainerNameMatcherFn(expectedName string) TemplateMatchFn

GenerateContainerNameMatcherFn creates a matcher function for matching the resource if the resource has a pod template with a container of the given name.

func GenerateResourceNameMatcherFn

func GenerateResourceNameMatcherFn(expectedName string) TemplateMatchFn

GenerateResourceNameMatcherFn creates a matcher function for matching the resource if the resource's name matches matchValue.

func GenerateServiceAccountSubjectMatcher

func GenerateServiceAccountSubjectMatcher(subjectName string) TemplateMatchFn

GenerateServiceAccountSubjectMatcher matches the resource definition containing a service account subject with the given name.

type YAMLFile

type YAMLFile struct {
	Name string
	YAML string
}

YAMLFile is a YAML associated with a name.

func ExecuteTemplatedYAMLs

func ExecuteTemplatedYAMLs(yamls []*YAMLFile, tmplValues *YAMLTmplArguments) ([]*YAMLFile, error)

ExecuteTemplatedYAMLs takes a template YAML and applies the given template values to it.

type YAMLTmplArguments

type YAMLTmplArguments struct {
	Values *map[string]interface{}
	// Release values represent special fields that are filled out by Helm.
	Release *map[string]interface{}
}

YAMLTmplArguments is a wrapper around YAMLTmplValues.

Jump to

Keyboard shortcuts

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