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

Ensure that pulumi config cp also copies the environments from the source stack #14847

Merged
merged 8 commits into from Dec 19, 2023
Merged

Ensure that pulumi config cp also copies the environments from the source stack #14847

merged 8 commits into from Dec 19, 2023

Conversation

praneetloke
Copy link
Contributor

@praneetloke praneetloke commented Dec 13, 2023

Description

This PR updates the copy config command to also copy the environments from the source stack to the destination stack. The list of environments in the destination stack's config will be overwritten.

Fixes #14564

Checklist

  • I have run make tidy to update any new dependencies
  • I have run make lint to verify my code passes the lint check
    • I have formatted my code using gofumpt
  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

Copy link

PR is now waiting for a maintainer to take action.

Note for the maintainer: Commands available:

  • /run-acceptance-tests - used to test run the acceptance tests for the project
  • /run-codegen - used to test the Pull Request against downstream codegen
  • /run-docs-gen - used to test the Pull Request against documentation generation

@pulumi-bot
Copy link
Contributor

pulumi-bot commented Dec 13, 2023

Changelog

[uncommitted] (2023-12-14)

Bug Fixes

  • [cli/config] Fixes config copy command to also copy environments from the source stack

}

return nil
return requiresSaving, nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this change had a cascading effect on another place. Though I am not a huge fan of this approach I feel like this is simple and makes this function testable through unit testing.

I am also thinking if I should rename this method from copyEntireConfigMap to something like getMergdConfigMap?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@justinvp @pgavlin before merging this though, I want to draw attention to this comment in case you missed it. Would love to know your thoughts.

Copy link
Member

Choose a reason for hiding this comment

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

Returning requiresSaving and making it so callers have to call save doesn't seem the best, but I don't feel strongly about it and agree it's nice that it makes it easier to unit test. I'm fine with it.

I also don't feel strongly about the function name.

@pgavlin
Copy link
Member

pgavlin commented Dec 13, 2023

Also please that I opted to merge the environments with any existing ones that the destination stack config might already have. I assumed that's the desired behavior based on how key/value pairs are handled today.

This is interesting. The ordering of imported environments is meaningful, as it defines the merge order for the evaluated environment. How were KV pairs handled?

@praneetloke
Copy link
Contributor Author

praneetloke commented Dec 13, 2023

The ordering of imported environments is meaningful, as it defines the merge order for the evaluated environment.

Ohhh. Hmm that's going to make this tricky. I don't know if we can make assumptions about which should take precedence either, i.e. the source stack's envs vs. the destination's.

How were KV pairs handled?

In the case of K/V pairs it's simply setting them in the config map. Looking at the YAML marshaller though, I can't tell if it does some sort of ordering implicitly? I feel like I have seen code somewhere that does the key ordering 🤔

EDIT: I just realized you were probably asking about KV handling because there could be key conflicts. We seem to be overwriting them for both single-path and object keys, if I am reading the code correctly.

@praneetloke
Copy link
Contributor Author

@pgavlin maybe we should overwrite the destination stack's environment since we can't know how to order the source vs. destination's environments?

@komalali
Copy link
Member

@pgavlin maybe we should overwrite the destination stack's environment since we can't know how to order the source vs. destination's environments?

Yeah, I think we should overwrite it.

Copy link

PR is now waiting for a maintainer to take action.

Note for the maintainer: Commands available:

  • /run-acceptance-tests - used to test run the acceptance tests for the project
  • /run-codegen - used to test the Pull Request against downstream codegen
  • /run-docs-gen - used to test the Pull Request against documentation generation

Copy link

PR is now waiting for a maintainer to take action.

Note for the maintainer: Commands available:

  • /run-acceptance-tests - used to test run the acceptance tests for the project
  • /run-codegen - used to test the Pull Request against downstream codegen
  • /run-docs-gen - used to test the Pull Request against documentation generation

@praneetloke
Copy link
Contributor Author

Adding a quick note that I've updated this PR to overwrite the environments in the destination stack.

@justinvp
Copy link
Member

justinvp commented Dec 13, 2023

/run-acceptance-tests
Please view the results of the acceptance tests Here

@komalali
Copy link
Member

Copy link

PR is now waiting for a maintainer to take action.

Note for the maintainer: Commands available:

  • /run-acceptance-tests - used to test run the acceptance tests for the project
  • /run-codegen - used to test the Pull Request against downstream codegen
  • /run-docs-gen - used to test the Pull Request against documentation generation

@praneetloke
Copy link
Contributor Author

@komalali thank you. For some reason I didn't get the failure notification. I've fixed the lint error now.

@komalali
Copy link
Member

komalali commented Dec 14, 2023

/run-acceptance-tests
Please view the results of the acceptance tests Here

@komalali
Copy link
Member

For some reason I didn't get the failure notification.

Yeah it's coz the run notifications are buried in the comments for external contributions, like here: #14847 (comment) - it's easy to miss

@praneetloke
Copy link
Contributor Author

Ah I see. Yep I definitely overlooked that one.

@praneetloke
Copy link
Contributor Author

@justinvp following-up on this PR. Looks like the acceptance tests have passed. Just making sure there isn't anything else for me to do here to get this reviewed? The only thing I want to follow-up on is my comment about the function name before merging this.

Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @praneetloke!

I'll wait to see if @pgavlin has any other feedback, otherwise will merge next week.

}

return nil
return requiresSaving, nil
Copy link
Member

Choose a reason for hiding this comment

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

Returning requiresSaving and making it so callers have to call save doesn't seem the best, but I don't feel strongly about it and agree it's nice that it makes it easier to unit test. I'm fine with it.

I also don't feel strongly about the function name.

@pgavlin
Copy link
Member

pgavlin commented Dec 18, 2023

@pgavlin maybe we should overwrite the destination stack's environment since we can't know how to order the source vs. destination's environments?

Yeah, I think we should overwrite it.

Yeah, overwriting is probably easier to understand.

I worry a little bit about overwriting b/c it's inconsistent with what we do for non-ESC config, where the result is kinda-sorta a merge (just not a deep merge). But I think that the tradeoff in terms of explainability is probably worthwhile.

@justinvp justinvp added this pull request to the merge queue Dec 19, 2023
Merged via the queue into pulumi:master with commit 9bf7723 Dec 19, 2023
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pulumi config cp should copy any environments defined in the config file
5 participants