diff --git a/test/testdata/generate.sh b/test/testdata/generate.sh index 814c5723931..b87539e827d 100755 --- a/test/testdata/generate.sh +++ b/test/testdata/generate.sh @@ -130,12 +130,12 @@ build_kb scaffold_test_project project-v2 --project-version=2 # [Currently, default CLI plugin] - Project version 3 (default) uses plugin go/v3 (default). -scaffold_test_project project-v3 -scaffold_test_project project-v3-multigroup +scaffold_test_project project-v3 --plugins="go/v3" +scaffold_test_project project-v3-multigroup --plugins="go/v3" scaffold_test_project project-v3-declarative-v1 --plugins="go/v3,declarative" -scaffold_test_project project-v3-config --component-config -scaffold_test_project project-v3-with-deploy-image -scaffold_test_project project-v3-with-grafana +scaffold_test_project project-v3-config --component-config --plugins="go/v3" +scaffold_test_project project-v3-with-deploy-image --plugins="go/v3" +scaffold_test_project project-v3-with-grafana --plugins="go/v3" # [Next version, alpha] Project version v4-alpha scaffold_test_project project-v4 --plugins="go/v4" @@ -143,4 +143,4 @@ scaffold_test_project project-v4-multigroup --plugins="go/v4" scaffold_test_project project-v4-declarative-v1 --plugins="go/v4,declarative" scaffold_test_project project-v4-config --component-config --plugins="go/v4" scaffold_test_project project-v4-with-deploy-image --plugins="go/v4" -scaffold_test_project project-v4-with-grafana +scaffold_test_project project-v4-with-grafana --plugins="go/v4" diff --git a/testdata/project-v4-with-grafana/Dockerfile b/testdata/project-v4-with-grafana/Dockerfile index 8f9cca18eb6..ef4cfaf90bd 100644 --- a/testdata/project-v4-with-grafana/Dockerfile +++ b/testdata/project-v4-with-grafana/Dockerfile @@ -12,16 +12,16 @@ COPY go.sum go.sum RUN go mod download # Copy the go source -COPY main.go main.go +COPY cmd/main.go cmd/main.go COPY api/ api/ -COPY controllers/ controllers/ +COPY internal/controller/ internal/controller/ # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/testdata/project-v4-with-grafana/Makefile b/testdata/project-v4-with-grafana/Makefile index 73a01c158dd..87dd37d4e2f 100644 --- a/testdata/project-v4-with-grafana/Makefile +++ b/testdata/project-v4-with-grafana/Makefile @@ -62,11 +62,11 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: manifests generate fmt vet ## Build manager binary. - go build -o bin/manager main.go + go build -o bin/manager cmd/main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. - go run ./main.go + go run ./cmd/main.go # If you wish built the manager image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. @@ -132,7 +132,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions -KUSTOMIZE_VERSION ?= v3.8.7 +KUSTOMIZE_VERSION ?= v5.0.0 CONTROLLER_TOOLS_VERSION ?= v0.11.3 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" diff --git a/testdata/project-v4-with-grafana/PROJECT b/testdata/project-v4-with-grafana/PROJECT index 241a6cdefb9..35d0977d50f 100644 --- a/testdata/project-v4-with-grafana/PROJECT +++ b/testdata/project-v4-with-grafana/PROJECT @@ -4,7 +4,7 @@ # More info: https://book.kubebuilder.io/reference/project-config.html domain: testproject.org layout: -- go.kubebuilder.io/v3 +- go.kubebuilder.io/v4 plugins: grafana.kubebuilder.io/v1-alpha: {} projectName: project-v4-with-grafana diff --git a/testdata/project-v4-with-grafana/main.go b/testdata/project-v4-with-grafana/cmd/main.go similarity index 100% rename from testdata/project-v4-with-grafana/main.go rename to testdata/project-v4-with-grafana/cmd/main.go diff --git a/testdata/project-v4-with-grafana/config/default/kustomization.yaml b/testdata/project-v4-with-grafana/config/default/kustomization.yaml index ca19fadabb7..d392dadc0fd 100644 --- a/testdata/project-v4-with-grafana/config/default/kustomization.yaml +++ b/testdata/project-v4-with-grafana/config/default/kustomization.yaml @@ -9,10 +9,12 @@ namespace: project-v4-with-grafana-system namePrefix: project-v4-with-grafana- # Labels to add to all resources and selectors. -#commonLabels: -# someName: someValue +#labels: +#- includeSelectors: true +# pairs: +# someName: someValue -bases: +resources: - ../crd - ../rbac - ../manager @@ -41,32 +43,102 @@ patchesStrategicMerge: # 'CERTMANAGER' needs to be enabled to use ca injection #- webhookcainjection_patch.yaml -# the following config is for teaching kustomize how to do var substitution -vars: # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. -#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -# fieldref: -# fieldpath: metadata.namespace -#- name: CERTIFICATE_NAME -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -#- name: SERVICE_NAMESPACE # namespace of the service -# objref: -# kind: Service -# version: v1 -# name: webhook-service -# fieldref: -# fieldpath: metadata.namespace -#- name: SERVICE_NAME -# objref: -# kind: Service -# version: v1 -# name: webhook-service +# Uncomment the following replacements to add the cert-manager CA injection annotations +#replacements: +# - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs +# kind: Certificate +# group: cert-manager.io +# version: v1 +# name: serving-cert # this name should match the one in certificate.yaml +# fieldPath: .metadata.namespace # namespace of the certificate CR +# targets: +# - select: +# kind: ValidatingWebhookConfiguration +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 0 +# create: true +# - select: +# kind: MutatingWebhookConfiguration +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 0 +# create: true +# - select: +# kind: CustomResourceDefinition +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 0 +# create: true +# - source: +# kind: Certificate +# group: cert-manager.io +# version: v1 +# name: serving-cert # this name should match the one in certificate.yaml +# fieldPath: .metadata.name +# targets: +# - select: +# kind: ValidatingWebhookConfiguration +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 1 +# create: true +# - select: +# kind: MutatingWebhookConfiguration +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 1 +# create: true +# - select: +# kind: CustomResourceDefinition +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 1 +# create: true +# - source: # Add cert-manager annotation to the webhook Service +# kind: Service +# version: v1 +# name: webhook-service +# fieldPath: .metadata.name # namespace of the service +# targets: +# - select: +# kind: Certificate +# group: cert-manager.io +# version: v1 +# fieldPaths: +# - .spec.dnsNames.0 +# - .spec.dnsNames.1 +# options: +# delimiter: '.' +# index: 0 +# create: true +# - source: +# kind: Service +# version: v1 +# name: webhook-service +# fieldPath: .metadata.namespace # namespace of the service +# targets: +# - select: +# kind: Certificate +# group: cert-manager.io +# version: v1 +# fieldPaths: +# - .spec.dnsNames.0 +# - .spec.dnsNames.1 +# options: +# delimiter: '.' +# index: 1 +# create: true diff --git a/testdata/project-v4-with-grafana/config/rbac/service_account.yaml b/testdata/project-v4-with-grafana/config/rbac/service_account.yaml index 1fb853ae687..04f10b75d76 100644 --- a/testdata/project-v4-with-grafana/config/rbac/service_account.yaml +++ b/testdata/project-v4-with-grafana/config/rbac/service_account.yaml @@ -3,7 +3,7 @@ kind: ServiceAccount metadata: labels: app.kubernetes.io/name: serviceaccount - app.kubernetes.io/instance: controller-manager + app.kubernetes.io/instance: controller-manager-sa app.kubernetes.io/component: rbac app.kubernetes.io/created-by: project-v4-with-grafana app.kubernetes.io/part-of: project-v4-with-grafana