Skip to content

Commit 7094dd8

Browse files
authored
fixing scafolding after kubebuilder update (#146)
Signed-off-by: Adam D. Cornett <adc@redhat.com>
1 parent 4cab4ed commit 7094dd8

File tree

5 files changed

+37
-63
lines changed

5 files changed

+37
-63
lines changed

pkg/plugins/util/cleanup.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,41 @@ func UpdateKustomizationsInit() error {
6969
return fmt.Errorf("remove %s resources: %v", defaultKFile, err)
7070
}
7171

72+
if err := kbutil.ReplaceInFile(defaultKFile,
73+
`# Uncomment the patches line if you enable Metrics and CertManager
74+
# [METRICS-WITH-CERTS] To enable metrics protected with certManager, uncomment the following line.
75+
# This patch will protect the metrics with certManager self-signed certs.
76+
#- path: cert_metrics_manager_patch.yaml
77+
# target:
78+
# kind: Deployment`, ""); err != nil {
79+
return fmt.Errorf("remove %s resources: %v", defaultKFile, err)
80+
}
81+
82+
// Remove the file not used for Helm projects since we do not scaffold the cert-manager
83+
certPatchPath := filepath.Join("config", "default", "cert_metrics_manager_patch.yaml")
84+
if err := os.Remove(certPatchPath); err != nil && !os.IsNotExist(err) {
85+
return fmt.Errorf("failed to remove unused file %s: %v", certPatchPath, err)
86+
}
87+
88+
// Remove the file not used for Helm projects since we do not scaffold the cert-manager
89+
monitorTLSPatchPath := filepath.Join("config", "prometheus", "monitor_tls_patch.yaml")
90+
if err := os.Remove(monitorTLSPatchPath); err != nil && !os.IsNotExist(err) {
91+
return fmt.Errorf("failed to remove unused file %s: %v", monitorTLSPatchPath, err)
92+
}
93+
94+
prometheusKustomize := filepath.Join("config", "prometheus", "kustomization.yaml")
95+
if err := kbutil.ReplaceInFile(prometheusKustomize,
96+
`# [PROMETHEUS-WITH-CERTS] The following patch configures the ServiceMonitor in ../prometheus
97+
# to securely reference certificates created and managed by cert-manager.
98+
# Additionally, ensure that you uncomment the [METRICS WITH CERTMANAGER] patch under config/default/kustomization.yaml
99+
# to mount the "metrics-server-cert" secret in the Manager Deployment.
100+
#patches:
101+
# - path: monitor_tls_patch.yaml
102+
# target:
103+
# kind: ServiceMonitor`, ""); err != nil {
104+
return fmt.Errorf("remove %s resources: %v", defaultKFile, err)
105+
}
106+
72107
if err := kbutil.ReplaceInFile(defaultKFile,
73108
`
74109
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in

testdata/memcached-molecule-operator/config/default/cert_metrics_manager_patch.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

testdata/memcached-molecule-operator/config/default/kustomization.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,4 @@ patches:
3636
target:
3737
kind: Deployment
3838

39-
# Uncomment the patches line if you enable Metrics and CertManager
40-
# [METRICS-WITH-CERTS] To enable metrics protected with certManager, uncomment the following line.
41-
# This patch will protect the metrics with certManager self-signed certs.
42-
#- path: cert_metrics_manager_patch.yaml
43-
# target:
44-
# kind: Deployment
39+
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
resources:
22
- monitor.yaml
33

4-
# [PROMETHEUS-WITH-CERTS] The following patch configures the ServiceMonitor in ../prometheus
5-
# to securely reference certificates created and managed by cert-manager.
6-
# Additionally, ensure that you uncomment the [METRICS WITH CERTMANAGER] patch under config/default/kustomization.yaml
7-
# to mount the "metrics-server-cert" secret in the Manager Deployment.
8-
#patches:
9-
# - path: monitor_tls_patch.yaml
10-
# target:
11-
# kind: ServiceMonitor
4+

testdata/memcached-molecule-operator/config/prometheus/monitor_tls_patch.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)