2022-04-19 16:39:23 +00:00
|
|
|
// Code generated by test DO NOT EDIT.
|
|
|
|
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
|
2021-07-06 22:40:53 +00:00
|
|
|
|
|
|
|
package example
|
|
|
|
|
|
|
|
import (
|
2021-08-23 20:46:09 +00:00
|
|
|
"context"
|
|
|
|
"reflect"
|
|
|
|
|
2021-07-06 22:40:53 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
2023-06-14 19:59:47 +00:00
|
|
|
"simple-resource-schema-custom-pypackage-name/example/internal"
|
2021-07-06 22:40:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func ArgFunction(ctx *pulumi.Context, args *ArgFunctionArgs, opts ...pulumi.InvokeOption) (*ArgFunctionResult, error) {
|
2023-06-14 16:34:49 +00:00
|
|
|
opts = internal.PkgInvokeDefaultOpts(opts)
|
2021-07-06 22:40:53 +00:00
|
|
|
var rv ArgFunctionResult
|
|
|
|
err := ctx.Invoke("example::argFunction", args, &rv, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &rv, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type ArgFunctionArgs struct {
|
|
|
|
Arg1 *Resource `pulumi:"arg1"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ArgFunctionResult struct {
|
|
|
|
Result *Resource `pulumi:"result"`
|
|
|
|
}
|
2021-08-23 20:46:09 +00:00
|
|
|
|
|
|
|
func ArgFunctionOutput(ctx *pulumi.Context, args ArgFunctionOutputArgs, opts ...pulumi.InvokeOption) ArgFunctionResultOutput {
|
|
|
|
return pulumi.ToOutputWithContext(context.Background(), args).
|
2024-09-09 12:57:43 +00:00
|
|
|
ApplyT(func(v interface{}) (ArgFunctionResultOutput, error) {
|
2021-08-23 20:46:09 +00:00
|
|
|
args := v.(ArgFunctionArgs)
|
2024-09-09 12:57:43 +00:00
|
|
|
opts = internal.PkgInvokeDefaultOpts(opts)
|
|
|
|
var rv ArgFunctionResult
|
|
|
|
secret, err := ctx.InvokePackageRaw("example::argFunction", args, &rv, "", opts...)
|
|
|
|
if err != nil {
|
|
|
|
return ArgFunctionResultOutput{}, err
|
[codegen/go] Update Go SDK function output to check for errors (#9274)
* [codegen/go] Update Go SDK function output to check for errors
Fixes https://github.com/pulumi/pulumi-aws/issues/1872.
This should result in the following sample output in the Go SDK:
```
func GetPolicyDocumentOutput(ctx *pulumi.Context, args GetPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyDocumentResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetPolicyDocumentResult, error) {
args := v.(GetPolicyDocumentArgs)
r, err := GetPolicyDocument(ctx, &args, opts...)
if err != nil {
return nil, err
}
if r == nil {
return nil, fmt.Errorf("expected either result or error to be nil, not both")
}
return *r, err
}).(GetPolicyDocumentResultOutput)
}
```
* Fix generated code panic on *nil (#9284)
* [codegen/go] Update Go SDK function output to check for errors
Fixes https://github.com/pulumi/pulumi-aws/issues/1872.
This should result in the following sample output in the Go SDK:
```
func GetPolicyDocumentOutput(ctx *pulumi.Context, args GetPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyDocumentResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetPolicyDocumentResult, error) {
args := v.(GetPolicyDocumentArgs)
r, err := GetPolicyDocument(ctx, &args, opts...)
if r != nil {
s = *r
}
return s, err
}).(GetPolicyDocumentResultOutput)
}
```
* Alternate fix to safeguard dereferencing nil
* Accept codegen changes in the test suite
Co-authored-by: Guinevere Saenger <guinevere@pulumi.com>
* Update CHANGELOG_PENDING.md
Co-authored-by: Anton Tayanovskyy <anton@pulumi.com>
2022-03-25 03:11:53 +00:00
|
|
|
}
|
2024-09-09 12:57:43 +00:00
|
|
|
|
|
|
|
output := pulumi.ToOutput(rv).(ArgFunctionResultOutput)
|
|
|
|
if secret {
|
|
|
|
return pulumi.ToSecret(output).(ArgFunctionResultOutput), nil
|
|
|
|
}
|
|
|
|
return output, nil
|
2021-08-23 20:46:09 +00:00
|
|
|
}).(ArgFunctionResultOutput)
|
|
|
|
}
|
|
|
|
|
|
|
|
type ArgFunctionOutputArgs struct {
|
|
|
|
Arg1 ResourceInput `pulumi:"arg1"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ArgFunctionOutputArgs) ElementType() reflect.Type {
|
|
|
|
return reflect.TypeOf((*ArgFunctionArgs)(nil)).Elem()
|
|
|
|
}
|
|
|
|
|
|
|
|
type ArgFunctionResultOutput struct{ *pulumi.OutputState }
|
|
|
|
|
|
|
|
func (ArgFunctionResultOutput) ElementType() reflect.Type {
|
|
|
|
return reflect.TypeOf((*ArgFunctionResult)(nil)).Elem()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o ArgFunctionResultOutput) ToArgFunctionResultOutput() ArgFunctionResultOutput {
|
|
|
|
return o
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o ArgFunctionResultOutput) ToArgFunctionResultOutputWithContext(ctx context.Context) ArgFunctionResultOutput {
|
|
|
|
return o
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o ArgFunctionResultOutput) Result() ResourceOutput {
|
|
|
|
return o.ApplyT(func(v ArgFunctionResult) *Resource { return v.Result }).(ResourceOutput)
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
pulumi.RegisterOutputType(ArgFunctionResultOutput{})
|
|
|
|
}
|