Documentation ¶
Overview ¶
Package imagetag contains two kio.Filter implementations to cover the functionality of the kustomize imagetag transformer.
Filter updates fields based on a FieldSpec and an ImageTag.
LegacyFilter doesn't use a FieldSpec, and instead only updates image references if the field is name image and it is underneath a field called either containers or initContainers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct { // imageTag is the tag we want to apply to the inputs // The name of the image is used as a key, and other fields // can specify a new name, tag, etc. ImageTag types.Image `json:"imageTag,omitempty" yaml:"imageTag,omitempty"` // FsSlice contains the FieldSpecs to locate an image field, // e.g. Path: "spec/myContainers[]/image" FsSlice types.FsSlice `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"` }
Filter modifies an "image tag", the value used to specify the name, tag, version digest etc. of (docker) container images used by a pod template.
Example ¶
err := kio.Pipeline{ Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(` apiVersion: example.com/v1 kind: Foo metadata: name: instance spec: containers: - name: FooBar image: nginx --- apiVersion: example.com/v1 kind: Bar metadata: name: instance spec: containers: - name: BarFoo image: nginx:1.2.1 `)}}, Filters: []kio.Filter{Filter{ ImageTag: types.Image{ Name: "nginx", NewName: "apache", Digest: "12345", }, FsSlice: []types.FieldSpec{ { Path: "spec/containers[]/image", }, }, }}, Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}}, }.Execute() if err != nil { log.Fatal(err) }
Output: apiVersion: example.com/v1 kind: Foo metadata: name: instance spec: containers: - name: FooBar image: apache@12345 --- apiVersion: example.com/v1 kind: Bar metadata: name: instance spec: containers: - name: BarFoo image: apache@12345
type LegacyFilter ¶
type LegacyFilter struct {
ImageTag types.Image `json:"imageTag,omitempty" yaml:"imageTag,omitempty"`
}
LegacyFilter is an implementation of the kio.Filter interface that scans through the provided kyaml data structure and updates any values of any image fields that is inside a sequence under a field called either containers or initContainers. The field is only update if it has a value that matches and image reference and the name of the image is a match with the provided ImageTag.
Example ¶
err := kio.Pipeline{ Inputs: []kio.Reader{&kio.ByteReader{Reader: bytes.NewBufferString(` apiVersion: example.com/v1 kind: Foo metadata: name: instance spec: containers: - name: FooBar image: nginx --- apiVersion: example.com/v1 kind: Bar metadata: name: instance spec: containers: - name: BarFoo image: nginx:1.2.1 `)}}, Filters: []kio.Filter{LegacyFilter{ ImageTag: types.Image{ Name: "nginx", NewName: "apache", Digest: "12345", }, }}, Outputs: []kio.Writer{kio.ByteWriter{Writer: os.Stdout}}, }.Execute() if err != nil { log.Fatal(err) }
Output: apiVersion: example.com/v1 kind: Foo metadata: name: instance spec: containers: - name: FooBar image: apache@12345 --- apiVersion: example.com/v1 kind: Bar metadata: name: instance spec: containers: - name: BarFoo image: apache@12345