Skip to content

Commit 837fcdc

Browse files
Merge branch 'master' into stop-generate-testdata-v3
2 parents 6ee6e8b + 958cda2 commit 837fcdc

File tree

10 files changed

+122
-50
lines changed

10 files changed

+122
-50
lines changed

pkg/config/store/yaml/store_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ var _ = Describe("yamlStore", func() {
5454
unversionedFile = `version:
5555
`
5656
nonexistentVersionFile = `version: 1-alpha
57-
` // v1-alpha never existed
57+
` // v1-alpha never existed
5858
wrongFile = `version: "2"
5959
layout: ""
60-
` // layout field does not exist in v2
60+
` // layout field does not exist in v2
6161
)
6262

6363
var (

pkg/plugins/golang/v3/plugin.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ func (p Plugin) GetCreateWebhookSubcommand() plugin.CreateWebhookSubcommand {
6262

6363
// GetEditSubcommand will return the subcommand which is responsible for editing the scaffold of the project
6464
func (p Plugin) GetEditSubcommand() plugin.EditSubcommand { return &p.editSubcommand }
65+
66+
func (p Plugin) DeprecationWarning() string {
67+
return "This version is deprecated." +
68+
"The `go/v3` cannot scaffold projects using kustomize versions v4x+" +
69+
" and cannot fully support Kubernetes 1.25+." +
70+
"It is recommended to upgrade your project to the latest versions available (go/v4)." +
71+
"Please, check the migration guide to learn how to upgrade your project"
72+
}

pkg/plugins/golang/v4/plugin.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,3 @@ func (p Plugin) GetCreateWebhookSubcommand() plugin.CreateWebhookSubcommand {
6363

6464
// GetEditSubcommand will return the subcommand which is responsible for editing the scaffold of the project
6565
func (p Plugin) GetEditSubcommand() plugin.EditSubcommand { return &p.editSubcommand }
66-
67-
func (p Plugin) DeprecationWarning() string {
68-
return "This version is deprecated." +
69-
"The `go/v3` cannot scaffold projects using kustomize versions v4x+" +
70-
" and cannot fully support Kubernetes 1.25+." +
71-
"It is recommended to upgrade your project to the latest versions available (go/v4)." +
72-
"Please, check the migration guide to learn how to upgrade your project"
73-
}

test/testdata/generate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,4 @@ scaffold_test_project project-v4-multigroup --plugins="go/v4"
138138
scaffold_test_project project-v4-declarative-v1 --plugins="go/v4,declarative"
139139
scaffold_test_project project-v4-config --component-config --plugins="go/v4"
140140
scaffold_test_project project-v4-with-deploy-image --plugins="go/v4"
141-
scaffold_test_project project-v4-with-grafana
141+
scaffold_test_project project-v4-with-grafana --plugins="go/v4"

testdata/project-v4-with-grafana/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ COPY go.sum go.sum
1212
RUN go mod download
1313

1414
# Copy the go source
15-
COPY main.go main.go
15+
COPY cmd/main.go cmd/main.go
1616
COPY api/ api/
17-
COPY controllers/ controllers/
17+
COPY internal/controller/ internal/controller/
1818

1919
# Build
2020
# the GOARCH has not a default value to allow the binary be built according to the host where the command
2121
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
2222
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2323
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
24-
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go
24+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
2525

2626
# Use distroless as minimal base image to package the manager binary
2727
# Refer to https://github.com/GoogleContainerTools/distroless for more details

testdata/project-v4-with-grafana/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ test: manifests generate fmt vet envtest ## Run tests.
6262

6363
.PHONY: build
6464
build: manifests generate fmt vet ## Build manager binary.
65-
go build -o bin/manager main.go
65+
go build -o bin/manager cmd/main.go
6666

6767
.PHONY: run
6868
run: manifests generate fmt vet ## Run a controller from your host.
69-
go run ./main.go
69+
go run ./cmd/main.go
7070

7171
# If you wish built the manager image targeting other platforms you can use the --platform flag.
7272
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
@@ -132,7 +132,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
132132
ENVTEST ?= $(LOCALBIN)/setup-envtest
133133

134134
## Tool Versions
135-
KUSTOMIZE_VERSION ?= v3.8.7
135+
KUSTOMIZE_VERSION ?= v5.0.0
136136
CONTROLLER_TOOLS_VERSION ?= v0.11.3
137137

138138
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"

testdata/project-v4-with-grafana/PROJECT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# More info: https://book.kubebuilder.io/reference/project-config.html
55
domain: testproject.org
66
layout:
7-
- go.kubebuilder.io/v3
7+
- go.kubebuilder.io/v4
88
plugins:
99
grafana.kubebuilder.io/v1-alpha: {}
1010
projectName: project-v4-with-grafana

testdata/project-v4-with-grafana/config/default/kustomization.yaml

Lines changed: 103 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ namespace: project-v4-with-grafana-system
99
namePrefix: project-v4-with-grafana-
1010

1111
# Labels to add to all resources and selectors.
12-
#commonLabels:
13-
# someName: someValue
12+
#labels:
13+
#- includeSelectors: true
14+
# pairs:
15+
# someName: someValue
1416

15-
bases:
17+
resources:
1618
- ../crd
1719
- ../rbac
1820
- ../manager
@@ -41,32 +43,102 @@ patchesStrategicMerge:
4143
# 'CERTMANAGER' needs to be enabled to use ca injection
4244
#- webhookcainjection_patch.yaml
4345

44-
# the following config is for teaching kustomize how to do var substitution
45-
vars:
4646
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
47-
#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
48-
# objref:
49-
# kind: Certificate
50-
# group: cert-manager.io
51-
# version: v1
52-
# name: serving-cert # this name should match the one in certificate.yaml
53-
# fieldref:
54-
# fieldpath: metadata.namespace
55-
#- name: CERTIFICATE_NAME
56-
# objref:
57-
# kind: Certificate
58-
# group: cert-manager.io
59-
# version: v1
60-
# name: serving-cert # this name should match the one in certificate.yaml
61-
#- name: SERVICE_NAMESPACE # namespace of the service
62-
# objref:
63-
# kind: Service
64-
# version: v1
65-
# name: webhook-service
66-
# fieldref:
67-
# fieldpath: metadata.namespace
68-
#- name: SERVICE_NAME
69-
# objref:
70-
# kind: Service
71-
# version: v1
72-
# name: webhook-service
47+
# Uncomment the following replacements to add the cert-manager CA injection annotations
48+
#replacements:
49+
# - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs
50+
# kind: Certificate
51+
# group: cert-manager.io
52+
# version: v1
53+
# name: serving-cert # this name should match the one in certificate.yaml
54+
# fieldPath: .metadata.namespace # namespace of the certificate CR
55+
# targets:
56+
# - select:
57+
# kind: ValidatingWebhookConfiguration
58+
# fieldPaths:
59+
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
60+
# options:
61+
# delimiter: '/'
62+
# index: 0
63+
# create: true
64+
# - select:
65+
# kind: MutatingWebhookConfiguration
66+
# fieldPaths:
67+
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
68+
# options:
69+
# delimiter: '/'
70+
# index: 0
71+
# create: true
72+
# - select:
73+
# kind: CustomResourceDefinition
74+
# fieldPaths:
75+
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
76+
# options:
77+
# delimiter: '/'
78+
# index: 0
79+
# create: true
80+
# - source:
81+
# kind: Certificate
82+
# group: cert-manager.io
83+
# version: v1
84+
# name: serving-cert # this name should match the one in certificate.yaml
85+
# fieldPath: .metadata.name
86+
# targets:
87+
# - select:
88+
# kind: ValidatingWebhookConfiguration
89+
# fieldPaths:
90+
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
91+
# options:
92+
# delimiter: '/'
93+
# index: 1
94+
# create: true
95+
# - select:
96+
# kind: MutatingWebhookConfiguration
97+
# fieldPaths:
98+
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
99+
# options:
100+
# delimiter: '/'
101+
# index: 1
102+
# create: true
103+
# - select:
104+
# kind: CustomResourceDefinition
105+
# fieldPaths:
106+
# - .metadata.annotations.[cert-manager.io/inject-ca-from]
107+
# options:
108+
# delimiter: '/'
109+
# index: 1
110+
# create: true
111+
# - source: # Add cert-manager annotation to the webhook Service
112+
# kind: Service
113+
# version: v1
114+
# name: webhook-service
115+
# fieldPath: .metadata.name # namespace of the service
116+
# targets:
117+
# - select:
118+
# kind: Certificate
119+
# group: cert-manager.io
120+
# version: v1
121+
# fieldPaths:
122+
# - .spec.dnsNames.0
123+
# - .spec.dnsNames.1
124+
# options:
125+
# delimiter: '.'
126+
# index: 0
127+
# create: true
128+
# - source:
129+
# kind: Service
130+
# version: v1
131+
# name: webhook-service
132+
# fieldPath: .metadata.namespace # namespace of the service
133+
# targets:
134+
# - select:
135+
# kind: Certificate
136+
# group: cert-manager.io
137+
# version: v1
138+
# fieldPaths:
139+
# - .spec.dnsNames.0
140+
# - .spec.dnsNames.1
141+
# options:
142+
# delimiter: '.'
143+
# index: 1
144+
# create: true

testdata/project-v4-with-grafana/config/rbac/service_account.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: ServiceAccount
33
metadata:
44
labels:
55
app.kubernetes.io/name: serviceaccount
6-
app.kubernetes.io/instance: controller-manager
6+
app.kubernetes.io/instance: controller-manager-sa
77
app.kubernetes.io/component: rbac
88
app.kubernetes.io/created-by: project-v4-with-grafana
99
app.kubernetes.io/part-of: project-v4-with-grafana

0 commit comments

Comments
 (0)