replacement

package
v0.8.12-0...-8b0f5fa Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package replacement contains a kio.Filter implementation of the kustomize replacement transformer (accepts sources and looks for targets to replace their values with values from the sources).

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Replacements []types.Replacement `json:"replacements,omitempty" yaml:"replacements,omitempty"`
}
Example
f := Filter{}
err := yaml.Unmarshal([]byte(`
replacements:
- source:
    kind: Foo2
    fieldPath: spec.replicas
  targets:
  - select:
      kind: Foo1
    fieldPaths: 
    - spec.replicas`), &f)
if err != nil {
	log.Fatal(err)
}

err = kio.Pipeline{
	Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(`
apiVersion: example.com/v1
kind: Foo1
metadata:
  name: instance
spec:
  replicas: 3
---
apiVersion: example.com/v1
kind: Foo2
metadata:
  name: instance
spec:
  replicas: 99
`)}},
	Filters: []kio.Filter{f},
	Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}},
}.Execute()
if err != nil {
	log.Fatal(err)
}
Output:

apiVersion: example.com/v1
kind: Foo1
metadata:
  name: instance
spec:
  replicas: 99
---
apiVersion: example.com/v1
kind: Foo2
metadata:
  name: instance
spec:
  replicas: 99

func (Filter) Filter

func (f Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error)

Filter replaces values of targets with values from sources

Jump to

Keyboard shortcuts

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