Skip to content

Commit cd20a3e

Browse files
committed
Add defaults to chart and validate non-empty value
The empty string will be accepted, but it breaks then in during the run with unclear error message.
1 parent 46d40a9 commit cd20a3e

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

charts/openstack-hypervisor-operator/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ spec:
3939
secretKeyRef:
4040
key: SERVICE_PASSWORD
4141
name: {{ include "openstack-hypervisor-operator.fullname" . }}-secret
42+
- name: CERTIFICATE_NAMESPACE
43+
value: {{ quote .Values.controllerManager.manager.env.certificateNamespace }}
4244
- name: CERTIFICATE_ISSUER_NAME
4345
value: {{ quote .Values.controllerManager.manager.env.certificateIssuerName }}
4446
- name: LABEL_SELECTOR

charts/openstack-hypervisor-operator/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ controllerManager:
44
- --metrics-bind-address=:8443
55
- --leader-elect
66
- --health-probe-bind-address=:8081
7+
- --certificate-namespace=$(CERTIFICATE_NAMESPACE)
78
- --certificate-issuer-name=$(CERTIFICATE_ISSUER_NAME)
89
- --label-selector=$(LABEL_SELECTOR)
910
containerSecurityContext:
@@ -12,7 +13,8 @@ controllerManager:
1213
drop:
1314
- ALL
1415
env:
15-
certificateIssuerName: ""
16+
certificateIssuerName: nova-hypervisor-agents-ca-issuer
17+
certificateNamespace: monsoon3
1618
labelSelector: ""
1719
osAuthUrl: ""
1820
osProjectDomainName: ""

cmd/main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package main
2020
import (
2121
"crypto/sha256"
2222
"crypto/tls"
23+
"errors"
2324
"flag"
2425
"fmt"
2526
"os"
@@ -99,12 +100,23 @@ func main() {
99100
flag.StringVar(&certificateIssuerName, "certificate-issuer-name", "nova-hypervisor-agents-ca-issuer",
100101
"Name of the certificate issuer.")
101102

103+
if certificateIssuerName == "" {
104+
setupLog.Error(errors.New("certificate-issuer-name cannot be empty"), "invalid certificate issuer name")
105+
os.Exit(1)
106+
}
107+
108+
if certificateNamespace == "" {
109+
setupLog.Error(errors.New("certificate-namespace cannot be empty"), "invalid certificate namespace")
110+
os.Exit(1)
111+
}
112+
102113
opts := ctrlzap.Options{
103114
Development: true,
104115
TimeEncoder: zapcore.ISO8601TimeEncoder,
105116
Encoder: logger.NewSanitzeReconcileErrorEncoder(zap.NewDevelopmentEncoderConfig()),
106117
StacktraceLevel: zap.DPanicLevel,
107118
}
119+
108120
opts.BindFlags(flag.CommandLine)
109121
flag.Parse()
110122

config/manager/manager.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ spec:
6161
- args:
6262
- --leader-elect
6363
- --health-probe-bind-address=:8081
64+
- --certificate-namespace=$(CERTIFICATE_NAMESPACE)
6465
- --certificate-issuer-name=$(CERTIFICATE_ISSUER_NAME)
6566
- --label-selector=$(LABEL_SELECTOR)
6667
env:
@@ -75,7 +76,10 @@ spec:
7576
secretKeyRef:
7677
name: secret
7778
key: SERVICE_PASSWORD
79+
- name: CERTIFICATE_NAMESPACE
80+
value: "monsoon3"
7881
- name: CERTIFICATE_ISSUER_NAME
82+
value: "nova-hypervisor-agents-ca-issuer"
7983
- name: LABEL_SELECTOR
8084
image: keppel.eu-de-1.cloud.sap/ccloud/openstack-hypervisor-operator:latest
8185
name: manager

0 commit comments

Comments
 (0)