Skip to content

Commit f74e10b

Browse files
author
Mengqi Yu
committed
Merge branch 'master' into starlark/v0.4
2 parents 5c0790c + 5e430f6 commit f74e10b

File tree

66 files changed

+1508
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1508
-106
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/resources.yaml b/resources.yaml
2+
index f8ec01d..bcc8f78 100644
3+
--- a/resources.yaml
4+
+++ b/resources.yaml
5+
@@ -3,8 +3,6 @@ kind: ConfigMap
6+
metadata:
7+
name: the-map
8+
namespace: the-namespace
9+
- annotations:
10+
- annotation-to-delete: "some_value"
11+
data:
12+
some-key: some-value
13+
---
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kpt.dev/v1
2+
kind: Kptfile
3+
metadata:
4+
name: delete-annotations-simple
5+
pipeline:
6+
mutators:
7+
- image: gcr.io/kpt-fn-contrib/delete-annotations:unstable
8+
configMap:
9+
annotationKeys: annotation-to-delete
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# delete-annotations: Simple Example
2+
3+
### Overview
4+
5+
In this example, we will see how to delete annotations on a set of resources in a package/folder
6+
7+
### Fetch the example package
8+
9+
Get the example package by running the following commands:
10+
11+
```shell
12+
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/contrib/examples/delete-annotations-simple
13+
```
14+
15+
### Function invocation
16+
17+
Invoke the function by running the following command:
18+
19+
```shell
20+
$ kpt fn render delete-annotations-simple
21+
```
22+
23+
### Expected result
24+
25+
One of the two resources i.e. `ConfigMap` in `resources.yaml` should have been mutated with the annotation `annotation-to-delete` removed from `metadata.annotations` where as there shouldn't be any changes to the second resource i.e. `Namespace` as it didn't have the supplied annotation.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: the-map
5+
namespace: the-namespace
6+
annotations:
7+
annotation-to-delete: "some_value"
8+
data:
9+
some-key: some-value
10+
---
11+
apiVersion: v1
12+
kind: Namespace
13+
metadata:
14+
name: the-namespace

contrib/examples/generate-kpt-pkg-docs-simple/.expected/exec.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

contrib/functions/go/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ GOBIN := $(shell go env GOPATH)/bin
2020
# Edit this list to contain all go functions
2121
FUNCTIONS := \
2222
annotate-apply-time-mutations \
23-
generate-kpt-pkg-docs
23+
delete-annotations
2424

2525
# Targets for running all function tests
2626
FUNCTION_TESTS := $(patsubst %,%-TEST,$(FUNCTIONS))
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# delete-annotations
2+
3+
## Overview
4+
5+
<!--mdtogo:Short-->
6+
7+
Deletes the supplied annotation keys from the resource(s).
8+
9+
<!--mdtogo-->
10+
11+
One of the use cases for this function is to help users remove annotations that are
12+
not necessary for deployment across a package. E.g. a user may add annotations to
13+
resource(s) for local processing but those annotations may not be necessary for
14+
deployment or for the functioning of the workload. This function can be used to
15+
clean up such unnecessary annotations before resources are deployed.
16+
17+
<!--mdtogo:Long-->
18+
19+
## Usage
20+
21+
You can delete multiple annotations provided as a comma separated string as part of the function config.
22+
23+
To execute imperatively:
24+
```shell
25+
$ kpt fn eval -i gcr.io/kpt-fn-contrib/delete-annotations:unstable -- annotationKeys=annotation-to-delete,another-annotation-to-delete
26+
```
27+
28+
To execute `delete-annotations` declaratively include the function in kpt package pipeline as follows:
29+
```yaml
30+
...
31+
pipeline:
32+
mutators:
33+
- image: gcr.io/kpt-fn-contrib/delete-annotations:unstable
34+
configMap:
35+
annotationKeys: annotation-to-delete,another-annotation-to-delete
36+
...
37+
```
38+
39+
### FunctionConfig
40+
41+
This function takes the annotation key names as part of the function config parameter
42+
`annotationKeys` where the key names can be provided as comma separated values as follows:
43+
44+
`annotationKeys=annotation-key-1,annotation-key-2`
45+
46+
In the previous example, the function will delete annotations `annotation-key-1` and `annotation-key-2`
47+
in all resource(s) where those annotations are present.
48+
49+
The `annotationKeys` field is a required parameter.
50+
51+
<!--mdtogo-->

contrib/functions/go/delete-annotations/generated/docs.go

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module github.com/GoogleContainerTools/kpt-functions-catalog/contrib/functions/go/delete-annotations
2+
3+
go 1.17
4+
5+
require (
6+
github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220405020624-e5817d5d2014
7+
github.com/stretchr/testify v1.7.0
8+
)
9+
10+
require (
11+
github.com/PuerkitoBio/purell v1.1.1 // indirect
12+
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
13+
github.com/davecgh/go-spew v1.1.1 // indirect
14+
github.com/go-errors/errors v1.0.1 // indirect
15+
github.com/go-logr/logr v1.2.0 // indirect
16+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
17+
github.com/go-openapi/jsonreference v0.19.3 // indirect
18+
github.com/go-openapi/swag v0.19.5 // indirect
19+
github.com/kr/text v0.2.0 // indirect
20+
github.com/mailru/easyjson v0.7.0 // indirect
21+
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
22+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
23+
github.com/pkg/errors v0.9.1 // indirect
24+
github.com/pmezard/go-difflib v1.0.0 // indirect
25+
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
26+
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
27+
golang.org/x/text v0.3.7 // indirect
28+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
29+
gopkg.in/yaml.v2 v2.4.0 // indirect
30+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
31+
k8s.io/klog/v2 v2.30.0 // indirect
32+
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
33+
sigs.k8s.io/kustomize/kyaml v0.13.3 // indirect
34+
)

0 commit comments

Comments
 (0)