-
Notifications
You must be signed in to change notification settings - Fork 115
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
Provider config should be available as outputs #2598
Conversation
Does the PR have any schema changes?Looking good! No breaking changes found. |
Codecov Report
@@ Coverage Diff @@
## master #2598 +/- ##
==========================================
+ Coverage 18.48% 18.56% +0.07%
==========================================
Files 47 47
Lines 9569 9577 +8
==========================================
+ Hits 1769 1778 +9
+ Misses 7701 7695 -6
- Partials 99 104 +5
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I opted to defer some of the error handling improvements to another PR. |
tests/sdk/nodejs/examples/helm-release-provider-namespace/package.json
Outdated
Show resolved
Hide resolved
tests/sdk/nodejs/examples/helm-release-provider-namespace/package.json
Outdated
Show resolved
Hide resolved
@lblackstone in the original issue, you mentioned a |
I think it's fine to leave |
One regression I encountered is that this change breaks cases where the context and cluster differs in CI and locally. I have to replicate the exact kubeconfig naming in CI and locally even if the access methods differ. Otherwise, I'd get a "context "..." does not exist" or "cluster "..." does not exist" error. This is especially relevant when using GitLab CI with the GitLab Agent for Kubernetes (KAS), where kubecontexts are generated by GitLab CI. In my setup, I am currently unable to use GitLab Agent for Kubernetes to access the cluster outside of GitLab CI (like on my local machine) to perform a manual deployment. |
This reverts commit 0f84cfe.
This reverts #2598. <!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md) for Pulumi's contribution guidelines. Help us merge your changes more quickly by adding more details such as labels, milestones, and reviewers.--> ### Proposed changes <!--Give us a brief description of what you've done and what it solves. --> Mitigates #2626 ### Related issues (optional) Original issue: #2486
Proposed changes
Closes #2486
This PR exposes the provider input properties as outputs, and normalizes those inputs to provide the effective values. This opens up some new scenarios:
namespace
,context
orcluster
as appropriate, which helps to explain why downstream changes may be occurring.Detailed Changes
The following provider inputs are normalized such that they contain the effective values in stack state:
namespace
- normalized to contain the ambient namespace ordefault
.context
- normalized to contain the ambient context name.cluster
normalized to contain the ambient cluster name.The
kubeconfig
property is not normalized, which means that the application would need to manually load the ambient config. It seems like a bad idea to normalize thekubeconfig
for a few reasons:The Helm provider was simplified to always take the merged kubeconfig (
apiConfig
) from the kube provider, as opposed to reloading it in some cases. This should have no effect on the behavior.Some minor improvements to kubeconfig loading logic:
kubeconfig
property is path-like, don't try to parse it as content. This improves the error message.default
namespace (as opposed to undefined) for diff purposes when the config could not be loaded.The special-case logic around 'replacement' was simplified to consider only the normalized server name. That is, the provider recommends replacement when the
name
field of the active server has changed. The earlier code had major limitations - it didn't consider the ambient kubeconfig, and didn't support kubeconfig paths.Testing
New tests were added and/or updated:
TestProvider
- updated to verify that the provider'snamespace
output property is useable as an input to other resources.TestProviderOutputs
- added to verify provider outputs and the normalization logic.Test_loadKubeconfig
- added to verify kubeconfig loading/parsing logic.New utility code was developed for easily asserting that certain engine events occurred during
ExtraRuntimeValidation
; seeutil.go#AssertEvents
.Example
Here's an example showing the use of the provider's new
namespace
output property, and showing the improved change detection related to the ambient namespace.The program relies on the ambient kubeconfig, uses the ambient namespace to create a
Deployment
, and binds the provider'snamespace
output property to the stack outputs:The procedure deploys the stack, changes the ambient namespace, and then previews the changes:
The resultant stack state:
Related issues (optional)