-
Notifications
You must be signed in to change notification settings - Fork 494
Fix chart rendering in dry-run or "helm template" scenarios #5760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| {{/* | ||
| Get IP-addresses of master nodes | ||
| Get IP-addresses of master nodes. If no nodes are returned, we assume this is | ||
| a dry-run/template call and return nothing. | ||
| */}} | ||
| {{- define "kubeovn.nodeIPs" -}} | ||
| {{- $nodes := lookup "v1" "Node" "" "" -}} | ||
| {{- if eq (len $nodes) 0 -}} | ||
| {{- else -}} | ||
|
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For better readability and to follow idiomatic Helm/Go template practices, this conditional can be simplified. Instead of checking The current |
||
| {{- $ips := list -}} | ||
| {{- range $node := $nodes.items -}} | ||
| {{- $label := splitList "=" $.Values.MASTER_NODES_LABEL }} | ||
|
|
@@ -25,6 +28,7 @@ Get IP-addresses of master nodes | |
| {{- end -}} | ||
| {{ join "," $ips }} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Number of master nodes | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability and to follow idiomatic Helm/Go template practices, this conditional can be simplified. Instead of checking
eq (len $nodes) 0and having an emptyifblock, you can directly check if$nodescontains any items. An empty dictionary (whichlookupreturns on failure or when no items are found) is treated asfalsein conditionals.The current
if-else-endstructure can be simplified to a more conciseif-endblock: