4b7985384c
* Add test case * Fix tests * Add test dependencies correctly * Feed through error handling * Include test output * Get types to line up * Add remaining test files * Update changelog * Correctly find type paths * Handle transitive objects * Handle required fields * Add feature flag for go * Add required+default test case * Don't `<any>` cast known types. * Add more flags. I realize this should really wait for PR#8400 to merge. * Add plain object to env-helper test This test fails right now. My next problem is fixing it. * Handle plain types * Handle function inputs * Fix the indentation * Handle output types correctly * Remove unnecessary `!` * Add test case * Fix tests * Add test dependencies correctly * Feed through error handling * Include test output * Get types to line up * Add remaining test files * Update changelog * Correctly find type paths * Handle transitive objects * Handle required fields * Add required+default test case * Don't `<any>` cast known types. * Add plain object to env-helper test This test fails right now. My next problem is fixing it. * Handle plain types * Handle function inputs * Fix the indentation * Handle output types correctly * Remove unnecessary `!` * Start on `genPlainObjectDefaultFunc` * Add missing change to fix test * Run tests with merge * Refactor out assign * Merge in next _index.md diff * Change method name to `Defaults` * Handle enums correctly * Another attempt at _index.md * Make module generation deterministic * Add checks for old values * Insert defaults in resources * Fix docs generation Credit to @praneetloke * Progress on adding defaults to Resource arguments * Handle resource argument defaults * Don't create defaults if disableObjectDefaults * Rename test folder * Add test for disable flag * Fix disable test * Update docs * Abstract out nil comparisons * Use reflection to test for empty values * Simplify Ptr and pulumi.Any type handling * Remove unused function * Apply defaults to functions * Update new test with master codegen * Tests + nil check
116 lines
3.2 KiB
Go
116 lines
3.2 KiB
Go
// *** WARNING: this file was generated by test. ***
|
|
// *** 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"
|
|
"plain-object-defaults/example/mod1"
|
|
)
|
|
|
|
type ModuleTest struct {
|
|
pulumi.CustomResourceState
|
|
}
|
|
|
|
// NewModuleTest registers a new resource with the given unique name, arguments, and options.
|
|
func NewModuleTest(ctx *pulumi.Context,
|
|
name string, args *ModuleTestArgs, opts ...pulumi.ResourceOption) (*ModuleTest, error) {
|
|
if args == nil {
|
|
args = &ModuleTestArgs{}
|
|
}
|
|
|
|
mod1Applier := func(v mod1.Typ) *mod1.Typ { return v.Defaults() }
|
|
if args.Mod1 != nil {
|
|
args.Mod1 = args.Mod1.ToTypPtrOutput().Elem().ApplyT(mod1Applier).(mod1.TypPtrOutput)
|
|
}
|
|
valApplier := func(v Typ) *Typ { return v.Defaults() }
|
|
if args.Val != nil {
|
|
args.Val = args.Val.ToTypPtrOutput().Elem().ApplyT(valApplier).(TypPtrOutput)
|
|
}
|
|
var resource ModuleTest
|
|
err := ctx.RegisterResource("example:index:moduleTest", name, args, &resource, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &resource, nil
|
|
}
|
|
|
|
// GetModuleTest gets an existing ModuleTest 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 GetModuleTest(ctx *pulumi.Context,
|
|
name string, id pulumi.IDInput, state *ModuleTestState, opts ...pulumi.ResourceOption) (*ModuleTest, error) {
|
|
var resource ModuleTest
|
|
err := ctx.ReadResource("example:index:moduleTest", name, id, state, &resource, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &resource, nil
|
|
}
|
|
|
|
// Input properties used for looking up and filtering ModuleTest resources.
|
|
type moduleTestState struct {
|
|
}
|
|
|
|
type ModuleTestState struct {
|
|
}
|
|
|
|
func (ModuleTestState) ElementType() reflect.Type {
|
|
return reflect.TypeOf((*moduleTestState)(nil)).Elem()
|
|
}
|
|
|
|
type moduleTestArgs struct {
|
|
Mod1 *mod1.Typ `pulumi:"mod1"`
|
|
Val *Typ `pulumi:"val"`
|
|
}
|
|
|
|
// The set of arguments for constructing a ModuleTest resource.
|
|
type ModuleTestArgs struct {
|
|
Mod1 mod1.TypPtrInput
|
|
Val TypPtrInput
|
|
}
|
|
|
|
func (ModuleTestArgs) ElementType() reflect.Type {
|
|
return reflect.TypeOf((*moduleTestArgs)(nil)).Elem()
|
|
}
|
|
|
|
type ModuleTestInput interface {
|
|
pulumi.Input
|
|
|
|
ToModuleTestOutput() ModuleTestOutput
|
|
ToModuleTestOutputWithContext(ctx context.Context) ModuleTestOutput
|
|
}
|
|
|
|
func (*ModuleTest) ElementType() reflect.Type {
|
|
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
|
|
}
|
|
|
|
func (i *ModuleTest) ToModuleTestOutput() ModuleTestOutput {
|
|
return i.ToModuleTestOutputWithContext(context.Background())
|
|
}
|
|
|
|
func (i *ModuleTest) ToModuleTestOutputWithContext(ctx context.Context) ModuleTestOutput {
|
|
return pulumi.ToOutputWithContext(ctx, i).(ModuleTestOutput)
|
|
}
|
|
|
|
type ModuleTestOutput struct{ *pulumi.OutputState }
|
|
|
|
func (ModuleTestOutput) ElementType() reflect.Type {
|
|
return reflect.TypeOf((**ModuleTest)(nil)).Elem()
|
|
}
|
|
|
|
func (o ModuleTestOutput) ToModuleTestOutput() ModuleTestOutput {
|
|
return o
|
|
}
|
|
|
|
func (o ModuleTestOutput) ToModuleTestOutputWithContext(ctx context.Context) ModuleTestOutput {
|
|
return o
|
|
}
|
|
|
|
func init() {
|
|
pulumi.RegisterInputType(reflect.TypeOf((*ModuleTestInput)(nil)).Elem(), &ModuleTest{})
|
|
pulumi.RegisterOutputType(ModuleTestOutput{})
|
|
}
|