Skip to content

Commit 240afa6

Browse files
authored
Merge pull request #798 from jetstack/tsgID_number_or_string
[VC-52458] Support both number and string for tsgID
2 parents 9db49f9 + 2d3e772 commit 240afa6

5 files changed

Lines changed: 24 additions & 8 deletions

File tree

deploy/charts/discovery-agent/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ The Discovery Agent connects your Kubernetes or OpenShift cluster to Palo Alto N
66

77
<!-- AUTO-GENERATED -->
88

9-
#### **config.tsgID** ~ `string`
9+
#### **config.tsgID** ~ `number,string`
1010
> Default value:
1111
> ```yaml
1212
> ""
1313
> ```
1414
15-
Required: The TSG (Tenant Service Group) ID to use when connecting to SCM. NB: TSG IDs are numeric, but must be treated as strings to avoid issues with YAML data types. With the Helm CLI use `--set-string`; with YAML always pass TSG IDs in double quotes.
15+
Required: The TSG (Tenant Service Group) ID to use when connecting to SCM.
1616
1717
1818
#### **config.clusterName** ~ `string`

deploy/charts/discovery-agent/templates/_helpers.tpl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,22 @@ usage through tuple/variable indirection.
104104
{{- printf "%s" $defaultReference -}}
105105
{{- end -}}
106106
{{- end }}
107+
108+
{{/*
109+
Because of Helm bug (https://github.com/helm/helm/issues/3001), Helm converts
110+
int value to float64 implictly, like 2748336 becomes 2.748336e+06.
111+
This breaks the output even when using quote to render.
112+
113+
Use this function when you want to get the string value only.
114+
It handles the case when the value is string itself as well.
115+
Parameters: is string/number
116+
117+
Usage: {{ include "discovery-agent.stringOrNumber" .Values.config.tsgID }}
118+
*/}}
119+
{{- define "discovery-agent.stringOrNumber" -}}
120+
{{- if kindIs "string" . }}
121+
{{- print . -}}
122+
{{- else }}
123+
{{- int64 . | toString -}}
124+
{{- end -}}
125+
{{- end -}}

deploy/charts/discovery-agent/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ spec:
7373
- "/etc/discovery-agent/config.yaml"
7474
- --ngts
7575
- --tsg-id
76-
- {{ required "config.tsgID is required" .Values.config.tsgID | toString | quote }}
76+
- {{ required "config.tsgID is required" .Values.config.tsgID | include "discovery-agent.stringOrNumber" | quote }}
7777
{{- with .Values.config.serverURL }}
7878
- --ngts-server-url
7979
- {{ . | quote }}

deploy/charts/discovery-agent/values.schema.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@
183183
},
184184
"helm-values.config.tsgID": {
185185
"default": "",
186-
"description": "Required: The TSG (Tenant Service Group) ID to use when connecting to SCM. NB: TSG IDs are numeric, but must be treated as strings to avoid issues with YAML data types. With the Helm CLI use `--set-string`; with YAML always pass TSG IDs in double quotes.",
187-
"type": "string"
186+
"description": "Required: The TSG (Tenant Service Group) ID to use when connecting to SCM."
188187
},
189188
"helm-values.extraArgs": {
190189
"default": [],

deploy/charts/discovery-agent/values.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Configuration for the Discovery Agent
22
config:
33
# Required: The TSG (Tenant Service Group) ID to use when connecting to SCM.
4-
# NB: TSG IDs are numeric, but must be treated as strings to avoid issues with YAML data types.
5-
# With the Helm CLI use `--set-string`; with YAML always pass TSG IDs in double quotes.
64
# +docs:property
7-
# +docs:type=string
5+
# +docs:type=number,string
86
tsgID: ""
97

108
# Required: A human readable name for the cluster into which the agent is being deployed.

0 commit comments

Comments
 (0)