Skip to content

Commit

Permalink
Allow Deployment, SA, and Service to be applied to custom Operator na…
Browse files Browse the repository at this point in the history
…mespace (#445)

* namespace change

* add namespace to chart.go

* update template

* template changes

* template changes

* indentation

* changes

* add changelog

* codegen
  • Loading branch information
jmhbh committed May 23, 2023
1 parent c3d88a0 commit 9b1f093
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
7 changes: 7 additions & 0 deletions changelog/v0.30.1/custom-operator-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
changelog:
- type: NEW_FEATURE
issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/9491
resolvesIssue: false
description: >
Allows setting a optional operator namespace on the operator that will be used when applying the
deployment, service account, and service for said operator.
3 changes: 3 additions & 0 deletions codegen/model/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ type JsonSchema struct {
type Operator struct {
Name string

// (Optional) If set, the operator deployment, service, and service account will use this namespace
Namespace string

// (Optional) To change the name referenced in the values file. If not specified a camelcase version of name is used
ValuesFileNameOverride string

Expand Down
17 changes: 15 additions & 2 deletions codegen/templates/chart/operator-deployment.yamltmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Expressions evaluating SKv2 Config use "[[" and "]]"
[[- $customDeploymentAnnotations := $operator.Deployment.CustomDeploymentAnnotations -]]
[[- $customServiceLabels := $operator.Service.CustomLabels -]]
[[- $customServiceAnnotations := $operator.Service.CustomAnnotations ]]
[[- $customNamespace := $operator.Namespace ]]

{{- $[[ $operatorVar ]] := [[ (opVar $operator) ]]}}
---
Expand Down Expand Up @@ -49,7 +50,11 @@ metadata:
[[ $key ]]: [[ $value ]]
[[- end ]]
name: [[ $operator.Name ]]
[[- if $customNamespace ]]
namespace: [[ $customNamespace ]]
[[- else ]]
namespace: {{ .Release.Namespace }}
[[- end ]]
spec:
selector:
matchLabels:
Expand Down Expand Up @@ -177,7 +182,11 @@ metadata:
{{- end }}
{{- end}}
name: [[ $operator.Name ]]
namespace: {{ $.Release.Namespace }}
[[- if $customNamespace ]]
namespace: [[ $customNamespace ]]
[[- else ]]
namespace: {{ .Release.Namespace }}
[[- end ]]
{{- end }}


Expand All @@ -200,7 +209,11 @@ metadata:
[[ $key ]]: [[ $value ]]
[[- end ]]
name: [[ $operator.Name ]]
namespace: {{ $.Release.Namespace }}
[[- if $customNamespace ]]
namespace: [[ $customNamespace ]]
[[- else ]]
namespace: {{ .Release.Namespace }}
[[- end ]]
spec:
selector:
app: [[ $operator.Name ]]
Expand Down
2 changes: 1 addition & 1 deletion codegen/test/chart-envvars/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ metadata:
{{- end }}
{{- end}}
name: painter
namespace: {{ $.Release.Namespace }}
namespace: {{ .Release.Namespace }}
{{- end }}


Expand Down
2 changes: 1 addition & 1 deletion codegen/test/chart-no-desc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ metadata:
{{- end }}
{{- end}}
name: painter
namespace: {{ $.Release.Namespace }}
namespace: {{ .Release.Namespace }}
{{- end }}


Expand Down
2 changes: 1 addition & 1 deletion codegen/test/chart-sidecar/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ metadata:
{{- end }}
{{- end}}
name: painter
namespace: {{ $.Release.Namespace }}
namespace: {{ .Release.Namespace }}
{{- end }}


Expand Down
2 changes: 1 addition & 1 deletion codegen/test/chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ metadata:
{{- end }}
{{- end}}
name: painter
namespace: {{ $.Release.Namespace }}
namespace: {{ .Release.Namespace }}
{{- end }}


Expand Down
2 changes: 1 addition & 1 deletion codegen/test/name_override_chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ metadata:
{{- end }}
{{- end}}
name: painter-original-name
namespace: {{ $.Release.Namespace }}
namespace: {{ .Release.Namespace }}
{{- end }}


Expand Down

0 comments on commit 9b1f093

Please sign in to comment.