File tree 5 files changed +17
-28
lines changed
docs/book/src/getting-started/testdata/project/dist/chart/templates
pkg/plugins/optional/helm/v1alpha/scaffolds
internal/templates/chart-templates
5 files changed +17
-28
lines changed Original file line number Diff line number Diff line change @@ -9,30 +9,6 @@ metadata:
9
9
namespace : {{ .Release.Namespace }}
10
10
spec :
11
11
selfSigned : {}
12
- {{- if .Values.webhook.enable }}
13
- ---
14
- # Certificate for the webhook
15
- apiVersion : cert-manager.io/v1
16
- kind : Certificate
17
- metadata :
18
- annotations :
19
- {{- if .Values.crd.keep }}
20
- " helm.sh/resource-policy " : keep
21
- {{- end }}
22
- name : serving-cert
23
- namespace : {{ .Release.Namespace }}
24
- labels :
25
- {{- include "chart.labels" . | nindent 4 }}
26
- spec :
27
- dnsNames :
28
- - project.{{ .Release.Namespace }}.svc
29
- - project.{{ .Release.Namespace }}.svc.cluster.local
30
- - project-webhook-service.{{ .Release.Namespace }}.svc
31
- issuerRef :
32
- kind : Issuer
33
- name : selfsigned-issuer
34
- secretName : webhook-server-cert
35
- {{- end }}
36
12
{{- if .Values.metrics.enable }}
37
13
---
38
14
# Certificate for the metrics
Original file line number Diff line number Diff line change 49
49
{{- toYaml .Values.controllerManager.container.resources | nindent 12 }}
50
50
securityContext :
51
51
{{- toYaml .Values.controllerManager.container.securityContext | nindent 12 }}
52
- {{- if and .Values.certmanager.enable (or .Values.webhook.enable .Values. metrics.enable) }}
52
+ {{- if and .Values.certmanager.enable .Values.metrics.enable }}
53
53
volumeMounts :
54
54
{{- if and .Values.metrics.enable .Values.certmanager.enable }}
55
55
- name : metrics-certs
61
61
{{- toYaml .Values.controllerManager.securityContext | nindent 8 }}
62
62
serviceAccountName : {{ .Values.controllerManager.serviceAccountName }}
63
63
terminationGracePeriodSeconds : {{ .Values.controllerManager.terminationGracePeriodSeconds }}
64
- {{- if and .Values.certmanager.enable (or .Values.webhook.enable .Values. metrics.enable) }}
64
+ {{- if and .Values.certmanager.enable .Values.metrics.enable }}
65
65
volumes :
66
66
{{- if and .Values.metrics.enable .Values.certmanager.enable }}
67
67
- name : metrics-certs
Original file line number Diff line number Diff line change @@ -96,12 +96,12 @@ func (s *initScaffolder) Scaffold() error {
96
96
DeployImages : len (imagesEnvVars ) > 0 ,
97
97
HasWebhooks : hasWebhooks ,
98
98
},
99
- & templatescertmanager.Certificate {},
99
+ & templatescertmanager.Certificate {HasWebhooks : hasWebhooks },
100
100
& templatesmetrics.Service {},
101
101
& prometheus.Monitor {},
102
102
}
103
103
104
- if len (mutatingWebhooks ) > 0 || len (validatingWebhooks ) > 0 {
104
+ if hasWebhooks && ( len (mutatingWebhooks ) > 0 || len (validatingWebhooks ) > 0 ) {
105
105
buildScaffold = append (buildScaffold ,
106
106
& templateswebhooks.Template {
107
107
MutatingWebhooks : mutatingWebhooks ,
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ var _ machinery.Template = &Certificate{}
27
27
type Certificate struct {
28
28
machinery.TemplateMixin
29
29
machinery.ProjectNameMixin
30
+
31
+ // HasWebhooks is true when webhooks were found in the config
32
+ HasWebhooks bool
30
33
}
31
34
32
35
// SetTemplateDefaults sets the default template configuration
@@ -53,6 +56,7 @@ metadata:
53
56
namespace: {{ "{{ .Release.Namespace }}" }}
54
57
spec:
55
58
selfSigned: {}
59
+ {{- if .HasWebhooks }}
56
60
{{ "{{- if .Values.webhook.enable }}" }}
57
61
---
58
62
# Certificate for the webhook
77
81
name: selfsigned-issuer
78
82
secretName: webhook-server-cert
79
83
{{` + "`" + `{{- end }}` + "`" + `}}
84
+ {{- end }}
80
85
{{ "{{- if .Values.metrics.enable }}" }}
81
86
---
82
87
# Certificate for the metrics
Original file line number Diff line number Diff line change @@ -114,7 +114,11 @@ spec:
114
114
{{ "{{- toYaml .Values.controllerManager.container.resources | nindent 12 }}" }}
115
115
securityContext:
116
116
{{ "{{- toYaml .Values.controllerManager.container.securityContext | nindent 12 }}" }}
117
+ {{- if .HasWebhooks }}
117
118
{{ "{{- if and .Values.certmanager.enable (or .Values.webhook.enable .Values.metrics.enable) }}" }}
119
+ {{- else }}
120
+ {{ "{{- if and .Values.certmanager.enable .Values.metrics.enable }}" }}
121
+ {{- end }}
118
122
volumeMounts:
119
123
{{- if .HasWebhooks }}
120
124
{{ "{{- if and .Values.webhook.enable .Values.certmanager.enable }}" }}
@@ -133,7 +137,11 @@ spec:
133
137
{{ "{{- toYaml .Values.controllerManager.securityContext | nindent 8 }}" }}
134
138
serviceAccountName: {{ "{{ .Values.controllerManager.serviceAccountName }}" }}
135
139
terminationGracePeriodSeconds: {{ "{{ .Values.controllerManager.terminationGracePeriodSeconds }}" }}
140
+ {{- if .HasWebhooks }}
136
141
{{ "{{- if and .Values.certmanager.enable (or .Values.webhook.enable .Values.metrics.enable) }}" }}
142
+ {{- else }}
143
+ {{ "{{- if and .Values.certmanager.enable .Values.metrics.enable }}" }}
144
+ {{- end }}
137
145
volumes:
138
146
{{- if .HasWebhooks }}
139
147
{{ "{{- if and .Values.webhook.enable .Values.certmanager.enable }}" }}
You can’t perform that action at this time.
0 commit comments