pulumi/tests/testdata/codegen/output-funcs/go/mypkg/x/funcWithDefaultValue.go

88 lines
2.7 KiB
Go

// Code generated by test DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package mypkg
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
"output-funcs/mypkg/internal"
)
// Check codegen of functions with default values.
func FuncWithDefaultValue(ctx *pulumi.Context, args *FuncWithDefaultValueArgs, opts ...pulumi.InvokeOption) (*FuncWithDefaultValueResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv FuncWithDefaultValueResult
err := ctx.Invoke("mypkg::funcWithDefaultValue", args.Defaults(), &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
type FuncWithDefaultValueArgs struct {
A string `pulumi:"a"`
B *string `pulumi:"b"`
}
// Defaults sets the appropriate defaults for FuncWithDefaultValueArgs
func (val *FuncWithDefaultValueArgs) Defaults() *FuncWithDefaultValueArgs {
if val == nil {
return nil
}
tmp := *val
if tmp.B == nil {
b_ := "b-default"
tmp.B = &b_
}
return &tmp
}
type FuncWithDefaultValueResult struct {
R string `pulumi:"r"`
}
func FuncWithDefaultValueOutput(ctx *pulumi.Context, args FuncWithDefaultValueOutputArgs, opts ...pulumi.InvokeOption) FuncWithDefaultValueResultOutput {
outputResult := pulumix.ApplyErr[*FuncWithDefaultValueArgs](args.ToOutput(), func(plainArgs *FuncWithDefaultValueArgs) (*FuncWithDefaultValueResult, error) {
return FuncWithDefaultValue(ctx, plainArgs, opts...)
})
return pulumix.Cast[FuncWithDefaultValueResultOutput, *FuncWithDefaultValueResult](outputResult)
}
type FuncWithDefaultValueOutputArgs struct {
A pulumix.Input[string] `pulumi:"a"`
B pulumix.Input[*string] `pulumi:"b"`
}
func (args FuncWithDefaultValueOutputArgs) ToOutput() pulumix.Output[*FuncWithDefaultValueArgs] {
allArgs := pulumix.All(
args.A.ToOutput(context.Background()).AsAny(),
args.B.ToOutput(context.Background()).AsAny())
return pulumix.Apply[[]any](allArgs, func(resolvedArgs []interface{}) *FuncWithDefaultValueArgs {
return &FuncWithDefaultValueArgs{
A: resolvedArgs[0].(string),
B: resolvedArgs[1].(*string),
}
})
}
type FuncWithDefaultValueResultOutput struct{ *pulumi.OutputState }
func (FuncWithDefaultValueResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*FuncWithDefaultValueResult)(nil)).Elem()
}
func (o FuncWithDefaultValueResultOutput) ToOutput(context.Context) pulumix.Output[*FuncWithDefaultValueResult] {
return pulumix.Output[*FuncWithDefaultValueResult]{
OutputState: o.OutputState,
}
}
func (o FuncWithDefaultValueResultOutput) R() pulumix.Output[string] {
return pulumix.Apply[*FuncWithDefaultValueResult](o, func(v *FuncWithDefaultValueResult) string { return v.R })
}