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

chore: fix generic map conversion #1838

Merged
merged 4 commits into from
Feb 10, 2025

Conversation

emosbaugh
Copy link
Member

@emosbaugh emosbaugh commented Feb 6, 2025

What this PR does / why we need it:

Makes map conversion more resilient. No longer have to add new case statements for each type.

Which issue(s) this PR fixes:

Does this PR require a test?

Does this PR require a release note?


Does this PR require documentation?

Copy link

github-actions bot commented Feb 6, 2025

This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID.

Online Installer:

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci/appver-dev-dfa3fa3" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Airgap Installer (may take a few minutes before the airgap bundle is built):

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci-airgap/appver-dev-dfa3fa3?airgap=true" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Happy debugging!

for i, v := range in {
result[i] = cleanUpInterfaceMap(v)
func cleanUpGenericMap(m map[string]interface{}) (map[string]interface{}, error) {
b, err := yaml.Marshal(m)
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 k8syaml?

Copy link
Member Author

Choose a reason for hiding this comment

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

i think because k8syaml cannot marshal a map[interface{}]interface{}. i will test and add a comment

Copy link
Member Author

Choose a reason for hiding this comment

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

i added comments to clarify

"float": 1.5,
"bool": true,
"array": []map[string]interface{}{
{
"array": []interface{}{
Copy link
Member

Choose a reason for hiding this comment

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

think helm will accept an []interface{}?

Copy link
Member Author

Choose a reason for hiding this comment

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

i assume since its passing tests...

Copy link
Member

Choose a reason for hiding this comment

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

our e2e tests never caught this bug, which is why these unit tests were introduced. so i wouldn't be so confident...

Copy link
Member

Choose a reason for hiding this comment

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

if want did not change at all in these unit tests, i would be more confident in the change.

Copy link
Member Author

@emosbaugh emosbaugh Feb 8, 2025

Choose a reason for hiding this comment

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

@emosbaugh emosbaugh requested a review from sgalsaleh February 8, 2025 02:05
@emosbaugh emosbaugh force-pushed the emosbaugh/20250206/generic-map-conversion branch from f596145 to 7e18a4e Compare February 8, 2025 02:06
req.NoError(err, "cleanUpGenericMap failed")
req.Equal(tt.want, out)

// ultimately helm calls k8syaml.Marshal so we must make sure that the output is compatible
Copy link
Member

Choose a reason for hiding this comment

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

did you verify (even if manually) that this would've caught the issue fixed by #1834?

Copy link
Member Author

Choose a reason for hiding this comment

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

How can I verify? Can you provide reproduction steps? They are not in the original fix.

@emosbaugh emosbaugh merged commit 361b0b0 into main Feb 10, 2025
65 checks passed
@emosbaugh emosbaugh deleted the emosbaugh/20250206/generic-map-conversion branch February 10, 2025 21:20
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