2021-07-28 01:00:39 +00:00
|
|
|
package utils
|
2020-04-07 02:43:16 +00:00
|
|
|
|
|
|
|
import (
|
2022-10-11 10:56:29 +00:00
|
|
|
"fmt"
|
|
|
|
|
2020-04-07 02:43:16 +00:00
|
|
|
"github.com/blang/semver"
|
2021-03-17 13:20:05 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/v3/resource/deploy/deploytest"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
|
2023-06-28 16:02:04 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/slice"
|
2022-06-14 06:27:11 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
|
2020-04-07 02:43:16 +00:00
|
|
|
)
|
|
|
|
|
2022-12-07 00:18:21 +00:00
|
|
|
type SchemaProvider struct {
|
|
|
|
name string
|
|
|
|
version string
|
|
|
|
}
|
|
|
|
|
2024-05-30 19:51:12 +00:00
|
|
|
func NewSchemaProvider(name, version string) SchemaProvider {
|
|
|
|
return SchemaProvider{name, version}
|
|
|
|
}
|
|
|
|
|
2022-10-11 10:56:29 +00:00
|
|
|
// NewHost creates a schema-only plugin host, supporting multiple package versions in tests. This
|
|
|
|
// enables running tests offline. If this host is used to load a plugin, that is, to run a Pulumi
|
|
|
|
// program, it will panic.
|
2022-12-07 00:18:21 +00:00
|
|
|
func NewHostWithProviders(schemaDirectoryPath string, providers ...SchemaProvider) plugin.Host {
|
2022-10-11 10:56:29 +00:00
|
|
|
mockProvider := func(name tokens.Package, version string) *deploytest.PluginLoader {
|
2022-07-20 22:12:02 +00:00
|
|
|
return deploytest.NewProviderLoader(name, semver.MustParse(version), func() (plugin.Provider, error) {
|
2022-10-11 10:56:29 +00:00
|
|
|
panic(fmt.Sprintf(
|
|
|
|
"expected plugin loader to use cached schema path, but cache was missed for package %v@%v, "+
|
|
|
|
"is an entry in the makefile or setup for this package missing?",
|
|
|
|
name, version))
|
2022-06-14 06:27:11 +00:00
|
|
|
}, deploytest.WithPath(schemaDirectoryPath))
|
|
|
|
}
|
|
|
|
|
2023-06-28 16:02:04 +00:00
|
|
|
pluginLoaders := slice.Prealloc[*deploytest.PluginLoader](len(providers))
|
2022-12-07 00:18:21 +00:00
|
|
|
|
|
|
|
for _, v := range providers {
|
|
|
|
pluginLoaders = append(pluginLoaders, mockProvider(tokens.Package(v.name), v.version))
|
|
|
|
}
|
|
|
|
|
2022-10-11 10:56:29 +00:00
|
|
|
// For the pulumi/pulumi repository, this must be kept in sync with the makefile and/or committed
|
|
|
|
// schema files in the given schema directory. This is the minimal set of schemas that must be
|
|
|
|
// supplied.
|
2020-04-07 02:43:16 +00:00
|
|
|
return deploytest.NewPluginHost(nil, nil, nil,
|
2022-12-07 00:18:21 +00:00
|
|
|
pluginLoaders...,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewHost creates a schema-only plugin host, supporting multiple package versions in tests. This
|
|
|
|
// enables running tests offline. If this host is used to load a plugin, that is, to run a Pulumi
|
|
|
|
// program, it will panic.
|
|
|
|
func NewHost(schemaDirectoryPath string) plugin.Host {
|
|
|
|
// For the pulumi/pulumi repository, this must be kept in sync with the makefile and/or committed
|
|
|
|
// schema files in the given schema directory. This is the minimal set of schemas that must be
|
|
|
|
// supplied.
|
|
|
|
return NewHostWithProviders(schemaDirectoryPath,
|
Support returning plain values from methods (#13592)
Support returning plain values from methods.
Implements Node, Python and Go support.
Remaining:
- [x] test receiving unknowns
- [x] acceptance tests written and passing locally for Node, Python, Go
clients against a Go server
- [x] acceptance tests passing in CI
- [x] tickets filed for remaining languages
- [x] https://github.com/pulumi/pulumi-yaml/issues/499
- [x] https://github.com/pulumi/pulumi-java/issues/1193
- [x] https://github.com/pulumi/pulumi-dotnet/issues/170
Known limitations:
- this is technically a breaking change in case there is code out there
that already uses methods that return Plain: true
- struct-wrapping limitation: the provider for the component resource
needs to still wrap the plain-returning Method response with a 1-arg
struct; by convention the field is named "res", and this is how it
travels through the plumbing
- resources cannot return plain values yet
- the provider for the component resource cannot have unknown
configuration, if it does, the methods will not be called
- Per Luke https://github.com/pulumi/pulumi/issues/11520 this might not
be supported/realizable yet
<!---
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
<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
Fixes https://github.com/pulumi/pulumi/issues/12709
## 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`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] 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. -->
2023-11-18 06:02:06 +00:00
|
|
|
SchemaProvider{"tls", "4.10.0"},
|
2022-12-07 00:18:21 +00:00
|
|
|
SchemaProvider{"aws", "4.15.0"},
|
|
|
|
SchemaProvider{"aws", "4.26.0"},
|
|
|
|
SchemaProvider{"aws", "4.36.0"},
|
|
|
|
SchemaProvider{"aws", "4.37.1"},
|
|
|
|
SchemaProvider{"aws", "5.16.2"},
|
|
|
|
SchemaProvider{"azure", "4.18.0"},
|
|
|
|
SchemaProvider{"azure-native", "1.28.0"},
|
|
|
|
SchemaProvider{"azure-native", "1.29.0"},
|
|
|
|
SchemaProvider{"random", "4.2.0"},
|
|
|
|
SchemaProvider{"random", "4.3.1"},
|
2023-03-01 22:26:18 +00:00
|
|
|
SchemaProvider{"random", "4.11.2"},
|
2022-12-07 00:18:21 +00:00
|
|
|
SchemaProvider{"kubernetes", "3.7.0"},
|
|
|
|
SchemaProvider{"kubernetes", "3.7.2"},
|
|
|
|
SchemaProvider{"eks", "0.37.1"},
|
|
|
|
SchemaProvider{"google-native", "0.18.2"},
|
2023-07-27 17:00:02 +00:00
|
|
|
SchemaProvider{"google-native", "0.27.0"},
|
2024-03-24 00:06:57 +00:00
|
|
|
SchemaProvider{"aws-native", "0.99.0"},
|
2022-12-07 00:18:21 +00:00
|
|
|
SchemaProvider{"docker", "3.1.0"},
|
2023-01-11 22:17:14 +00:00
|
|
|
SchemaProvider{"std", "1.0.0"},
|
2022-10-20 20:37:10 +00:00
|
|
|
// PCL examples in 'testing/test/testdata/transpiled_examples require these versions
|
2022-12-07 00:18:21 +00:00
|
|
|
SchemaProvider{"aws", "5.4.0"},
|
|
|
|
SchemaProvider{"azure-native", "1.56.0"},
|
|
|
|
SchemaProvider{"eks", "0.40.0"},
|
|
|
|
SchemaProvider{"aws-native", "0.13.0"},
|
|
|
|
SchemaProvider{"docker", "4.0.0-alpha.0"},
|
|
|
|
SchemaProvider{"awsx", "1.0.0-beta.5"},
|
|
|
|
SchemaProvider{"kubernetes", "3.0.0"},
|
|
|
|
SchemaProvider{"aws", "4.37.1"},
|
|
|
|
|
|
|
|
SchemaProvider{"other", "0.1.0"},
|
|
|
|
SchemaProvider{"synthetic", "1.0.0"},
|
2024-03-28 10:49:27 +00:00
|
|
|
SchemaProvider{"basic-unions", "0.1.0"},
|
2023-04-26 18:00:32 +00:00
|
|
|
SchemaProvider{"range", "1.0.0"},
|
2023-03-16 14:41:04 +00:00
|
|
|
SchemaProvider{"lambda", "0.1.0"},
|
2023-05-23 13:50:23 +00:00
|
|
|
SchemaProvider{"remoteref", "1.0.0"},
|
2023-06-07 11:22:41 +00:00
|
|
|
SchemaProvider{"splat", "1.0.0"},
|
2023-06-08 23:44:09 +00:00
|
|
|
SchemaProvider{"snowflake", "0.66.1"},
|
2023-06-20 16:11:47 +00:00
|
|
|
SchemaProvider{"using-dashes", "1.0.0"},
|
2023-07-13 23:23:27 +00:00
|
|
|
SchemaProvider{"auto-deploy", "0.0.1"},
|
2023-08-08 17:20:56 +00:00
|
|
|
SchemaProvider{"localref", "1.0.0"},
|
2023-09-12 18:34:40 +00:00
|
|
|
SchemaProvider{"enum", "1.0.0"},
|
2023-11-27 11:05:03 +00:00
|
|
|
SchemaProvider{"plain-properties", "1.0.0"},
|
2024-02-20 15:49:08 +00:00
|
|
|
SchemaProvider{"recursive", "1.0.0"},
|
2024-03-10 17:23:15 +00:00
|
|
|
SchemaProvider{"aws-static-website", "0.4.0"},
|
2024-06-18 15:24:42 +00:00
|
|
|
SchemaProvider{"typeddict", "1.0.0"},
|
2022-05-20 17:29:05 +00:00
|
|
|
)
|
2020-04-07 02:43:16 +00:00
|
|
|
}
|