Skip to content

Commit bf9d255

Browse files
authored
Move delete-annos fn from contrib (#1231)
* Move delete-annos fn from contrib Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> * Remove delete-anno from contrib Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> * Update expected diff Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> * Remove invalid emails tag Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech> --------- Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
1 parent c63df8e commit bf9d255

20 files changed

Lines changed: 87 additions & 22 deletions

File tree

contrib/functions/go/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ GOBIN := $(shell go env GOPATH)/bin
2020

2121
# Edit this list to contain all go functions
2222
FUNCTIONS := \
23-
annotate-apply-time-mutations \
24-
delete-annotations
23+
annotate-apply-time-mutations
2524

2625
# Targets for running all function tests
2726
FUNCTION_TESTS := $(patsubst %,%-TEST,$(FUNCTIONS))
@@ -117,3 +116,4 @@ func-push:
117116

118117
docs-generate:
119118
$(GOBIN)/mdtogo $(CURRENT_FUNCTION) $(CURRENT_FUNCTION)/generated --license=none --strategy=cmdDocs
119+
find $(CURRENT_FUNCTION)/generated -name '*.go' -exec sed -i '/./,$$!d' {} +

contrib/functions/go/delete-annotations/metadata.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
testType: eval
2+
image: ghcr.io/kptdev/krm-functions-catalog/delete-annotations:latest
3+
args:
4+
annotationKeys: annotation-to-delete
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/app.yaml b/app.yaml
2+
index e6f41bf..7f0277c 100644
3+
--- a/app.yaml
4+
+++ b/app.yaml
5+
@@ -2,8 +2,6 @@ apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: the-map
9+
- annotations:
10+
- annotation-to-delete: "some_value"
11+
data:
12+
some-key: some-value
13+
---
File renamed without changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
parent_function: "delete-annotations"
3+
---
4+
# delete-annotations: Imperative Example
5+
6+
### Overview
7+
8+
This example shows how to delete annotations from the `.metadata.annotations` field
9+
on all resources by running `delete-annotations` function imperatively.
10+
11+
### Fetch the example package
12+
13+
Get the example package by running the following commands:
14+
15+
```shell
16+
$ kpt pkg get https://github.com/kptdev/krm-functions-catalog/tree/master/examples/delete-annotations-imperative
17+
```
18+
19+
### Function invocation
20+
21+
Invoke the function by running the following commands:
22+
23+
```shell
24+
$ kpt fn eval delete-annotations-imperative --image ghcr.io/kptdev/krm-functions-catalog/delete-annotations:latest -- annotationKeys=annotation-to-delete
25+
```
26+
27+
The annotation keys provided after `--` will be converted to a
28+
`ConfigMap` by kpt and used as the function configuration.
29+
30+
### Expected result
31+
32+
Check that the annotation `annotation-to-delete` has been removed from
33+
all resources where it was present.
34+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: the-map
5+
annotations:
6+
annotation-to-delete: "some_value"
7+
data:
8+
some-key: some-value
9+
---
10+
apiVersion: v1
11+
kind: Namespace
12+
metadata:
13+
name: the-namespace

contrib/examples/delete-annotations-simple/.expected/diff.patch renamed to examples/delete-annotations-simple/.expected/diff.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
diff --git a/Kptfile b/Kptfile
2-
index fee8bad..1dcb34b 100644
2+
index 779ebf6..704a02a 100644
33
--- a/Kptfile
44
+++ b/Kptfile
55
@@ -7,3 +7,19 @@ pipeline:
6-
- image: ghcr.io/kptdev/krm-functions-catalog/krm-fn-contrib/delete-annotations:latest
6+
- image: ghcr.io/kptdev/krm-functions-catalog/delete-annotations:latest
77
configMap:
88
annotationKeys: annotation-to-delete
99
+status:
@@ -13,7 +13,7 @@ index fee8bad..1dcb34b 100644
1313
+ reason: RenderSuccess
1414
+ renderStatus:
1515
+ mutationSteps:
16-
+ - image: ghcr.io/kptdev/krm-functions-catalog/krm-fn-contrib/delete-annotations:latest
16+
+ - image: ghcr.io/kptdev/krm-functions-catalog/delete-annotations:latest
1717
+ exitCode: 0
1818
+ results:
1919
+ - message: The provided annotations were deleted from 1 resource(s)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.expected

contrib/examples/delete-annotations-simple/Kptfile renamed to examples/delete-annotations-simple/Kptfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ metadata:
44
name: delete-annotations-simple
55
pipeline:
66
mutators:
7-
- image: ghcr.io/kptdev/krm-functions-catalog/krm-fn-contrib/delete-annotations:latest
7+
- image: ghcr.io/kptdev/krm-functions-catalog/delete-annotations:latest
88
configMap:
99
annotationKeys: annotation-to-delete

0 commit comments

Comments
 (0)