package replacement
import "sigs.k8s.io/kustomize/api/filters/replacement"
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 ¶
Types ¶
type Filter ¶
type Filter struct { Replacements []types.Replacement `json:"replacements,omitempty" yaml:"replacements,omitempty"` }
Example¶
Code:
{
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
}
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 ¶
Filter replaces values of targets with values from sources
Source Files ¶
doc.go replacement.go
- Version
- v0.20.0 (latest)
- Published
- Jun 28, 2025
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 2 days ago –
Tools for package owners.