manifest

package
v0.0.0-...-273c865 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0 Imports: 36 Imported by: 70

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteTemplate

func ExecuteTemplate(tpl string, data map[string]interface{}) (string, error)

ExecuteTemplate instantiates the given template with data

func ExecuteTemplates

func ExecuteTemplates(ctx context.Context, path, suffix string, images map[string]string, data map[string]interface{}) (map[string]string, error)

ExecuteTemplates executes a set of templates found at path, filtering on suffix. Executed into memory and returned.

func ExecuteYAML

func ExecuteYAML(ctx context.Context, fsys fs.FS, images map[string]string, cfg map[string]interface{}) (map[string]string, error)

ExecuteYAML process the templates found in files named "*.yaml" and return the f.

func ImagesFromFS

func ImagesFromFS(ctx context.Context, fsys fs.FS) []string

func OutputYAML

func OutputYAML(out io.Writer, files map[string]string)

OutputYAML writes out each file contents to out after removing comments and blank lines. This also adds a YAML file separator "---" between each file. Files is a map of "filename" to "file contents".

func Parse

func Parse(pathname string, recursive bool) ([]unstructured.Unstructured, error)

Parse parses YAML files into Unstructured objects.

It supports 5 cases today:

  1. pathname = path to a file --> parses that file.
  2. pathname = path to a directory, recursive = false --> parses all files in that directory.
  3. pathname = path to a directory, recursive = true --> parses all files in that directory and it's descendants
  4. pathname = url --> fetches the contents of that URL and parses them as YAML.
  5. pathname = combination of all previous cases, the string can contain multiple records (file, directory or url) separated by comma

func ParseTemplates

func ParseTemplates(path string, images map[string]string, cfg map[string]interface{}) (string, error)

ParseTemplates walks through all the template yaml file in the given directory and produces instantiated yaml file in a temporary directory. Returns the name of the temporary directory. Deprecated: Use ParseTemplatesFS.

func ParseTemplatesFS

func ParseTemplatesFS(ctx context.Context, fsys fs.FS, images map[string]string, cfg map[string]interface{}) (string, error)

ParseTemplatesFS walks through all the template yaml file in the given FS and produces instantiated yaml file in a temporary directory. Returns the name of the temporary directory.

func UpdateChanged

func UpdateChanged(src, tgt map[string]interface{}) bool

We need to preserve the top-level target keys, specifically 'metadata.resourceVersion', 'spec.clusterIP', and any existing entries in a ConfigMap's 'data' field. So we only overwrite fields set in our src resource.

func WithIstioPodAnnotations

func WithIstioPodAnnotations(cfg map[string]interface{})

Types

type CfgFn

type CfgFn func(map[string]interface{})

CfgFn is the function signature of configuration mutation options.

func PodSecurityCfgFn

func PodSecurityCfgFn(ctx context.Context, t feature.T) CfgFn

PodSecurityCfgFn returns a function for configuring security context for Pod, depending on security settings of the enclosing namespace.

func WithAnnotations

func WithAnnotations(annotations map[string]interface{}) CfgFn

WithAnnotations returns a function for configuring annototations of the resource

func WithLabels

func WithLabels(labels map[string]string) CfgFn

WithLabels returns a function for configuring labels of the resource

func WithPodAnnotations

func WithPodAnnotations(additional map[string]interface{}) CfgFn

WithPodAnnotations appends pod annotations (usually used by types where pod template is embedded)

type Manifest

type Manifest interface {
	// Either updates or creates all resources in the manifest
	ApplyAll() error
	// Updates or creates a particular resource
	Apply(*unstructured.Unstructured) error
	// Deletes all resources in the manifest
	DeleteAll() error
	// Deletes a particular resource
	Delete(spec *unstructured.Unstructured) error
	// Returns a deep copy of the matching resource read from the file
	Find(apiVersion string, kind string, name string) *unstructured.Unstructured
	// Returns the resource fetched from the api server, nil if not found
	Get(spec *unstructured.Unstructured) (*unstructured.Unstructured, error)
	// Returns a deep copy of all resources in the manifest
	DeepCopyResources() []unstructured.Unstructured
	// ResourceNames is a convenient list of all the resource names in the manifest
	ResourceNames() []string
	// References is a convenient list of all resources in the manifest as object references
	References() []corev1.ObjectReference
}

func InstallYamlFS

func InstallYamlFS(ctx context.Context, fsys fs.FS, base map[string]interface{}) (Manifest, error)

func NewYamlManifest

func NewYamlManifest(ctx context.Context, pathname string, recursive bool, client dynamic.Interface) (Manifest, error)

type YamlManifest

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

func (*YamlManifest) Apply

func (f *YamlManifest) Apply(spec *unstructured.Unstructured) error

func (*YamlManifest) ApplyAll

func (f *YamlManifest) ApplyAll() error

func (*YamlManifest) DeepCopyResources

func (f *YamlManifest) DeepCopyResources() []unstructured.Unstructured

func (*YamlManifest) Delete

func (f *YamlManifest) Delete(spec *unstructured.Unstructured) error

func (*YamlManifest) DeleteAll

func (f *YamlManifest) DeleteAll() error

func (*YamlManifest) Find

func (f *YamlManifest) Find(apiVersion string, kind string, name string) *unstructured.Unstructured

func (*YamlManifest) Get

func (*YamlManifest) References

func (f *YamlManifest) References() []corev1.ObjectReference

func (*YamlManifest) ResourceNames

func (f *YamlManifest) ResourceNames() []string

Jump to

Keyboard shortcuts

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