pulumi/pkg/resource
Eron Wright 89d3467b0f
Canonicalize provider version during default provider lookup (#16109)
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

This PR addresses a problem that leads to two default providers for a
given package+version. The problem occurs when given a combination of
unversioned and versioned provider requests, as can occur in
multi-language programs.

The fix is as follows: given an unversioned provider request, apply the
default version before looking into the provider cache.

Fixes #16108 

## Example
Given the example program from #16108 plus this fix, the stack state has
one provider as expected:

```jsonl
{
    "urn": "urn:pulumi:dev::issue-1939-nodejs::pulumi:providers:kubernetes::default_4_10_0",
    "custom": true,
    "id": "c19b65b0-dd5a-432f-8c75-d7544de782ec",
    "type": "pulumi:providers:kubernetes",
    "inputs": {
        "version": "4.10.0"
    },
    "outputs": {
        "version": "4.10.0"
    },
    "created": "2024-05-02T21:22:09.72166Z",
    "modified": "2024-05-02T21:22:09.72166Z"
}
{
    "urn": "urn:pulumi:dev::issue-1939-nodejs::kubernetes:yaml/v2:ConfigGroup$kubernetes:core/v1:ConfigMap::example:eron/example",
    "custom": true,
    "id": "eron/example",
    "type": "kubernetes:core/v1:ConfigMap",
    "parent": "urn:pulumi:dev::issue-1939-nodejs::kubernetes:yaml/v2:ConfigGroup::example",
    "provider": "urn:pulumi:dev::issue-1939-nodejs::pulumi:providers:kubernetes::default_4_10_0::c19b65b0-dd5a-432f-8c75-d7544de782ec",
    "propertyDependencies": {
        "apiVersion": [],
        "kind": [],
        "metadata": []
    },
}
```

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-05-06 08:22:28 +00:00
..
analyzer Clean up uses of .Error() (#14965) 2023-12-20 15:54:06 +00:00
deploy Canonicalize provider version during default provider lookup (#16109) 2024-05-06 08:22:28 +00:00
edit State: fix panic when deleting non-unique Provider (#15322) 2024-02-05 16:21:38 +00:00
graph Better handle property dependencies and `deletedWith` (#16088) 2024-05-03 17:08:06 +00:00
provider turn on the golangci-lint exhaustive linter (#15028) 2024-01-17 16:50:41 +00:00
stack Revert "Run integration tests and dev builds with race detection" (#15998) 2024-04-19 16:57:16 +00:00
testdata ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00