patchwork

package module
v0.0.0-...-5c159d4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: 0BSD Imports: 6 Imported by: 0

README

KRM Filter - Patchwork

Kustomize patching on steroids

An alternative way to patch resources using kustomize's replacement selector.

Examples

The function config is a custom resourcce of kind Patchwork.

apiVersion: bluebrown.github.io/v1alpha1
kind: Patchwork
metadata:
  name: inject-sidecar
spec:
  patches:
    - resource:
        # pre filter based on kind
        # can be a regex pattern
        kind: (Deployment|Job|CronJob)
      # look up the first match of the paths
      # further selector queries are relative to it
      lookup:
        - spec.template
        - spec.jobTemplate.spec.template
      values:
        # apply one or more patches to the given
        # paths relative to lookup
        - paths:
            - spec.containers.[name=sidecar]
          value:
            name: sidecar
            image: busybox
            command:
              - sleep
            args:
              - infinity

Run the function as standalone providing the function config and resources.

patchwork fn-config.yaml - < resources.yaml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyValue

func CopyValue(val *yaml.RNode) yaml.FilterFunc

func MatchField

func MatchField(field string, pattern string) yaml.FilterFunc

Types

type FunctionConfig

type FunctionConfig struct {
	Spec PatchSpec `json:"spec,omitempty"`
}

type Patch

type Patch struct {
	Resource Resource `json:"resource,omitempty"`
	Lookup   []string `json:"lookup,omitempty"`
	Values   []Value
}

type PatchSpec

type PatchSpec struct {
	Patches []Patch
}

type Processor

type Processor struct{}

func (*Processor) Process

func (p *Processor) Process(rl *framework.ResourceList) error

type Resource

type Resource struct {
	Kind string `json:"kind,omitempty"`
	Name string `json:"name,omitempty"`
}

type Value

type Value struct {
	Paths []string
	Value json.RawMessage
}

Directories

Path Synopsis
cmd
Code generated by "mdtogo"; DO NOT EDIT.
Code generated by "mdtogo"; DO NOT EDIT.

Jump to

Keyboard shortcuts

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