Skip to content

Commit

Permalink
Expose ManifestReader helper functions to users
Browse files Browse the repository at this point in the history
  • Loading branch information
mortent committed May 25, 2021
1 parent a4a8232 commit 4ff5118
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/manifestreader/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ func FilterLocalConfig(objs []*unstructured.Unstructured) []*unstructured.Unstru
return filteredObjs
}

// removeAnnotations removes the specified kioutil annotations from the resource.
func removeAnnotations(n *yaml.RNode, annotations ...kioutil.AnnotationKey) error {
// RemoveAnnotations removes the specified kioutil annotations from the resource.
func RemoveAnnotations(n *yaml.RNode, annotations ...kioutil.AnnotationKey) error {
for _, a := range annotations {
err := n.PipeE(yaml.ClearAnnotation(a))
if err != nil {
Expand All @@ -148,9 +148,9 @@ func removeAnnotations(n *yaml.RNode, annotations ...kioutil.AnnotationKey) erro
return nil
}

// kyamlNodeToUnstructured take a resource represented as a kyaml RNode and
// KyamlNodeToUnstructured take a resource represented as a kyaml RNode and
// turns it into an Unstructured object.
func kyamlNodeToUnstructured(n *yaml.RNode) (*unstructured.Unstructured, error) {
func KyamlNodeToUnstructured(n *yaml.RNode) (*unstructured.Unstructured, error) {
b, err := n.MarshalJSON()
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/manifestreader/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ metadata:
for tn, tc := range testCases {
t.Run(tn, func(t *testing.T) {
node := tc.node
err := removeAnnotations(node, tc.removeAnnotations...)
err := RemoveAnnotations(node, tc.removeAnnotations...)
if !assert.NoError(t, err) {
t.FailNow()
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/manifestreader/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ func (p *PathManifestReader) Read() ([]*unstructured.Unstructured, error) {
}

for _, n := range nodes {
err = removeAnnotations(n, kioutil.IndexAnnotation)
err = RemoveAnnotations(n, kioutil.IndexAnnotation)
if err != nil {
return objs, err
}
u, err := kyamlNodeToUnstructured(n)
u, err := KyamlNodeToUnstructured(n)
if err != nil {
return objs, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/manifestreader/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func (r *StreamManifestReader) Read() ([]*unstructured.Unstructured, error) {
}

for _, n := range nodes {
err = removeAnnotations(n, kioutil.IndexAnnotation)
err = RemoveAnnotations(n, kioutil.IndexAnnotation)
if err != nil {
return objs, err
}
u, err := kyamlNodeToUnstructured(n)
u, err := KyamlNodeToUnstructured(n)
if err != nil {
return objs, err
}
Expand Down

0 comments on commit 4ff5118

Please sign in to comment.