annotation

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAnnotationPrefix = "comment.kyaml.io/set."

Variables

This section is empty.

Functions

func AddCommentsToManifests

func AddCommentsToManifests(packagePath, annotationPrefix string) error

func HandleComments

func HandleComments(filter FilterWithCallback, callback func(file, field, comment string, node *yaml.RNode)) kio.Filter

func NewAddCommentsFilter

func NewAddCommentsFilter(annotationPrefix string, callback func(file, field, comment string, node *yaml.RNode)) kio.Filter

func NewStripCommentsFilter

func NewStripCommentsFilter(annotationPrefix string, callback func(file, field, comment string, node *yaml.RNode)) kio.Filter

func StripCommentsFromManifests

func StripCommentsFromManifests(packagePath, annotationPrefix string) error

Types

type AddCommentsFilter

type AddCommentsFilter struct {
	AnnotationPrefix string
	Callback         func(field, oldValue, newValue string)
}

AddCommentsFilter adds annotation values as comment to a field in the yaml document with the path defined in the annotation key. The key must be of the form "{AnnotationPrefix}{FieldPath}"

One known limitation is that comments can only be added to scalar fields (e.g. strings, integers, booleans), but not to maps and sequences.

Example input: ```yaml metadata:

annotations:
  comment.kyaml.io/set.spec.values.imageTag: '{"$imagepolicy": "flux-system:podinfo:tag"}'

spec:

values:
  imageTag: 5.0.0

```

Example output (AnnotationPrefix="comment.kyaml.io/set."): ```yaml metadata:

annotations:
  comment.kyaml.io/set.spec.values.imageTag: '{"$imagepolicy": "flux-system:podinfo:tag"}'

spec:

values:
  imageTag: 5.0.0 #{"$imagepolicy": "flux-system:podinfo:tag"}

```

func (*AddCommentsFilter) Filter

func (a *AddCommentsFilter) Filter(object *yaml.RNode) (*yaml.RNode, error)

func (*AddCommentsFilter) SetCallback

func (a *AddCommentsFilter) SetCallback(cb func(field, oldValue, newValue string))

type FilterWithCallback

type FilterWithCallback interface {
	Filter(object *yaml.RNode) (*yaml.RNode, error)
	SetCallback(cb func(field, oldValue, newValue string))
}

type StripCommentsFilter

type StripCommentsFilter struct {
	AnnotationPrefix string
	Callback         func(field, oldValue, newValue string)
}

StripCommentsFilter removes comments from fields in the yaml document as defined in the annotations. This filter is useful for cleaning up comments set by AddCommentsFilter when used in a filter pipe.

Example input: ```yaml metadata:

annotations:
  comment.kyaml.io/set.spec.values.imageTag: '{"$imagepolicy": "flux-system:podinfo:tag"}'

spec:

values:
  imageTag: 5.0.0 #{"$imagepolicy": "flux-system:podinfo:tag"}

```

Example output (AnnotationPrefix="comment.kyaml.io/set."): ```yaml metadata:

annotations:
  comment.kyaml.io/set.spec.values.imageTag: '{"$imagepolicy": "flux-system:podinfo:tag"}'

spec:

values:
  imageTag: 5.0.0

```

func (*StripCommentsFilter) Filter

func (s *StripCommentsFilter) Filter(object *yaml.RNode) (*yaml.RNode, error)

func (*StripCommentsFilter) SetCallback

func (s *StripCommentsFilter) SetCallback(cb func(field, oldValue, newValue string))

Jump to

Keyboard shortcuts

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