Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarbian-sap committed Sep 4, 2024
2 parents 864a55f + d33e5e5 commit 63650f5
Show file tree
Hide file tree
Showing 18 changed files with 260 additions and 484 deletions.
2 changes: 1 addition & 1 deletion build/controller/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### build go executable
FROM --platform=$BUILDPLATFORM golang:1.22.5 as build
FROM --platform=$BUILDPLATFORM golang:1.23.0 AS build

WORKDIR /go/src

Expand Down
2 changes: 1 addition & 1 deletion build/webhook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### build go executable
FROM --platform=$BUILDPLATFORM golang:1.22.5 as build
FROM --platform=$BUILDPLATFORM golang:1.23.0 AS build

WORKDIR /go/src

Expand Down
64 changes: 33 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
module github.com/sap/clustersecret-operator

go 1.19
go 1.23.0

require (
github.com/evanphx/json-patch/v5 v5.6.0
github.com/google/uuid v1.3.1
github.com/evanphx/json-patch/v5 v5.9.0
github.com/google/uuid v1.6.0
github.com/hashicorp/go-multierror v1.1.1
github.com/spf13/pflag v1.0.5
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.27.1
k8s.io/apimachinery v0.27.1
k8s.io/client-go v0.27.1
k8s.io/code-generator v0.27.2
k8s.io/klog/v2 v2.90.1
sigs.k8s.io/structured-merge-diff/v4 v4.2.3
k8s.io/api v0.31.0
k8s.io/apimachinery v0.31.0
k8s.io/client-go v0.31.0
k8s.io/code-generator v0.31.0
k8s.io/klog/v2 v2.130.1
sigs.k8s.io/structured-merge-diff/v4 v4.4.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // 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/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
Expand All @@ -39,21 +39,23 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.8.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
276 changes: 82 additions & 194 deletions go.sum

Large diffs are not rendered by default.

29 changes: 18 additions & 11 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,31 @@ if ! which go >/dev/null; then
exit 1
fi

cd $(dirname "${BASH_SOURCE[0]}")/..
cd "$(dirname "${BASH_SOURCE[0]}")"/..

go mod download k8s.io/code-generator
CODEGEN_PKG=$(go list -m -f '{{.Dir}}' k8s.io/code-generator)
GEN_PKG_PATH=$(go list -m)/pkg
OUTPUT_BASE=$(mktemp -d)

trap 'rm -rf "${OUTPUT_BASE}"' EXIT
OUTPUT_PATH=$(mktemp -d)
trap 'rm -rf "${OUTPUT_PATH}"' EXIT

# echo "PWD: ${PWD}"
# echo "CODEGEN_PKG: ${CODEGEN_PKG}"
# echo "GEN_PKG_PATH: ${GEN_PKG_PATH}"
# echo "OUTPUT_BASE: ${OUTPUT_BASE}"
# echo "OUTPUT_PATH: ${OUTPUT_PATH}"

source "${CODEGEN_PKG}"/kube_codegen.sh

kube::codegen::gen_helpers \
--boilerplate ./hack/boilerplate.go.txt \
./pkg/apis

/bin/bash "${CODEGEN_PKG}"/generate-groups.sh all \
"${GEN_PKG_PATH}"/client "${GEN_PKG_PATH}"/apis \
core.cs.sap.com:v1alpha1 \
--output-base "${OUTPUT_BASE}"/ \
--go-header-file ./hack/boilerplate.go.txt
kube::codegen::gen_client \
--with-watch \
--with-applyconfig \
--output-dir "${OUTPUT_PATH}"/client \
--output-pkg "${GEN_PKG_PATH}"/client \
--boilerplate ./hack/boilerplate.go.txt \
./pkg/apis

rm -rf "./pkg/client" && cp -Rf "${OUTPUT_BASE}"/"${GEN_PKG_PATH}" .
rm -rf "./pkg/client" && cp -Rf "${OUTPUT_PATH}"/client ./pkg
10 changes: 5 additions & 5 deletions internal/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestController1(t *testing.T) {
defer cancel()

clusterSecret := env.MustFatal(t).CreateClusterSecretFromFile("clustersecret.yaml")
clusterSecret = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret)
_ = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret)
env.MustError(t).AssertSecretFromFile("secret.yaml")
}

Expand Down Expand Up @@ -76,7 +76,7 @@ func TestController2(t *testing.T) {
env.MustError(t).AssertSecretFromFile("secret-4.yaml")

env.CreateNamespaceFromFile("namespace-5.yaml")
clusterSecret = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret)
_ = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret)
env.MustError(t).AssertSecretCount("", "clustersecrets.core.cs.sap.com/name=my-secret", 2)
env.MustError(t).AssertSecretFromFile("secret-4.yaml")
env.MustError(t).AssertSecretFromFile("secret-5.yaml")
Expand Down Expand Up @@ -106,13 +106,13 @@ func TestController3(t *testing.T) {
env.MustError(t).AssertSecretFromFile("secret-a-1.yaml")

env.MustFatal(t).UpdateClusterSecretFromFile("clustersecret-a-updated.yaml")
clusterSecret_a = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret_a)
_ = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret_a)
env.MustError(t).AssertSecretCount("", "clustersecrets.core.cs.sap.com/name=my-secret-a", 2)
env.MustError(t).AssertSecretFromFile("secret-a-updated-1.yaml")
env.MustError(t).AssertSecretFromFile("secret-a-updated-2.yaml")

clusterSecret_b := env.MustFatal(t).CreateClusterSecretFromFile("clustersecret-b.yaml")
clusterSecret_b = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret_b)
_ = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret_b)
env.MustError(t).AssertSecretCount("", "clustersecrets.core.cs.sap.com/name", 3)
env.MustError(t).AssertSecretFromFile("secret-a-updated-1.yaml")
env.MustError(t).AssertSecretFromFile("secret-a-updated-2.yaml")
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestController4(t *testing.T) {
defer cancel()

clusterSecret_a = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret_a)
clusterSecret_b = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret_b)
_ = env.MustFatal(t).WaitForClusterSecretReady(clusterSecret_b)
env.MustError(t).AssertSecretCount("", "clustersecrets.core.cs.sap.com/name", 2)
env.MustError(t).AssertSecret(secret_a_1)
env.MustError(t).AssertSecret(secret_b_2)
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *Controller) reconcileNamespace(namespaceName string) error {
if errors.IsNotFound(err) {
// that is a bit strange, since this should be only triggered after namespace create/update events
// however it may happen if the namespace has been deleted concurrently
klog.Warning("namespace %s does not exist; skipping reconcile", namespaceName)
klog.Warningf("namespace %s does not exist; skipping reconcile", namespaceName)
return nil
} else {
return err
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/client/applyconfiguration/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 38 additions & 1 deletion pkg/client/clientset/versioned/fake/clientset_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 63650f5

Please sign in to comment.