From cf3a4962d177341513b88457b3a16204ebd4e76d Mon Sep 17 00:00:00 2001 From: John Belamaric Date: Thu, 14 Sep 2023 22:27:26 +0000 Subject: [PATCH] Basic config map generator function (#347) --- krm-functions/gen-configmap-fn/.gitignore | 1 + krm-functions/gen-configmap-fn/Dockerfile | 25 ++ krm-functions/gen-configmap-fn/Makefile | 20 ++ krm-functions/gen-configmap-fn/README.md | 73 +++++ .../gen-configmap-fn/fn/gen_configmap.go | 135 ++++++++++ .../gen-configmap-fn/fn/gen_configmap_test.go | 80 ++++++ .../gen-configmap-fn/fn/golden_test.go | 32 +++ .../fn/testdata/empty/_expected.yaml | 14 + .../fn/testdata/empty/_fnconfig.yaml | 4 + .../fn/testdata/empty/resources.yaml | 0 .../fn/testdata/gotmpl/_expected.yaml | 32 +++ .../fn/testdata/gotmpl/_fnconfig.yaml | 17 ++ .../fn/testdata/gotmpl/resources.yaml | 0 .../fn/testdata/literal/_expected.yaml | 32 +++ .../fn/testdata/literal/_fnconfig.yaml | 16 ++ .../fn/testdata/literal/resources.yaml | 0 .../fn/testdata/meta-only/_expected.yaml | 22 ++ .../fn/testdata/meta-only/_fnconfig.yaml | 9 + .../fn/testdata/meta-only/resources.yaml | 0 .../fn/testdata/mixed/_expected.yaml | 35 +++ .../fn/testdata/mixed/_fnconfig.yaml | 20 ++ .../fn/testdata/mixed/resources.yaml | 0 krm-functions/gen-configmap-fn/go.mod | 49 ++++ krm-functions/gen-configmap-fn/go.sum | 249 ++++++++++++++++++ krm-functions/gen-configmap-fn/main.go | 15 ++ 25 files changed, 880 insertions(+) create mode 100644 krm-functions/gen-configmap-fn/.gitignore create mode 100644 krm-functions/gen-configmap-fn/Dockerfile create mode 100644 krm-functions/gen-configmap-fn/Makefile create mode 100644 krm-functions/gen-configmap-fn/README.md create mode 100644 krm-functions/gen-configmap-fn/fn/gen_configmap.go create mode 100644 krm-functions/gen-configmap-fn/fn/gen_configmap_test.go create mode 100644 krm-functions/gen-configmap-fn/fn/golden_test.go create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/empty/_expected.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/empty/_fnconfig.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/empty/resources.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/gotmpl/_expected.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/gotmpl/_fnconfig.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/gotmpl/resources.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/literal/_expected.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/literal/_fnconfig.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/literal/resources.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/meta-only/_expected.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/meta-only/_fnconfig.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/meta-only/resources.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/mixed/_expected.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/mixed/_fnconfig.yaml create mode 100644 krm-functions/gen-configmap-fn/fn/testdata/mixed/resources.yaml create mode 100644 krm-functions/gen-configmap-fn/go.mod create mode 100644 krm-functions/gen-configmap-fn/go.sum create mode 100644 krm-functions/gen-configmap-fn/main.go diff --git a/krm-functions/gen-configmap-fn/.gitignore b/krm-functions/gen-configmap-fn/.gitignore new file mode 100644 index 00000000..f4970f46 --- /dev/null +++ b/krm-functions/gen-configmap-fn/.gitignore @@ -0,0 +1 @@ +_actual_output.yaml diff --git a/krm-functions/gen-configmap-fn/Dockerfile b/krm-functions/gen-configmap-fn/Dockerfile new file mode 100644 index 00000000..e9f55093 --- /dev/null +++ b/krm-functions/gen-configmap-fn/Dockerfile @@ -0,0 +1,25 @@ +# Copyright 2023 The Nephio Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM golang:1.20-alpine +ENV CGO_ENABLED=0 +WORKDIR /go/src/ +COPY krm-functions/ krm-functions/ +WORKDIR /go/src/krm-functions/gen-configmap-fn +RUN go install +RUN go build -o /usr/local/bin/function ./ + +FROM gcr.io/distroless/static:latest +COPY --from=0 /usr/local/bin/function /usr/local/bin/function +ENTRYPOINT ["function"] diff --git a/krm-functions/gen-configmap-fn/Makefile b/krm-functions/gen-configmap-fn/Makefile new file mode 100644 index 00000000..1e81dc48 --- /dev/null +++ b/krm-functions/gen-configmap-fn/Makefile @@ -0,0 +1,20 @@ +IMAGE_TAG ?= latest +REGISTRY ?= docker.io/nephio +IMAGE_NAME ?= gen-configmap-fn +IMG ?= $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) + +# This includes the following targets: +# test, unit, unit-clean, +# gosec, lint, +# fmt, vet +include ../../default-go.mk + +# This includes the following targets: +# docker-build, docker-push +include ../../default-docker.mk + +# This includes the 'help' target that prints out all targets with their descriptions organized by categories +include ../../default-help.mk + +.PHONY: all +all: fmt test docker-build docker-push diff --git a/krm-functions/gen-configmap-fn/README.md b/krm-functions/gen-configmap-fn/README.md new file mode 100644 index 00000000..ecf23f93 --- /dev/null +++ b/krm-functions/gen-configmap-fn/README.md @@ -0,0 +1,73 @@ +# gen-configmap-fn + +## Overview + + + +This function is a simple ConfigMap generator. + + + +Application config is often captured in ConfigMaps, but it is difficult to edit +the contents of the ConfigMap with KRM functions. This allows function inputs to +be used to generate ConfigMaps, and those inputs can be more easily edited than +the raw ConfigMap data values. + + + +## Usage + +To use this function, define a GenConfigMap resource for each ConfigMap you want +to generate. It can be used declaratively or imperatively, but it does require +the GenConfigMap Kind; you cannot run it using a simple ConfigMap for inputs. + +When run, it will create or overwrite a ConfigMap, and generate `data` field +entries for each of the listed values in the function config. + +### FunctionConfig + +```yaml +apiVersion: fn.kpt.dev/v1alpha1 +kind: GenConfigMap +metadata: + name: my-generator +configMapMetadata: + name: my-configmap + labels: + foo: bar +params: + hostname: foo.example.com + port: 8992 + scheme: https + region: us-east1 +data: +- type: literal + key: hello + value: there +- type: gotmpl + key: dburl + value: "{{.scheme}}://{{.hostname}}:{{.port}}/{{.region}}/db" +``` + +The function config above will generate the following ConfigMap: + +```yaml +kind: ConfigMap +metadata: + name: my-configmap + labels: + foo: bar +data: + dburl: https://foo.example.com:8992/us-east1/db + hello: there +``` + +If `configMapMetadata.name` is not defined, the generated ConfigMap will use the +name of the GenConfigMap resource. + + + +## Future Work + +This function is very basic right now. Integration with CEL and implementation +of features found in the Kustomize ConfigMapGenerator would be valuable. diff --git a/krm-functions/gen-configmap-fn/fn/gen_configmap.go b/krm-functions/gen-configmap-fn/fn/gen_configmap.go new file mode 100644 index 00000000..379ccaf4 --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/gen_configmap.go @@ -0,0 +1,135 @@ +/* +Copyright 2023 Nephio. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package fn + +import ( + "bytes" + "fmt" + "text/template" + + "github.com/GoogleContainerTools/kpt-functions-sdk/go/fn" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "sigs.k8s.io/kustomize/kyaml/kio/kioutil" +) + +type GenConfigMapEntry struct { + Type string + Key string + Value string +} + +type GenConfigMap struct { + ConfigMapMetadata metav1.ObjectMeta + Params map[string]string + Data []GenConfigMapEntry +} + +func (entry *GenConfigMapEntry) generate(params, data map[string]string) error { + switch entry.Type { + case "gotmpl": + t, err := template.New(entry.Key).Parse(entry.Value) + if err != nil { + return err + } + buf := &bytes.Buffer{} + err = t.Execute(buf, params) + if err != nil { + return err + } + data[entry.Key] = buf.String() + default: + data[entry.Key] = entry.Value + } + + return nil +} + +func (fc *GenConfigMap) Validate() error { + for i, entry := range fc.Data { + if entry.Key == "" { + return fmt.Errorf("data entry %d, key must not be empty", i) + } + } + return nil +} + +func Process(rl *fn.ResourceList) (bool, error) { + // read our fc into a new struct + fc := &GenConfigMap{} + err := rl.FunctionConfig.As(fc) + if err != nil { + return false, err + } + + name := fc.ConfigMapMetadata.Name + if name == "" { + name = rl.FunctionConfig.GetName() + } + + err = fc.Validate() + if err != nil { + return false, err + } + + cmko := fn.NewEmptyKubeObject() + err = cmko.SetAPIVersion("v1") + if err != nil { + return false, err + } + err = cmko.SetKind("ConfigMap") + if err != nil { + return false, err + } + err = cmko.SetNestedField(fc.ConfigMapMetadata, "metadata") + if err != nil { + return false, err + } + _, err = cmko.RemoveNestedField("metadata", "creationTimestamp") + if err != nil { + return false, err + } + err = cmko.SetName(name) + if err != nil { + return false, err + } + + err = cmko.SetAnnotation(kioutil.PathAnnotation, "_gen_configmap_"+name+".yaml") + if err != nil { + return false, err + } + + data := make(map[string]string, len(fc.Data)) + for i, entry := range fc.Data { + err = entry.generate(fc.Params, data) + if err != nil { + return false, fmt.Errorf("data entry %d generate error: %s", i, err.Error()) + } + } + if len(data) > 0 { + err = cmko.SetNestedField(data, "data") + if err != nil { + return false, err + } + } + err = rl.UpsertObjectToItems(cmko, nil, true) + if err != nil { + return false, err + } + + return true, nil +} diff --git a/krm-functions/gen-configmap-fn/fn/gen_configmap_test.go b/krm-functions/gen-configmap-fn/fn/gen_configmap_test.go new file mode 100644 index 00000000..459ffe36 --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/gen_configmap_test.go @@ -0,0 +1,80 @@ +/* +Copyright 2023 Nephio. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package fn + +import ( + "github.com/GoogleContainerTools/kpt-functions-sdk/go/fn" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestErrorCases(t *testing.T) { + cases := map[string]struct { + input []byte + errExpected string + }{ + "MissingKey": { + input: []byte(` +apiVersion: fn.kpt.dev/v1alpha1 +kind: GenConfigMap +metadata: + name: empty-test +data: +- type: literal + value: foo`), + errExpected: "data entry 0, key must not be empty", + }, + "GoTemplateParseError": { + input: []byte(` +apiVersion: fn.kpt.dev/v1alpha1 +kind: GenConfigMap +metadata: + name: empty-test +data: +- type: gotmpl + key: bad + value: foo{{`), + errExpected: "data entry 0 generate error: template: bad:1: unclosed action", + }, + "GoTemplateExecuteError": { + input: []byte(` +apiVersion: fn.kpt.dev/v1alpha1 +kind: GenConfigMap +metadata: + name: empty-test +data: +- type: gotmpl + key: bad + value: foo{{template "nope"}}`), + errExpected: "data entry 0 generate error: template: bad:1:14: executing \"bad\" at <{{template \"nope\"}}>: template \"nope\" not defined", + }, + } + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + ko, err := fn.ParseKubeObject(tc.input) + assert.NoError(t, err) + + _, err = Process(&fn.ResourceList{FunctionConfig: ko}) + if tc.errExpected != "" { + assert.EqualError(t, err, tc.errExpected) + } else { + assert.NoError(t, err) + } + }) + } +} diff --git a/krm-functions/gen-configmap-fn/fn/golden_test.go b/krm-functions/gen-configmap-fn/fn/golden_test.go new file mode 100644 index 00000000..c1375c26 --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/golden_test.go @@ -0,0 +1,32 @@ +/* + Copyright 2023 The Nephio Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package fn + +import ( + "testing" + + "github.com/GoogleContainerTools/kpt-functions-sdk/go/fn" + "github.com/GoogleContainerTools/kpt-functions-sdk/go/fn/testhelpers" +) + +const TestDataPath = "testdata" + +func TestFunction(t *testing.T) { + // This golden test expects each sub-directory of `testdata` can has its input resources (in `resources.yaml`) + // be modified to the output resources (in `_expected.yaml`). + testhelpers.RunGoldenTests(t, TestDataPath, fn.ResourceListProcessorFunc(Process)) +} diff --git a/krm-functions/gen-configmap-fn/fn/testdata/empty/_expected.yaml b/krm-functions/gen-configmap-fn/fn/testdata/empty/_expected.yaml new file mode 100644 index 00000000..630d28ca --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/empty/_expected.yaml @@ -0,0 +1,14 @@ +apiVersion: config.kubernetes.io/v1 +kind: ResourceList +items: +- apiVersion: v1 + kind: ConfigMap + metadata: + name: empty-test + annotations: + internal.config.kubernetes.io/path: _gen_configmap_empty-test.yaml +functionConfig: + apiVersion: fn.kpt.dev/v1alpha1 + kind: GenConfigMap + metadata: + name: empty-test diff --git a/krm-functions/gen-configmap-fn/fn/testdata/empty/_fnconfig.yaml b/krm-functions/gen-configmap-fn/fn/testdata/empty/_fnconfig.yaml new file mode 100644 index 00000000..86482c40 --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/empty/_fnconfig.yaml @@ -0,0 +1,4 @@ +apiVersion: fn.kpt.dev/v1alpha1 +kind: GenConfigMap +metadata: + name: empty-test diff --git a/krm-functions/gen-configmap-fn/fn/testdata/empty/resources.yaml b/krm-functions/gen-configmap-fn/fn/testdata/empty/resources.yaml new file mode 100644 index 00000000..e69de29b diff --git a/krm-functions/gen-configmap-fn/fn/testdata/gotmpl/_expected.yaml b/krm-functions/gen-configmap-fn/fn/testdata/gotmpl/_expected.yaml new file mode 100644 index 00000000..f6a4d244 --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/gotmpl/_expected.yaml @@ -0,0 +1,32 @@ +apiVersion: config.kubernetes.io/v1 +kind: ResourceList +items: +- apiVersion: v1 + kind: ConfigMap + metadata: + name: my-config-map + namespace: some-ns + labels: + foo: bar + annotations: + internal.config.kubernetes.io/path: _gen_configmap_my-config-map.yaml + data: + greeting: Hello Ms. Foo! How are you doing? +functionConfig: + apiVersion: fn.kpt.dev/v1alpha1 + kind: GenConfigMap + metadata: + name: simple-test + configMapMetadata: + name: my-config-map + namespace: some-ns + labels: + foo: bar + params: + salutation: Hello + name: Ms. Foo + followUp: How are you doing? + data: + - type: gotmpl + key: greeting + value: "{{.salutation}} {{.name}}! {{.followUp}}" diff --git a/krm-functions/gen-configmap-fn/fn/testdata/gotmpl/_fnconfig.yaml b/krm-functions/gen-configmap-fn/fn/testdata/gotmpl/_fnconfig.yaml new file mode 100644 index 00000000..523b0ab7 --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/gotmpl/_fnconfig.yaml @@ -0,0 +1,17 @@ +apiVersion: fn.kpt.dev/v1alpha1 +kind: GenConfigMap +metadata: + name: simple-test +configMapMetadata: + name: my-config-map + namespace: some-ns + labels: + foo: bar +params: + salutation: Hello + name: Ms. Foo + followUp: How are you doing? +data: +- type: gotmpl + key: greeting + value: "{{.salutation}} {{.name}}! {{.followUp}}" diff --git a/krm-functions/gen-configmap-fn/fn/testdata/gotmpl/resources.yaml b/krm-functions/gen-configmap-fn/fn/testdata/gotmpl/resources.yaml new file mode 100644 index 00000000..e69de29b diff --git a/krm-functions/gen-configmap-fn/fn/testdata/literal/_expected.yaml b/krm-functions/gen-configmap-fn/fn/testdata/literal/_expected.yaml new file mode 100644 index 00000000..12084eea --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/literal/_expected.yaml @@ -0,0 +1,32 @@ +apiVersion: config.kubernetes.io/v1 +kind: ResourceList +items: +- apiVersion: v1 + kind: ConfigMap + metadata: + name: my-config-map + namespace: some-ns + labels: + foo: bar + annotations: + internal.config.kubernetes.io/path: _gen_configmap_my-config-map.yaml + data: + foo: bar + footoo: barbar +functionConfig: + apiVersion: fn.kpt.dev/v1alpha1 + kind: GenConfigMap + metadata: + name: literal-test + configMapMetadata: + name: my-config-map + namespace: some-ns + labels: + foo: bar + data: + - type: literal + key: foo + value: bar + - type: literal + key: footoo + value: barbar diff --git a/krm-functions/gen-configmap-fn/fn/testdata/literal/_fnconfig.yaml b/krm-functions/gen-configmap-fn/fn/testdata/literal/_fnconfig.yaml new file mode 100644 index 00000000..64c182af --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/literal/_fnconfig.yaml @@ -0,0 +1,16 @@ +apiVersion: fn.kpt.dev/v1alpha1 +kind: GenConfigMap +metadata: + name: literal-test +configMapMetadata: + name: my-config-map + namespace: some-ns + labels: + foo: bar +data: +- type: literal + key: foo + value: bar +- type: literal + key: footoo + value: barbar diff --git a/krm-functions/gen-configmap-fn/fn/testdata/literal/resources.yaml b/krm-functions/gen-configmap-fn/fn/testdata/literal/resources.yaml new file mode 100644 index 00000000..e69de29b diff --git a/krm-functions/gen-configmap-fn/fn/testdata/meta-only/_expected.yaml b/krm-functions/gen-configmap-fn/fn/testdata/meta-only/_expected.yaml new file mode 100644 index 00000000..2fa3ebff --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/meta-only/_expected.yaml @@ -0,0 +1,22 @@ +apiVersion: config.kubernetes.io/v1 +kind: ResourceList +items: +- apiVersion: v1 + kind: ConfigMap + metadata: + name: my-meta-only-map + namespace: yo + labels: + foo: bar + annotations: + internal.config.kubernetes.io/path: _gen_configmap_my-meta-only-map.yaml +functionConfig: + apiVersion: fn.kpt.dev/v1alpha1 + kind: GenConfigMap + metadata: + name: meta-only-test + configMapMetadata: + name: my-meta-only-map + labels: + foo: bar + namespace: yo diff --git a/krm-functions/gen-configmap-fn/fn/testdata/meta-only/_fnconfig.yaml b/krm-functions/gen-configmap-fn/fn/testdata/meta-only/_fnconfig.yaml new file mode 100644 index 00000000..18b5a51c --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/meta-only/_fnconfig.yaml @@ -0,0 +1,9 @@ +apiVersion: fn.kpt.dev/v1alpha1 +kind: GenConfigMap +metadata: + name: meta-only-test +configMapMetadata: + name: my-meta-only-map + labels: + foo: bar + namespace: yo diff --git a/krm-functions/gen-configmap-fn/fn/testdata/meta-only/resources.yaml b/krm-functions/gen-configmap-fn/fn/testdata/meta-only/resources.yaml new file mode 100644 index 00000000..e69de29b diff --git a/krm-functions/gen-configmap-fn/fn/testdata/mixed/_expected.yaml b/krm-functions/gen-configmap-fn/fn/testdata/mixed/_expected.yaml new file mode 100644 index 00000000..be4a8405 --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/mixed/_expected.yaml @@ -0,0 +1,35 @@ +apiVersion: config.kubernetes.io/v1 +kind: ResourceList +items: +- apiVersion: v1 + kind: ConfigMap + metadata: + name: my-configmap + labels: + foo: bar + annotations: + internal.config.kubernetes.io/path: _gen_configmap_my-configmap.yaml + data: + dburl: https://foo.example.com:8992/us-east1/db + hello: there +functionConfig: + apiVersion: fn.kpt.dev/v1alpha1 + kind: GenConfigMap + metadata: + name: my-generator + configMapMetadata: + name: my-configmap + labels: + foo: bar + params: + hostname: foo.example.com + port: "8992" + scheme: https + region: us-east1 + data: + - type: literal + key: hello + value: there + - type: gotmpl + key: dburl + value: "{{.scheme}}://{{.hostname}}:{{.port}}/{{.region}}/db" diff --git a/krm-functions/gen-configmap-fn/fn/testdata/mixed/_fnconfig.yaml b/krm-functions/gen-configmap-fn/fn/testdata/mixed/_fnconfig.yaml new file mode 100644 index 00000000..f98ee276 --- /dev/null +++ b/krm-functions/gen-configmap-fn/fn/testdata/mixed/_fnconfig.yaml @@ -0,0 +1,20 @@ +apiVersion: fn.kpt.dev/v1alpha1 +kind: GenConfigMap +metadata: + name: my-generator +configMapMetadata: + name: my-configmap + labels: + foo: bar +params: + hostname: foo.example.com + port: "8992" + scheme: https + region: us-east1 +data: +- type: literal + key: hello + value: there +- type: gotmpl + key: dburl + value: "{{.scheme}}://{{.hostname}}:{{.port}}/{{.region}}/db" diff --git a/krm-functions/gen-configmap-fn/fn/testdata/mixed/resources.yaml b/krm-functions/gen-configmap-fn/fn/testdata/mixed/resources.yaml new file mode 100644 index 00000000..e69de29b diff --git a/krm-functions/gen-configmap-fn/go.mod b/krm-functions/gen-configmap-fn/go.mod new file mode 100644 index 00000000..1986f885 --- /dev/null +++ b/krm-functions/gen-configmap-fn/go.mod @@ -0,0 +1,49 @@ +module github.com/nephio-project/nephio/krm-functions/gen-configmap-fn + +go 1.20 + +replace github.com/nephio-project/nephio/krm-functions/lib => ../lib + +require ( + github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20230427202446-3255accc518d + github.com/stretchr/testify v1.8.2 + k8s.io/apimachinery v0.27.3 +) + +require ( + github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20230427202446-3255accc518d // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-errors/errors v1.4.2 // indirect + github.com/go-logr/logr v1.2.4 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.22.3 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/gnostic v0.6.9 // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect + github.com/xlab/treeprint v1.2.0 // indirect + golang.org/x/net v0.10.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/text v0.9.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/klog/v2 v2.100.1 // indirect + k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515 // indirect + k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/kustomize/kyaml v0.14.2 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect +) diff --git a/krm-functions/gen-configmap-fn/go.sum b/krm-functions/gen-configmap-fn/go.sum new file mode 100644 index 00000000..470eb722 --- /dev/null +++ b/krm-functions/gen-configmap-fn/go.sum @@ -0,0 +1,249 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20230427202446-3255accc518d h1:NQFVnLXevDG7Ht9B/46X3FWHg+gEQc8Q68PlAnY0XsM= +github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20230427202446-3255accc518d/go.mod h1:prNhhUAODrB2VqHVead9tB8nLU9ffY4e4jjBwLMNO1M= +github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20230427202446-3255accc518d h1:kgC/R6Kl+tBjsRvcPr4Beae1MiHumNMtbmUTy7qlPZI= +github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20230427202446-3255accc518d/go.mod h1:Pnd3ImgaWS3OBVjztSiGMACMf+CDs20l5nT5Oljy/tA= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= +github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0= +github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= +github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= +github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/apimachinery v0.27.3 h1:Ubye8oBufD04l9QnNtW05idcOe9Z3GQN8+7PqmuVcUM= +k8s.io/apimachinery v0.27.3/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= +k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= +k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515 h1:OmK1d0WrkD3IPfkskvroRykOulHVHf0s0ZIFRjyt+UI= +k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515/go.mod h1:kzo02I3kQ4BTtEfVLaPbjvCkX97YqGve33wzlb3fofQ= +k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU= +k8s.io/utils v0.0.0-20230505201702-9f6742963106/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/kustomize/kyaml v0.14.2 h1:9WSwztbzwGszG1bZTziQUmVMrJccnyrLb5ZMKpJGvXw= +sigs.k8s.io/kustomize/kyaml v0.14.2/go.mod h1:AN1/IpawKilWD7V+YvQwRGUvuUOOWpjsHu6uHwonSF4= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/krm-functions/gen-configmap-fn/main.go b/krm-functions/gen-configmap-fn/main.go new file mode 100644 index 00000000..59024fcd --- /dev/null +++ b/krm-functions/gen-configmap-fn/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "os" + + "github.com/GoogleContainerTools/kpt-functions-sdk/go/fn" + + fnr "github.com/nephio-project/nephio/krm-functions/gen-configmap-fn/fn" +) + +func main() { + if err := fn.AsMain(fn.ResourceListProcessorFunc(fnr.Process)); err != nil { + os.Exit(1) + } +}