Skip to content

Commit 2f61c91

Browse files
authored
Fix several issues on set-labels (#928)
1 parent 6054d61 commit 2f61c91

File tree

44 files changed

+464
-1403
lines changed

Some content is hidden

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

44 files changed

+464
-1403
lines changed

examples/set-labels-full-coverage/.expected/diff.patch

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/resources.yaml b/resources.yaml
2-
index 6a06662..62df835 100644
2+
index c70e1f9..62df835 100644
33
--- a/resources.yaml
44
+++ b/resources.yaml
55
@@ -2,56 +2,84 @@ apiVersion: v1
@@ -174,7 +174,7 @@ index 6a06662..62df835 100644
174174
spec:
175175
selector:
176176
matchLabels:
177-
@@ -117,12 +172,14 @@ spec:
177+
@@ -117,7 +172,9 @@ spec:
178178
template:
179179
metadata:
180180
labels:
@@ -185,12 +185,6 @@ index 6a06662..62df835 100644
185185
spec:
186186
containers:
187187
- name: pi
188-
image: perl:5.34
189-
- command: ["perl", "-Mbignum=bpi", "-wle", "'print bpi(2000)'"]
190-
+ command: ["perl", "-Mbignum=bpi", "-wle", "'print bpi(2000)'"]
191-
restartPolicy: Never
192-
backoffLimit: 4
193-
---
194188
@@ -130,12 +187,19 @@ apiVersion: batch/v1
195189
kind: CronJob
196190
metadata:

examples/set-labels-full-coverage/resources.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ spec:
122122
containers:
123123
- name: pi
124124
image: perl:5.34
125-
command: ["perl", "-Mbignum=bpi", "-wle", "'print bpi(2000)'"]
125+
command: ["perl", "-Mbignum=bpi", "-wle", "'print bpi(2000)'"]
126126
restartPolicy: Never
127127
backoffLimit: 4
128128
---

functions/go/set-labels/go.mod

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,32 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/set-la
22

33
go 1.18
44

5-
require (
6-
github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220723081830-33aee7fe8a2e
7-
github.com/stretchr/testify v1.7.1
8-
)
5+
require github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20221014182208-8e78fe927b37
96

107
require (
11-
github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20220720212527-133180134b93 // indirect
12-
github.com/PuerkitoBio/purell v1.1.1 // indirect
13-
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
8+
github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20221014182208-8e78fe927b37 // indirect
149
github.com/davecgh/go-spew v1.1.1 // indirect
1510
github.com/go-errors/errors v1.4.2 // indirect
16-
github.com/go-logr/logr v1.2.0 // indirect
11+
github.com/go-logr/logr v1.2.3 // indirect
1712
github.com/go-openapi/jsonpointer v0.19.5 // indirect
18-
github.com/go-openapi/jsonreference v0.19.6 // indirect
19-
github.com/go-openapi/swag v0.21.1 // indirect
13+
github.com/go-openapi/jsonreference v0.20.0 // indirect
14+
github.com/go-openapi/swag v0.22.3 // indirect
15+
github.com/gogo/protobuf v1.3.2 // indirect
2016
github.com/golang/protobuf v1.5.2 // indirect
21-
github.com/google/gnostic v0.5.7-v3refs // indirect
17+
github.com/google/gnostic v0.6.9 // indirect
18+
github.com/google/go-cmp v0.5.9 // indirect
19+
github.com/google/gofuzz v1.2.0 // indirect
2220
github.com/josharian/intern v1.0.0 // indirect
23-
github.com/kr/pretty v0.2.1 // indirect
2421
github.com/mailru/easyjson v0.7.7 // indirect
2522
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
26-
github.com/pkg/errors v0.9.1 // indirect
27-
github.com/pmezard/go-difflib v1.0.0 // indirect
23+
github.com/stretchr/objx v0.4.0 // indirect
2824
github.com/xlab/treeprint v1.1.0 // indirect
29-
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
30-
golang.org/x/text v0.3.7 // indirect
31-
google.golang.org/protobuf v1.28.0 // indirect
25+
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 // indirect
26+
google.golang.org/protobuf v1.28.1 // indirect
3227
gopkg.in/yaml.v2 v2.4.0 // indirect
33-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
34-
k8s.io/klog/v2 v2.60.1 // indirect
35-
k8s.io/kube-openapi v0.0.0-20220401212409-b28bf2818661 // indirect
36-
sigs.k8s.io/kustomize/kyaml v0.13.7-0.20220418212550-9d5491c2e20c // indirect
28+
gopkg.in/yaml.v3 v3.0.1 // indirect
29+
k8s.io/apimachinery v0.25.3 // indirect
30+
k8s.io/klog/v2 v2.80.1 // indirect
31+
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
32+
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
3733
)

functions/go/set-labels/go.sum

Lines changed: 55 additions & 504 deletions
Large diffs are not rendered by default.

functions/go/set-labels/run.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@
1717
package main
1818

1919
import (
20-
"github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/set-labels/transformer"
20+
"context"
21+
2122
"github.com/GoogleContainerTools/kpt-functions-sdk/go/fn"
2223
)
2324

25+
func NewTransformer() fn.ResourceListProcessor {
26+
return fn.WithContext(fn.Context{Context: context.Background()}, &SetLabels{})
27+
}
28+
2429
func run() error {
25-
return fn.AsMain(fn.ResourceListProcessorFunc(transformer.SetLabels))
30+
return fn.AsMain(NewTransformer())
2631
}

functions/go/set-labels/run_js.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"fmt"
2121
"syscall/js"
2222

23-
"github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/set-labels/transformer"
2423
"github.com/GoogleContainerTools/kpt-functions-sdk/go/fn"
2524
)
2625

@@ -34,7 +33,8 @@ func run() error {
3433
}
3534

3635
func transformLabels(input []byte) ([]byte, error) {
37-
return fn.Run(fn.ResourceListProcessorFunc(transformer.SetLabels), []byte(input))
36+
runner := fn.WithContext(fn.Context{Context: nil}, &SetLabels{})
37+
return fn.Run(runner, []byte(input))
3838
}
3939

4040
func resourceListProcessorWrapper() js.Func {

0 commit comments

Comments
 (0)