applier

package
v0.0.0-...-beceb34 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Deprecated: Use github.com/stolostron/applier/pkg/applier project

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applier

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

Applier structure to access kubernetes through the applier

func NewApplier

func NewApplier(
	templateReader templateprocessor.TemplateReader,
	templateProcessorOptions *templateprocessor.Options,
	client client.Client,
	owner metav1.Object,
	scheme *runtime.Scheme,
	merger Merger,
	applierOptions *Options,
) (*Applier, error)

NewApplier creates a new client to access kubernetes through the applier. applier: An applier client: The client-go client to use when applying the resources. owner: The object owner for the setControllerReference, the reference is not if nil. scheme: The object scheme for the setControllerReference, the reference is not if nil. merger: The function implementing the way how the resources must be merged

func (*Applier) Create

func (a *Applier) Create(
	u *unstructured.Unstructured,
) error

Create creates an unstructured object.

func (*Applier) CreateInPath

func (a *Applier) CreateInPath(
	path string,
	excluded []string,
	recursive bool,
	values interface{},
) error

CreateInPath creates the assets found in the path and subpath if recursive is set to true. path: The path were the yaml to apply is located excludes: The list of yamls to exclude recursive: If true all yamls in the path directory and sub-directories will be applied it excludes the assets named in the excluded array it sets the Controller reference if owner and scheme are not nil

func (*Applier) CreateOrUpdate

func (a *Applier) CreateOrUpdate(
	u *unstructured.Unstructured,
) error

CreateOrUpdate creates or updates an unstructured object. It will returns an error if it failed and also if it needs to update the object and the applier.Merger is not defined.

func (*Applier) CreateOrUpdateInPath

func (a *Applier) CreateOrUpdateInPath(
	path string,
	excluded []string,
	recursive bool,
	values interface{},
) error

CreateOrUpdateInPath creates or updates the assets found in the path and subpath if recursive is set to true. path: The path were the yaml to apply is located excludes: The list of yamls to exclude recursive: If true all yamls in the path directory and sub-directories will be applied it excludes the assets named in the excluded array it sets the Controller reference if owner and scheme are not nil

func (*Applier) CreateOrUpdateResource

func (a *Applier) CreateOrUpdateResource(
	assetName string,
	values interface{},
) error

CreateorUpdateAsset create or updates an asset

func (*Applier) CreateOrUpdateResources

func (a *Applier) CreateOrUpdateResources(
	assetNames []string,
	values interface{},
) error

CreateOrUpdateResources creates or update resources given an array of resources name

func (*Applier) CreateOrUpdates

func (a *Applier) CreateOrUpdates(
	us []*unstructured.Unstructured,
) error

CreateOrUpdates an array of unstructured.Unstructured

func (*Applier) CreateResource

func (a *Applier) CreateResource(
	assetName string,
	values interface{},
) error

CreateResource create an asset

func (*Applier) CreateResources

func (a *Applier) CreateResources(
	assetNames []string,
	values interface{},
) error

CreateResources creates resources given an array of resources name

func (*Applier) Creates

func (a *Applier) Creates(
	us []*unstructured.Unstructured,
) error

Creates create resources from an array of unstructured.Unstructured

func (*Applier) Delete

func (a *Applier) Delete(
	u *unstructured.Unstructured,
) error

Delete deletes an unstructured object.

func (*Applier) DeleteInPath

func (a *Applier) DeleteInPath(
	path string,
	excluded []string,
	recursive bool,
	values interface{},
) error

DeleteInPath delete the assets found in the path and subpath if recursive is set to true. path: The path were the yaml to apply is located excludes: The list of yamls to exclude recursive: If true all yamls in the path directory and sub-directories will be applied it excludes the assets named in the excluded array it sets the Controller reference if owner and scheme are not nil

func (*Applier) DeleteResource

func (a *Applier) DeleteResource(
	assetName string,
	values interface{},
) error

DeleteResource delete an resource

func (*Applier) DeleteResources

func (a *Applier) DeleteResources(
	assetNames []string,
	values interface{},
) error

DeleteResources deletes resources given an array of resources name

func (*Applier) Deletes

func (a *Applier) Deletes(
	us []*unstructured.Unstructured,
) error

Delete deletes resources from an array of unstructured.Unstructured

func (*Applier) Update

func (a *Applier) Update(
	u *unstructured.Unstructured,
) error

Update updates an unstructured object. It will returns an error if it failed and also if it needs to update the object and the applier.Merger is not defined.

func (*Applier) UpdateInPath

func (a *Applier) UpdateInPath(
	path string,
	excluded []string,
	recursive bool,
	values interface{},
) error

UpdateInPath creates or updates the assets found in the path and subpath if recursive is set to true. path: The path were the yaml to apply is located excludes: The list of yamls to exclude recursive: If true all yamls in the path directory and sub-directories will be applied it excludes the assets named in the excluded array it sets the Controller reference if owner and scheme are not nil

func (*Applier) UpdateResource

func (a *Applier) UpdateResource(
	assetName string,
	values interface{},
) error

UpdateResource updates an asset

func (*Applier) UpdateResources

func (a *Applier) UpdateResources(
	assetNames []string,
	values interface{},
) error

UpdateResources update resources given an array of resources name

func (*Applier) Updates

func (a *Applier) Updates(
	us []*unstructured.Unstructured,
) error

Updates updates resources from an array of unstructured.Unstructured

type Merger

type Merger func(current,
	new *unstructured.Unstructured,
) (
	future *unstructured.Unstructured,
	update bool,
)

Merger merges the `current` and the `want` resources into one resource which will be use for to update. If `update` is true than the update will be executed.

var DefaultKubernetesMerger Merger = func(current,
	new *unstructured.Unstructured,
) (
	future *unstructured.Unstructured,
	update bool,
) {
	for _, r := range rootAttributes {
		if newValue, ok := new.Object[r]; ok {
			if !reflect.DeepEqual(newValue, current.Object[r]) {
				update = true
				current.Object[r] = newValue
			}
		} else {
			if _, ok := current.Object[r]; ok {
				current.Object[r] = nil
			}
		}
	}
	return current, update
}

DefaultKubernetesMerger merges kubernetes runtime.Object It merges the spec, rules, roleRef, subjects root attribute of a runtime.Object For example a CLusterRoleBinding has a subjects and roleRef fields and so the old subjects and roleRef fields from the ClusterRoleBinding will be replaced by the new values.

type Options

type Options struct {
	//The option used when a resource is created
	ClientCreateOption []client.CreateOption
	//The option used when a resource is updated
	ClientUpdateOption []client.UpdateOption
	//The option used when a resource is deleted
	ClientDeleteOption []client.DeleteOption
	//Defines the parameters for retrying a transaction if it fails.
	Backoff *wait.Backoff
	//If true, the client will be set for dryrun
	DryRun bool
	//If true, the finalizers will be removed after deletion.
	ForceDelete bool
}

Options defines for the available options for the applier

Jump to

Keyboard shortcuts

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