Skip to content
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

allow empty status informers #102

Merged
merged 4 commits into from
Oct 13, 2023
Merged

allow empty status informers #102

merged 4 commits into from
Oct 13, 2023

Conversation

cbodonnell
Copy link
Contributor

What this PR does / why we need it:

This PR allows an empty array of status informers to be explicitly passed to the SDK. Previously if this was the case, the SDK would automatically generate status informers based on the Helm release. The default value for statusInformers will still result in them being automatically generated, which maintains existing behavior.

Which issue(s) this PR fixes:

Part of https://app.shortcut.com/replicated/story/88171/detect-and-configure-the-replicated-sdk-chart-subchart-if-it-s-part-of-the-vendor-s-application

Special notes for your reviewer:

Steps to reproduce

Does this PR introduce a user-facing change?

Status informers will no longer be automatically generated if the user explicitly passes an empty array for the `statusInformers` value.

Does this PR require documentation?

NONE

@cbodonnell cbodonnell force-pushed the cbo/empty-status-informers branch 5 times, most recently from 8a7ba41 to 5c9b2a0 Compare October 12, 2023 13:40
statusInformers: []
EOF

output=$(helm template oci://ttl.sh/automated-${{ github.run_id }}/replicated --version 0.0.0 --values test-values.yaml)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit pick: any reason not to use --set replicated.statusInformers=[]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that ended up rendering this:

statusInformers:
  - "[]"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, that's not what Helm's docs say. It's fine then, let's leave it as is.

https://helm.sh/docs/intro/using_helm/#the-format-and-limitations-of---set

Copy link
Contributor Author

@cbodonnell cbodonnell Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw that too. maybe it's because of how we template it

$ helm template replicated chart/replicated-0.0.0.tgz --set statusInformers=[] | grep -i statusInformers -A1
    statusInformers:
      '[]'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, probably. hmm, this might break in a production install if someone decides to override status informers using helm set, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if they try to override it using --set replicated.statusInformers=[]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the key issue is that {{- if .Values.statusInformers }} evaluates to true when using --set replicated.statusInformers=[], but evaluates to false when passing the same via a user-provided values file. looking like Helm is interpreting [] as a string in the former case and as an array in the latter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use if not (kindIs "invalid" ... like we do with the integration.enabled field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result is the same in that case as it's interpreted as a string when --set replicated.statusInformers=[] is passed to the cli:

$ helm template replicated chart/replicated-0.0.0.tgz --set statusInformers=[] | grep -i statusInformers -A1
    statusInformers:
      '[]'

@cbodonnell cbodonnell force-pushed the cbo/empty-status-informers branch 2 times, most recently from 0f22def to 5d5c759 Compare October 12, 2023 21:00
@cbodonnell cbodonnell force-pushed the cbo/empty-status-informers branch from 5d5c759 to 0fba0f9 Compare October 12, 2023 21:31
@cbodonnell cbodonnell requested a review from sgalsaleh October 13, 2023 13:10
pkg/appstate/util.go Outdated Show resolved Hide resolved
@cbodonnell cbodonnell merged commit 4e3d3d0 into main Oct 13, 2023
10 checks passed
@cbodonnell cbodonnell deleted the cbo/empty-status-informers branch October 13, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants