resourcemodifiers

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigmapRefType                   = "configmap"
	ResourceModifierSupportedVersionV1 = "v1"
)

Variables

This section is empty.

Functions

func ApplyPatch

func ApplyPatch(patch []byte, obj *unstructured.Unstructured, log logrus.FieldLogger) error

Types

type Conditions

type Conditions struct {
	Namespaces        []string              `json:"namespaces,omitempty"`
	GroupResource     string                `json:"groupResource"`
	ResourceNameRegex string                `json:"resourceNameRegex,omitempty"`
	LabelSelector     *metav1.LabelSelector `json:"labelSelector,omitempty"`
}

func (*Conditions) Validate

func (c *Conditions) Validate() error

type JSONPatch

type JSONPatch struct {
	Operation string `json:"operation"`
	From      string `json:"from,omitempty"`
	Path      string `json:"path"`
	Value     string `json:"value,omitempty"`
}

func (*JSONPatch) ToString

func (p *JSONPatch) ToString() string

func (*JSONPatch) Validate

func (p *JSONPatch) Validate() error

type ResourceModifierRule

type ResourceModifierRule struct {
	Conditions Conditions  `json:"conditions"`
	Patches    []JSONPatch `json:"patches"`
}

func (*ResourceModifierRule) Apply

func (r *ResourceModifierRule) Apply(obj *unstructured.Unstructured, groupResource string, log logrus.FieldLogger) error

func (*ResourceModifierRule) PatchArrayToByteArray

func (r *ResourceModifierRule) PatchArrayToByteArray() ([]byte, error)

PatchArrayToByteArray converts all JsonPatch to string array with the format of jsonpatch.Patch and then convert it to byte array

func (*ResourceModifierRule) Validate

func (r *ResourceModifierRule) Validate() error

type ResourceModifiers

type ResourceModifiers struct {
	Version               string                 `json:"version"`
	ResourceModifierRules []ResourceModifierRule `json:"resourceModifierRules"`
}

func GetResourceModifiersFromConfig

func GetResourceModifiersFromConfig(cm *v1.ConfigMap) (*ResourceModifiers, error)

func (*ResourceModifiers) ApplyResourceModifierRules

func (p *ResourceModifiers) ApplyResourceModifierRules(obj *unstructured.Unstructured, groupResource string, log logrus.FieldLogger) []error

func (*ResourceModifiers) Validate

func (p *ResourceModifiers) Validate() error

Jump to

Keyboard shortcuts

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