pulumi/tests/testdata/codegen/replace-on-change/go/example/noRecursive.go

211 lines
6.3 KiB
Go
Raw Permalink Normal View History

// Code generated by test DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package example
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
2023-06-14 16:34:49 +00:00
"replace-on-change/example/internal"
)
type NoRecursive struct {
pulumi.CustomResourceState
[sdkgen/python] Replace-on-changes values should be camelCased (#15666) <!--- 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 When replaceOnChanges is set in the schema for a property with a multi-word name, currently, Python SDK generation incorrectly puts its Python name into replace_on_changes. This is wrong, because these property names are passed to the engine and they should be engine names (i.e. schema names). All other languages (Node.js, .NET, Go) do this correctly. This PR adds a test case and fixes the Python generation to use the same naming as all other SDKs. Fixes #15665 ## 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. --> - [x] 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-03-13 15:43:56 +00:00
Rec RecPtrOutput `pulumi:"rec"`
ReplaceMe pulumi.StringPtrOutput `pulumi:"replaceMe"`
}
// NewNoRecursive registers a new resource with the given unique name, arguments, and options.
func NewNoRecursive(ctx *pulumi.Context,
name string, args *NoRecursiveArgs, opts ...pulumi.ResourceOption) (*NoRecursive, error) {
if args == nil {
args = &NoRecursiveArgs{}
}
replaceOnChanges := pulumi.ReplaceOnChanges([]string{
[sdkgen/python] Replace-on-changes values should be camelCased (#15666) <!--- 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 When replaceOnChanges is set in the schema for a property with a multi-word name, currently, Python SDK generation incorrectly puts its Python name into replace_on_changes. This is wrong, because these property names are passed to the engine and they should be engine names (i.e. schema names). All other languages (Node.js, .NET, Go) do this correctly. This PR adds a test case and fixes the Python generation to use the same naming as all other SDKs. Fixes #15665 ## 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. --> - [x] 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-03-13 15:43:56 +00:00
"replaceMe",
})
opts = append(opts, replaceOnChanges)
2023-06-14 16:34:49 +00:00
opts = internal.PkgResourceDefaultOpts(opts)
var resource NoRecursive
err := ctx.RegisterResource("example::NoRecursive", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetNoRecursive gets an existing NoRecursive resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetNoRecursive(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *NoRecursiveState, opts ...pulumi.ResourceOption) (*NoRecursive, error) {
var resource NoRecursive
err := ctx.ReadResource("example::NoRecursive", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering NoRecursive resources.
type noRecursiveState struct {
}
type NoRecursiveState struct {
}
func (NoRecursiveState) ElementType() reflect.Type {
return reflect.TypeOf((*noRecursiveState)(nil)).Elem()
}
type noRecursiveArgs struct {
}
// The set of arguments for constructing a NoRecursive resource.
type NoRecursiveArgs struct {
}
func (NoRecursiveArgs) ElementType() reflect.Type {
return reflect.TypeOf((*noRecursiveArgs)(nil)).Elem()
}
type NoRecursiveInput interface {
pulumi.Input
ToNoRecursiveOutput() NoRecursiveOutput
ToNoRecursiveOutputWithContext(ctx context.Context) NoRecursiveOutput
}
func (*NoRecursive) ElementType() reflect.Type {
[codegen/go] Remove ResourcePtr input/output types (#8449) These changes remove the `Ptr` variants of input/ouptut types for resources. A `TPtr` input or output is normally generated for `T` if `T` is present in an `optional(input(T))` or `optional(output(T))` and if the Go representation for `T` is not nilable. The generation of `Ptr` variants for resource types breaks the latter rule: the canonical representation of a resource type named `Foo` is a pointer to a struct type named `Foo` (i.e. `*Foo`). `Foo` itself is not a resource, as it does not implement the Go `Resource` interface. Because this representation already accommodates `nil` to indicate the lack of a value, we need not generate `FooPtr{Input,Output}` types. Besides being unnecessary, the implementation of `Ptr` types for resources was incorrect. Rather than using `**Foo` as their element type, these types use `*Foo`--identical to the element type used for the normal input/output types. Furthermore, the generated code for at least `FooOutput.ToFooPtrOutputWithContext` and `FooPtrOutput.Elem` was incorrect, making these types virtually unusable in practice. Finally, these `Ptr` types should never appear on input/output properties in practice, as the logic we use to generate input and output type references never generates them for `optional({input,output}(T)). Instead, it generates references to the standard input/output types. Though this is _technically_ a breaking change--it changes the set of exported types for any package that defines resources--I believe that in practice it will be invisible to users for the reasons stated above. These types are not usable, and were never referenced. This is preparatory work for #7943.
2021-11-23 18:24:56 +00:00
return reflect.TypeOf((**NoRecursive)(nil)).Elem()
}
func (i *NoRecursive) ToNoRecursiveOutput() NoRecursiveOutput {
return i.ToNoRecursiveOutputWithContext(context.Background())
}
func (i *NoRecursive) ToNoRecursiveOutputWithContext(ctx context.Context) NoRecursiveOutput {
return pulumi.ToOutputWithContext(ctx, i).(NoRecursiveOutput)
}
// NoRecursiveArrayInput is an input type that accepts NoRecursiveArray and NoRecursiveArrayOutput values.
// You can construct a concrete instance of `NoRecursiveArrayInput` via:
//
2022-09-14 02:12:02 +00:00
// NoRecursiveArray{ NoRecursiveArgs{...} }
type NoRecursiveArrayInput interface {
pulumi.Input
ToNoRecursiveArrayOutput() NoRecursiveArrayOutput
ToNoRecursiveArrayOutputWithContext(context.Context) NoRecursiveArrayOutput
}
type NoRecursiveArray []NoRecursiveInput
func (NoRecursiveArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*NoRecursive)(nil)).Elem()
}
func (i NoRecursiveArray) ToNoRecursiveArrayOutput() NoRecursiveArrayOutput {
return i.ToNoRecursiveArrayOutputWithContext(context.Background())
}
func (i NoRecursiveArray) ToNoRecursiveArrayOutputWithContext(ctx context.Context) NoRecursiveArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(NoRecursiveArrayOutput)
}
// NoRecursiveMapInput is an input type that accepts NoRecursiveMap and NoRecursiveMapOutput values.
// You can construct a concrete instance of `NoRecursiveMapInput` via:
//
2022-09-14 02:12:02 +00:00
// NoRecursiveMap{ "key": NoRecursiveArgs{...} }
type NoRecursiveMapInput interface {
pulumi.Input
ToNoRecursiveMapOutput() NoRecursiveMapOutput
ToNoRecursiveMapOutputWithContext(context.Context) NoRecursiveMapOutput
}
type NoRecursiveMap map[string]NoRecursiveInput
func (NoRecursiveMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*NoRecursive)(nil)).Elem()
}
func (i NoRecursiveMap) ToNoRecursiveMapOutput() NoRecursiveMapOutput {
return i.ToNoRecursiveMapOutputWithContext(context.Background())
}
func (i NoRecursiveMap) ToNoRecursiveMapOutputWithContext(ctx context.Context) NoRecursiveMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(NoRecursiveMapOutput)
}
type NoRecursiveOutput struct{ *pulumi.OutputState }
func (NoRecursiveOutput) ElementType() reflect.Type {
[codegen/go] Remove ResourcePtr input/output types (#8449) These changes remove the `Ptr` variants of input/ouptut types for resources. A `TPtr` input or output is normally generated for `T` if `T` is present in an `optional(input(T))` or `optional(output(T))` and if the Go representation for `T` is not nilable. The generation of `Ptr` variants for resource types breaks the latter rule: the canonical representation of a resource type named `Foo` is a pointer to a struct type named `Foo` (i.e. `*Foo`). `Foo` itself is not a resource, as it does not implement the Go `Resource` interface. Because this representation already accommodates `nil` to indicate the lack of a value, we need not generate `FooPtr{Input,Output}` types. Besides being unnecessary, the implementation of `Ptr` types for resources was incorrect. Rather than using `**Foo` as their element type, these types use `*Foo`--identical to the element type used for the normal input/output types. Furthermore, the generated code for at least `FooOutput.ToFooPtrOutputWithContext` and `FooPtrOutput.Elem` was incorrect, making these types virtually unusable in practice. Finally, these `Ptr` types should never appear on input/output properties in practice, as the logic we use to generate input and output type references never generates them for `optional({input,output}(T)). Instead, it generates references to the standard input/output types. Though this is _technically_ a breaking change--it changes the set of exported types for any package that defines resources--I believe that in practice it will be invisible to users for the reasons stated above. These types are not usable, and were never referenced. This is preparatory work for #7943.
2021-11-23 18:24:56 +00:00
return reflect.TypeOf((**NoRecursive)(nil)).Elem()
}
func (o NoRecursiveOutput) ToNoRecursiveOutput() NoRecursiveOutput {
return o
}
func (o NoRecursiveOutput) ToNoRecursiveOutputWithContext(ctx context.Context) NoRecursiveOutput {
return o
}
func (o NoRecursiveOutput) Rec() RecPtrOutput {
return o.ApplyT(func(v *NoRecursive) RecPtrOutput { return v.Rec }).(RecPtrOutput)
}
[sdkgen/python] Replace-on-changes values should be camelCased (#15666) <!--- 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 When replaceOnChanges is set in the schema for a property with a multi-word name, currently, Python SDK generation incorrectly puts its Python name into replace_on_changes. This is wrong, because these property names are passed to the engine and they should be engine names (i.e. schema names). All other languages (Node.js, .NET, Go) do this correctly. This PR adds a test case and fixes the Python generation to use the same naming as all other SDKs. Fixes #15665 ## 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. --> - [x] 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-03-13 15:43:56 +00:00
func (o NoRecursiveOutput) ReplaceMe() pulumi.StringPtrOutput {
return o.ApplyT(func(v *NoRecursive) pulumi.StringPtrOutput { return v.ReplaceMe }).(pulumi.StringPtrOutput)
}
type NoRecursiveArrayOutput struct{ *pulumi.OutputState }
func (NoRecursiveArrayOutput) ElementType() reflect.Type {
[codegen/go] Remove ResourcePtr input/output types (#8449) These changes remove the `Ptr` variants of input/ouptut types for resources. A `TPtr` input or output is normally generated for `T` if `T` is present in an `optional(input(T))` or `optional(output(T))` and if the Go representation for `T` is not nilable. The generation of `Ptr` variants for resource types breaks the latter rule: the canonical representation of a resource type named `Foo` is a pointer to a struct type named `Foo` (i.e. `*Foo`). `Foo` itself is not a resource, as it does not implement the Go `Resource` interface. Because this representation already accommodates `nil` to indicate the lack of a value, we need not generate `FooPtr{Input,Output}` types. Besides being unnecessary, the implementation of `Ptr` types for resources was incorrect. Rather than using `**Foo` as their element type, these types use `*Foo`--identical to the element type used for the normal input/output types. Furthermore, the generated code for at least `FooOutput.ToFooPtrOutputWithContext` and `FooPtrOutput.Elem` was incorrect, making these types virtually unusable in practice. Finally, these `Ptr` types should never appear on input/output properties in practice, as the logic we use to generate input and output type references never generates them for `optional({input,output}(T)). Instead, it generates references to the standard input/output types. Though this is _technically_ a breaking change--it changes the set of exported types for any package that defines resources--I believe that in practice it will be invisible to users for the reasons stated above. These types are not usable, and were never referenced. This is preparatory work for #7943.
2021-11-23 18:24:56 +00:00
return reflect.TypeOf((*[]*NoRecursive)(nil)).Elem()
}
func (o NoRecursiveArrayOutput) ToNoRecursiveArrayOutput() NoRecursiveArrayOutput {
return o
}
func (o NoRecursiveArrayOutput) ToNoRecursiveArrayOutputWithContext(ctx context.Context) NoRecursiveArrayOutput {
return o
}
func (o NoRecursiveArrayOutput) Index(i pulumi.IntInput) NoRecursiveOutput {
[codegen/go] Remove ResourcePtr input/output types (#8449) These changes remove the `Ptr` variants of input/ouptut types for resources. A `TPtr` input or output is normally generated for `T` if `T` is present in an `optional(input(T))` or `optional(output(T))` and if the Go representation for `T` is not nilable. The generation of `Ptr` variants for resource types breaks the latter rule: the canonical representation of a resource type named `Foo` is a pointer to a struct type named `Foo` (i.e. `*Foo`). `Foo` itself is not a resource, as it does not implement the Go `Resource` interface. Because this representation already accommodates `nil` to indicate the lack of a value, we need not generate `FooPtr{Input,Output}` types. Besides being unnecessary, the implementation of `Ptr` types for resources was incorrect. Rather than using `**Foo` as their element type, these types use `*Foo`--identical to the element type used for the normal input/output types. Furthermore, the generated code for at least `FooOutput.ToFooPtrOutputWithContext` and `FooPtrOutput.Elem` was incorrect, making these types virtually unusable in practice. Finally, these `Ptr` types should never appear on input/output properties in practice, as the logic we use to generate input and output type references never generates them for `optional({input,output}(T)). Instead, it generates references to the standard input/output types. Though this is _technically_ a breaking change--it changes the set of exported types for any package that defines resources--I believe that in practice it will be invisible to users for the reasons stated above. These types are not usable, and were never referenced. This is preparatory work for #7943.
2021-11-23 18:24:56 +00:00
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *NoRecursive {
return vs[0].([]*NoRecursive)[vs[1].(int)]
}).(NoRecursiveOutput)
}
type NoRecursiveMapOutput struct{ *pulumi.OutputState }
func (NoRecursiveMapOutput) ElementType() reflect.Type {
[codegen/go] Remove ResourcePtr input/output types (#8449) These changes remove the `Ptr` variants of input/ouptut types for resources. A `TPtr` input or output is normally generated for `T` if `T` is present in an `optional(input(T))` or `optional(output(T))` and if the Go representation for `T` is not nilable. The generation of `Ptr` variants for resource types breaks the latter rule: the canonical representation of a resource type named `Foo` is a pointer to a struct type named `Foo` (i.e. `*Foo`). `Foo` itself is not a resource, as it does not implement the Go `Resource` interface. Because this representation already accommodates `nil` to indicate the lack of a value, we need not generate `FooPtr{Input,Output}` types. Besides being unnecessary, the implementation of `Ptr` types for resources was incorrect. Rather than using `**Foo` as their element type, these types use `*Foo`--identical to the element type used for the normal input/output types. Furthermore, the generated code for at least `FooOutput.ToFooPtrOutputWithContext` and `FooPtrOutput.Elem` was incorrect, making these types virtually unusable in practice. Finally, these `Ptr` types should never appear on input/output properties in practice, as the logic we use to generate input and output type references never generates them for `optional({input,output}(T)). Instead, it generates references to the standard input/output types. Though this is _technically_ a breaking change--it changes the set of exported types for any package that defines resources--I believe that in practice it will be invisible to users for the reasons stated above. These types are not usable, and were never referenced. This is preparatory work for #7943.
2021-11-23 18:24:56 +00:00
return reflect.TypeOf((*map[string]*NoRecursive)(nil)).Elem()
}
func (o NoRecursiveMapOutput) ToNoRecursiveMapOutput() NoRecursiveMapOutput {
return o
}
func (o NoRecursiveMapOutput) ToNoRecursiveMapOutputWithContext(ctx context.Context) NoRecursiveMapOutput {
return o
}
func (o NoRecursiveMapOutput) MapIndex(k pulumi.StringInput) NoRecursiveOutput {
[codegen/go] Remove ResourcePtr input/output types (#8449) These changes remove the `Ptr` variants of input/ouptut types for resources. A `TPtr` input or output is normally generated for `T` if `T` is present in an `optional(input(T))` or `optional(output(T))` and if the Go representation for `T` is not nilable. The generation of `Ptr` variants for resource types breaks the latter rule: the canonical representation of a resource type named `Foo` is a pointer to a struct type named `Foo` (i.e. `*Foo`). `Foo` itself is not a resource, as it does not implement the Go `Resource` interface. Because this representation already accommodates `nil` to indicate the lack of a value, we need not generate `FooPtr{Input,Output}` types. Besides being unnecessary, the implementation of `Ptr` types for resources was incorrect. Rather than using `**Foo` as their element type, these types use `*Foo`--identical to the element type used for the normal input/output types. Furthermore, the generated code for at least `FooOutput.ToFooPtrOutputWithContext` and `FooPtrOutput.Elem` was incorrect, making these types virtually unusable in practice. Finally, these `Ptr` types should never appear on input/output properties in practice, as the logic we use to generate input and output type references never generates them for `optional({input,output}(T)). Instead, it generates references to the standard input/output types. Though this is _technically_ a breaking change--it changes the set of exported types for any package that defines resources--I believe that in practice it will be invisible to users for the reasons stated above. These types are not usable, and were never referenced. This is preparatory work for #7943.
2021-11-23 18:24:56 +00:00
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *NoRecursive {
return vs[0].(map[string]*NoRecursive)[vs[1].(string)]
}).(NoRecursiveOutput)
}
func init() {
pulumi.RegisterOutputType(NoRecursiveOutput{})
pulumi.RegisterOutputType(NoRecursiveArrayOutput{})
pulumi.RegisterOutputType(NoRecursiveMapOutput{})
}