[sdk/{go,nodejs,python}] Fix DeletedWith resource option
This change fixes the `DeletedWith` resource option in the Go, Node.js,
and Python SDKs and adds tests.
This feature was a community contribution and while there were engine
tests included with the original PR, there weren't any tests confirming
the functionality worked correctly from each SDK.
Here's a summary of the fixes:
* Go: The `DeletedWith` resource option was never usable as it accepted
a URN instead of a Resource. We discussed this internally a while back
and decided to go ahead and fix this. (Note: While changing the
signature is technically a breaking change, the feature is currently
unusable, so the change would not break anyone, so there's no need to
wait for a major version bump.)
* Node.js: The `deletedWith` resource option did not work at all from
the Node.js SDK because it was incorrectly passing the resource object
itself in the RegisterResource request, rather than the resource's
URN.
* Python: The `deleted_with` resource option did not work at all from
the Python SDK because it was incorrectly passing the resource object
itself in the RegisterResource request, rather than the resource's
URN.
A `FailsOnDelete` resource has been added to the testprovider, which
will fail when its `Delete` gRPC is called. The tests use this to ensure
`Delete` is not called for resources of this type with the `DeletedWith`
option specified.
2023-01-16 00:19:26 +00:00
|
|
|
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
|
|
|
|
//go:build !all
|
|
|
|
// +build !all
|
|
|
|
|
|
|
|
// Exposes the Random resource from the testprovider.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Random struct {
|
|
|
|
pulumi.CustomResourceState
|
|
|
|
|
|
|
|
Length pulumi.IntOutput `pulumi:"length"`
|
|
|
|
Result pulumi.StringOutput `pulumi:"result"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewRandom(ctx *pulumi.Context,
|
2023-03-03 16:36:39 +00:00
|
|
|
name string, args *RandomArgs, opts ...pulumi.ResourceOption,
|
|
|
|
) (*Random, error) {
|
[sdk/{go,nodejs,python}] Fix DeletedWith resource option
This change fixes the `DeletedWith` resource option in the Go, Node.js,
and Python SDKs and adds tests.
This feature was a community contribution and while there were engine
tests included with the original PR, there weren't any tests confirming
the functionality worked correctly from each SDK.
Here's a summary of the fixes:
* Go: The `DeletedWith` resource option was never usable as it accepted
a URN instead of a Resource. We discussed this internally a while back
and decided to go ahead and fix this. (Note: While changing the
signature is technically a breaking change, the feature is currently
unusable, so the change would not break anyone, so there's no need to
wait for a major version bump.)
* Node.js: The `deletedWith` resource option did not work at all from
the Node.js SDK because it was incorrectly passing the resource object
itself in the RegisterResource request, rather than the resource's
URN.
* Python: The `deleted_with` resource option did not work at all from
the Python SDK because it was incorrectly passing the resource object
itself in the RegisterResource request, rather than the resource's
URN.
A `FailsOnDelete` resource has been added to the testprovider, which
will fail when its `Delete` gRPC is called. The tests use this to ensure
`Delete` is not called for resources of this type with the `DeletedWith`
option specified.
2023-01-16 00:19:26 +00:00
|
|
|
if args == nil || args.Length == nil {
|
|
|
|
return nil, errors.New("missing required argument 'Length'")
|
|
|
|
}
|
|
|
|
if args == nil {
|
|
|
|
args = &RandomArgs{}
|
|
|
|
}
|
|
|
|
var resource Random
|
|
|
|
err := ctx.RegisterResource("testprovider:index:Random", name, args, &resource, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &resource, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type randomArgs struct {
|
|
|
|
Length int `pulumi:"length"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type RandomArgs struct {
|
|
|
|
Length pulumi.IntInput
|
|
|
|
}
|
|
|
|
|
|
|
|
func (RandomArgs) ElementType() reflect.Type {
|
|
|
|
return reflect.TypeOf((*randomArgs)(nil)).Elem()
|
|
|
|
}
|