pulumi/pkg/codegen/internal/test/testdata/plain-object-defaults/go/example/mod2/pulumiTypes.go

186 lines
4.3 KiB
Go
Raw Normal View History

// *** WARNING: this file was generated by test. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package mod2
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
[codegen/go] Call site defaults for Pulumi Object types (#8411) * 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
2021-11-24 00:10:15 +01:00
"plain-object-defaults/example/mod1"
)
// A test for namespaces (mod 2)
type Typ struct {
Mod1 *mod1.Typ `pulumi:"mod1"`
Val *string `pulumi:"val"`
}
[codegen/go] Call site defaults for Pulumi Object types (#8411) * 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
2021-11-24 00:10:15 +01:00
// Defaults sets the appropriate defaults for Typ
func (val *Typ) Defaults() *Typ {
if val == nil {
return nil
}
tmp := *val
tmp.Mod1 = tmp.Mod1.Defaults()
if isZero(tmp.Val) {
val_ := "mod2"
tmp.Val = &val_
}
return &tmp
}
// TypInput is an input type that accepts TypArgs and TypOutput values.
// You can construct a concrete instance of `TypInput` via:
//
// TypArgs{...}
type TypInput interface {
pulumi.Input
ToTypOutput() TypOutput
ToTypOutputWithContext(context.Context) TypOutput
}
// A test for namespaces (mod 2)
type TypArgs struct {
Mod1 mod1.TypPtrInput `pulumi:"mod1"`
Val pulumi.StringPtrInput `pulumi:"val"`
}
func (TypArgs) ElementType() reflect.Type {
return reflect.TypeOf((*Typ)(nil)).Elem()
}
func (i TypArgs) ToTypOutput() TypOutput {
return i.ToTypOutputWithContext(context.Background())
}
func (i TypArgs) ToTypOutputWithContext(ctx context.Context) TypOutput {
return pulumi.ToOutputWithContext(ctx, i).(TypOutput)
}
func (i TypArgs) ToTypPtrOutput() TypPtrOutput {
return i.ToTypPtrOutputWithContext(context.Background())
}
func (i TypArgs) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(TypOutput).ToTypPtrOutputWithContext(ctx)
}
// TypPtrInput is an input type that accepts TypArgs, TypPtr and TypPtrOutput values.
// You can construct a concrete instance of `TypPtrInput` via:
//
// TypArgs{...}
//
// or:
//
// nil
type TypPtrInput interface {
pulumi.Input
ToTypPtrOutput() TypPtrOutput
ToTypPtrOutputWithContext(context.Context) TypPtrOutput
}
type typPtrType TypArgs
func TypPtr(v *TypArgs) TypPtrInput {
return (*typPtrType)(v)
}
func (*typPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Typ)(nil)).Elem()
}
func (i *typPtrType) ToTypPtrOutput() TypPtrOutput {
return i.ToTypPtrOutputWithContext(context.Background())
}
func (i *typPtrType) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(TypPtrOutput)
}
// A test for namespaces (mod 2)
type TypOutput struct{ *pulumi.OutputState }
func (TypOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Typ)(nil)).Elem()
}
func (o TypOutput) ToTypOutput() TypOutput {
return o
}
func (o TypOutput) ToTypOutputWithContext(ctx context.Context) TypOutput {
return o
}
func (o TypOutput) ToTypPtrOutput() TypPtrOutput {
return o.ToTypPtrOutputWithContext(context.Background())
}
func (o TypOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v Typ) *Typ {
return &v
}).(TypPtrOutput)
}
func (o TypOutput) Mod1() mod1.TypPtrOutput {
return o.ApplyT(func(v Typ) *mod1.Typ { return v.Mod1 }).(mod1.TypPtrOutput)
}
func (o TypOutput) Val() pulumi.StringPtrOutput {
return o.ApplyT(func(v Typ) *string { return v.Val }).(pulumi.StringPtrOutput)
}
type TypPtrOutput struct{ *pulumi.OutputState }
func (TypPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Typ)(nil)).Elem()
}
func (o TypPtrOutput) ToTypPtrOutput() TypPtrOutput {
return o
}
func (o TypPtrOutput) ToTypPtrOutputWithContext(ctx context.Context) TypPtrOutput {
return o
}
func (o TypPtrOutput) Elem() TypOutput {
return o.ApplyT(func(v *Typ) Typ {
if v != nil {
return *v
}
var ret Typ
return ret
}).(TypOutput)
}
func (o TypPtrOutput) Mod1() mod1.TypPtrOutput {
return o.ApplyT(func(v *Typ) *mod1.Typ {
if v == nil {
return nil
}
return v.Mod1
}).(mod1.TypPtrOutput)
}
func (o TypPtrOutput) Val() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Typ) *string {
if v == nil {
return nil
}
return v.Val
}).(pulumi.StringPtrOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*TypInput)(nil)).Elem(), TypArgs{})
pulumi.RegisterInputType(reflect.TypeOf((*TypPtrInput)(nil)).Elem(), TypArgs{})
pulumi.RegisterOutputType(TypOutput{})
pulumi.RegisterOutputType(TypPtrOutput{})
}