[codegen/go] - Resolve type name collisions (#7985)
This commit is contained in:
parent
d43b8984fd
commit
b8b6f3dd70
|
@ -10,3 +10,6 @@
|
|||
|
||||
- [codegen/nodejs] Correctly determine imports for functions.
|
||||
[#8038](https://github.com/pulumi/pulumi/pull/8038)
|
||||
|
||||
- [codegen/go] - Fix resolution of enum naming collisions
|
||||
[#7985](https://github.com/pulumi/pulumi/pull/7985)
|
||||
|
|
|
@ -142,16 +142,14 @@ func (pkg *pkgContext) tokenToType(tok string) string {
|
|||
|
||||
mod, name := pkg.tokenToPackage(tok), components[2]
|
||||
|
||||
modPkg, ok := pkg.packages[mod]
|
||||
name = Title(name)
|
||||
|
||||
if ok {
|
||||
if modPkg, ok := pkg.packages[mod]; ok {
|
||||
newName, renamed := modPkg.renamed[name]
|
||||
if renamed {
|
||||
name = newName
|
||||
} else if modPkg.duplicateTokens[strings.ToLower(tok)] {
|
||||
// maintain support for duplicate tokens for types and resources in Kubernetes
|
||||
name = name + "Type"
|
||||
name += "Type"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,6 +163,42 @@ func (pkg *pkgContext) tokenToType(tok string) string {
|
|||
return strings.Replace(mod, "-provider", "", -1)
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) tokenToEnum(tok string) string {
|
||||
// token := pkg : module : member
|
||||
// module := path/to/module
|
||||
|
||||
components := strings.Split(tok, ":")
|
||||
contract.Assert(len(components) == 3)
|
||||
if pkg == nil {
|
||||
panic(fmt.Errorf("pkg is nil. token %s", tok))
|
||||
}
|
||||
if pkg.pkg == nil {
|
||||
panic(fmt.Errorf("pkg.pkg is nil. token %s", tok))
|
||||
}
|
||||
|
||||
mod, name := pkg.tokenToPackage(tok), components[2]
|
||||
|
||||
name = Title(name)
|
||||
if modPkg, ok := pkg.packages[mod]; ok {
|
||||
newName, renamed := modPkg.renamed[name]
|
||||
if renamed {
|
||||
name = newName
|
||||
} else if modPkg.duplicateTokens[tok] {
|
||||
// If the package containing the enum's token already has a resource or type with the
|
||||
// same name, add an `Enum` suffix.
|
||||
name += "Enum"
|
||||
}
|
||||
}
|
||||
|
||||
if mod == pkg.mod {
|
||||
return name
|
||||
}
|
||||
if mod == "" {
|
||||
mod = components[0]
|
||||
}
|
||||
return strings.Replace(mod, "/", "", -1) + "." + name
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) tokenToResource(tok string) string {
|
||||
// token := pkg : module : member
|
||||
// module := path/to/module
|
||||
|
@ -1951,47 +1985,6 @@ func (pkg *pkgContext) nestedTypeToType(typ schema.Type) string {
|
|||
return strings.TrimSuffix(pkg.tokenToType(typ.String()), "Args")
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) tokenToEnum(tok string) string {
|
||||
// token := pkg : module : member
|
||||
// module := path/to/module
|
||||
|
||||
components := strings.Split(tok, ":")
|
||||
contract.Assert(len(components) == 3)
|
||||
if pkg == nil {
|
||||
panic(fmt.Errorf("pkg is nil. token %s", tok))
|
||||
}
|
||||
if pkg.pkg == nil {
|
||||
panic(fmt.Errorf("pkg.pkg is nil. token %s", tok))
|
||||
}
|
||||
|
||||
mod, name := pkg.tokenToPackage(tok), components[2]
|
||||
|
||||
modPkg, ok := pkg.packages[mod]
|
||||
name = Title(name)
|
||||
|
||||
if ok {
|
||||
newName, renamed := modPkg.renamed[name]
|
||||
if renamed {
|
||||
name = newName
|
||||
} else if modPkg.names.Has(name) {
|
||||
// If the package containing the enum's token already has a resource with the
|
||||
// same name, add a `Enum` suffix.
|
||||
newName := name + "Enum"
|
||||
modPkg.renamed[name] = newName
|
||||
modPkg.names.Add(newName)
|
||||
name = newName
|
||||
}
|
||||
}
|
||||
|
||||
if mod == pkg.mod {
|
||||
return name
|
||||
}
|
||||
if mod == "" {
|
||||
mod = components[0]
|
||||
}
|
||||
return strings.Replace(mod, "/", "", -1) + "." + name
|
||||
}
|
||||
|
||||
func (pkg *pkgContext) genTypeRegistrations(w io.Writer, objTypes []*schema.ObjectType, types ...string) {
|
||||
fmt.Fprintf(w, "func init() {\n")
|
||||
for _, obj := range objTypes {
|
||||
|
@ -2594,13 +2587,16 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
// compute set of names generated by a type
|
||||
// handling any potential collisions via remapping along the way
|
||||
scanType := func(t schema.Type) {
|
||||
getNames := func(name, suffix string) []string {
|
||||
return []string{name + suffix, name + suffix + "Input", name + suffix + "Output"}
|
||||
}
|
||||
|
||||
switch t := t.(type) {
|
||||
case *schema.ObjectType:
|
||||
pkg := getPkgFromToken(t.Token)
|
||||
// maintain support for duplicate tokens for types and resources in Kubernetes
|
||||
if resSeen[strings.ToLower(t.Token)] {
|
||||
pkg.duplicateTokens[strings.ToLower(t.Token)] = true
|
||||
return
|
||||
}
|
||||
if typeSeen[strings.ToLower(t.Token)] {
|
||||
return
|
||||
|
@ -2608,13 +2604,6 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
typeSeen[strings.ToLower(t.Token)] = true
|
||||
|
||||
name := pkg.tokenToType(t.Token)
|
||||
getNames := func(suffix string) []string {
|
||||
names := []string{}
|
||||
names = append(names, name+suffix)
|
||||
names = append(names, name+suffix+"Input")
|
||||
names = append(names, name+suffix+"Output")
|
||||
return names
|
||||
}
|
||||
suffixes := []string{"", "Type", "Typ"}
|
||||
suffix := ""
|
||||
suffixIndex := 0
|
||||
|
@ -2622,7 +2611,7 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
|
||||
for !canGenerate && suffixIndex <= len(suffixes) {
|
||||
suffix = suffixes[suffixIndex]
|
||||
candidates := getNames(suffix)
|
||||
candidates := getNames(name, suffix)
|
||||
conflict := false
|
||||
for _, c := range candidates {
|
||||
if pkg.names.Has(c) {
|
||||
|
@ -2641,8 +2630,53 @@ func generatePackageContextMap(tool string, pkg *schema.Package, goInfo GoPackag
|
|||
panic(fmt.Sprintf("unable to generate Go SDK, schema has unresolvable overlapping type: %s", name))
|
||||
}
|
||||
|
||||
names := getNames(suffix)
|
||||
originalNames := getNames("")
|
||||
names := getNames(name, suffix)
|
||||
originalNames := getNames(name, "")
|
||||
for i, n := range names {
|
||||
pkg.names.Add(n)
|
||||
if suffix != "" {
|
||||
pkg.renamed[originalNames[i]] = names[i]
|
||||
}
|
||||
}
|
||||
case *schema.EnumType:
|
||||
pkg := getPkgFromToken(t.Token)
|
||||
if resSeen[t.Token] {
|
||||
pkg.duplicateTokens[strings.ToLower(t.Token)] = true
|
||||
}
|
||||
if typeSeen[t.Token] {
|
||||
return
|
||||
}
|
||||
typeSeen[t.Token] = true
|
||||
|
||||
name := pkg.tokenToEnum(t.Token)
|
||||
suffixes := []string{"", "Enum"}
|
||||
suffix := ""
|
||||
suffixIndex := 0
|
||||
canGenerate := false
|
||||
|
||||
for !canGenerate && suffixIndex <= len(suffixes) {
|
||||
suffix = suffixes[suffixIndex]
|
||||
candidates := getNames(name, suffix)
|
||||
conflict := false
|
||||
for _, c := range candidates {
|
||||
if pkg.names.Has(c) {
|
||||
conflict = true
|
||||
}
|
||||
}
|
||||
if !conflict {
|
||||
canGenerate = true
|
||||
break
|
||||
}
|
||||
|
||||
suffixIndex++
|
||||
}
|
||||
|
||||
if !canGenerate {
|
||||
panic(fmt.Sprintf("unable to generate Go SDK, schema has unresolvable overlapping type: %s", name))
|
||||
}
|
||||
|
||||
names := getNames(name, suffix)
|
||||
originalNames := getNames(name, "")
|
||||
for i, n := range names {
|
||||
pkg.names.Add(n)
|
||||
if suffix != "" {
|
||||
|
|
|
@ -42,13 +42,13 @@ const (
|
|||
|
||||
var sdkTests = []sdkTest{
|
||||
{
|
||||
Directory: "dash-named-schema",
|
||||
Description: "Simple schema with a two part name (foo-bar)",
|
||||
Directory: "naming-collisions",
|
||||
Description: "Schema with types that could potentially produce collisions (go).",
|
||||
Skip: codegen.NewStringSet("python/test"),
|
||||
},
|
||||
{
|
||||
Directory: "input-collision",
|
||||
Description: "Schema with types that could potentially produce collisions (go).",
|
||||
Directory: "dash-named-schema",
|
||||
Description: "Simple schema with a two part name (foo-bar)",
|
||||
Skip: codegen.NewStringSet("python/test"),
|
||||
},
|
||||
{
|
||||
|
|
93
pkg/codegen/internal/test/testdata/naming-collisions/dotnet/Enums.cs
vendored
Normal file
93
pkg/codegen/internal/test/testdata/naming-collisions/dotnet/Enums.cs
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Pulumi;
|
||||
|
||||
namespace Pulumi.Example
|
||||
{
|
||||
[EnumType]
|
||||
public readonly struct ExampleEnum : IEquatable<ExampleEnum>
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
private ExampleEnum(string value)
|
||||
{
|
||||
_value = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
public static ExampleEnum One { get; } = new ExampleEnum("one");
|
||||
public static ExampleEnum Two { get; } = new ExampleEnum("two");
|
||||
|
||||
public static bool operator ==(ExampleEnum left, ExampleEnum right) => left.Equals(right);
|
||||
public static bool operator !=(ExampleEnum left, ExampleEnum right) => !left.Equals(right);
|
||||
|
||||
public static explicit operator string(ExampleEnum value) => value._value;
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override bool Equals(object? obj) => obj is ExampleEnum other && Equals(other);
|
||||
public bool Equals(ExampleEnum other) => string.Equals(_value, other._value, StringComparison.Ordinal);
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
|
||||
|
||||
public override string ToString() => _value;
|
||||
}
|
||||
|
||||
[EnumType]
|
||||
public readonly struct ExampleEnumInput : IEquatable<ExampleEnumInput>
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
private ExampleEnumInput(string value)
|
||||
{
|
||||
_value = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
public static ExampleEnumInput One { get; } = new ExampleEnumInput("one");
|
||||
public static ExampleEnumInput Two { get; } = new ExampleEnumInput("two");
|
||||
|
||||
public static bool operator ==(ExampleEnumInput left, ExampleEnumInput right) => left.Equals(right);
|
||||
public static bool operator !=(ExampleEnumInput left, ExampleEnumInput right) => !left.Equals(right);
|
||||
|
||||
public static explicit operator string(ExampleEnumInput value) => value._value;
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override bool Equals(object? obj) => obj is ExampleEnumInput other && Equals(other);
|
||||
public bool Equals(ExampleEnumInput other) => string.Equals(_value, other._value, StringComparison.Ordinal);
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
|
||||
|
||||
public override string ToString() => _value;
|
||||
}
|
||||
|
||||
[EnumType]
|
||||
public readonly struct ResourceType : IEquatable<ResourceType>
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
private ResourceType(string value)
|
||||
{
|
||||
_value = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
public static ResourceType Haha { get; } = new ResourceType("haha");
|
||||
public static ResourceType Business { get; } = new ResourceType("business");
|
||||
|
||||
public static bool operator ==(ResourceType left, ResourceType right) => left.Equals(right);
|
||||
public static bool operator !=(ResourceType left, ResourceType right) => !left.Equals(right);
|
||||
|
||||
public static explicit operator string(ResourceType value) => value._value;
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override bool Equals(object? obj) => obj is ResourceType other && Equals(other);
|
||||
public bool Equals(ResourceType other) => string.Equals(_value, other._value, StringComparison.Ordinal);
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
|
||||
|
||||
public override string ToString() => _value;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"emittedFiles": [
|
||||
"Enums.cs",
|
||||
"Provider.cs",
|
||||
"Pulumi.Example.csproj",
|
||||
"README.md",
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
|
@ -3,6 +3,7 @@
|
|||
"example/doc.go",
|
||||
"example/init.go",
|
||||
"example/provider.go",
|
||||
"example/pulumiEnums.go",
|
||||
"example/pulumiTypes.go",
|
||||
"example/pulumiUtilities.go",
|
||||
"example/resource.go",
|
512
pkg/codegen/internal/test/testdata/naming-collisions/go/example/pulumiEnums.go
vendored
Normal file
512
pkg/codegen/internal/test/testdata/naming-collisions/go/example/pulumiEnums.go
vendored
Normal file
|
@ -0,0 +1,512 @@
|
|||
// *** 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"
|
||||
)
|
||||
|
||||
type ExampleEnum string
|
||||
|
||||
const (
|
||||
ExampleEnumOne = ExampleEnum("one")
|
||||
ExampleEnumTwo = ExampleEnum("two")
|
||||
)
|
||||
|
||||
func (ExampleEnum) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ExampleEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (e ExampleEnum) ToExampleEnumOutput() ExampleEnumOutput {
|
||||
return pulumi.ToOutput(e).(ExampleEnumOutput)
|
||||
}
|
||||
|
||||
func (e ExampleEnum) ToExampleEnumOutputWithContext(ctx context.Context) ExampleEnumOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, e).(ExampleEnumOutput)
|
||||
}
|
||||
|
||||
func (e ExampleEnum) ToExampleEnumPtrOutput() ExampleEnumPtrOutput {
|
||||
return e.ToExampleEnumPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e ExampleEnum) ToExampleEnumPtrOutputWithContext(ctx context.Context) ExampleEnumPtrOutput {
|
||||
return ExampleEnum(e).ToExampleEnumOutputWithContext(ctx).ToExampleEnumPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
func (e ExampleEnum) ToStringOutput() pulumi.StringOutput {
|
||||
return pulumi.ToOutput(pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e ExampleEnum) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e ExampleEnum) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e ExampleEnum) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringOutputWithContext(ctx).ToStringPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
type ExampleEnumOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ExampleEnumOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ExampleEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ExampleEnumOutput) ToExampleEnumOutput() ExampleEnumOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ExampleEnumOutput) ToExampleEnumOutputWithContext(ctx context.Context) ExampleEnumOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ExampleEnumOutput) ToExampleEnumPtrOutput() ExampleEnumPtrOutput {
|
||||
return o.ToExampleEnumPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ExampleEnumOutput) ToExampleEnumPtrOutputWithContext(ctx context.Context) ExampleEnumPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v ExampleEnum) *ExampleEnum {
|
||||
return &v
|
||||
}).(ExampleEnumPtrOutput)
|
||||
}
|
||||
|
||||
func (o ExampleEnumOutput) ToStringOutput() pulumi.StringOutput {
|
||||
return o.ToStringOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ExampleEnumOutput) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e ExampleEnum) string {
|
||||
return string(e)
|
||||
}).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (o ExampleEnumOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ExampleEnumOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e ExampleEnum) *string {
|
||||
v := string(e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
type ExampleEnumPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ExampleEnumPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ExampleEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ExampleEnumPtrOutput) ToExampleEnumPtrOutput() ExampleEnumPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ExampleEnumPtrOutput) ToExampleEnumPtrOutputWithContext(ctx context.Context) ExampleEnumPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ExampleEnumPtrOutput) Elem() ExampleEnumOutput {
|
||||
return o.ApplyT(func(v *ExampleEnum) ExampleEnum {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret ExampleEnum
|
||||
return ret
|
||||
}).(ExampleEnumOutput)
|
||||
}
|
||||
|
||||
func (o ExampleEnumPtrOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ExampleEnumPtrOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e *ExampleEnum) *string {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
v := string(*e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// ExampleEnumInput is an input type that accepts ExampleEnumArgs and ExampleEnumOutput values.
|
||||
// You can construct a concrete instance of `ExampleEnumInput` via:
|
||||
//
|
||||
// ExampleEnumArgs{...}
|
||||
type ExampleEnumInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToExampleEnumOutput() ExampleEnumOutput
|
||||
ToExampleEnumOutputWithContext(context.Context) ExampleEnumOutput
|
||||
}
|
||||
|
||||
var exampleEnumPtrType = reflect.TypeOf((**ExampleEnum)(nil)).Elem()
|
||||
|
||||
type ExampleEnumPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToExampleEnumPtrOutput() ExampleEnumPtrOutput
|
||||
ToExampleEnumPtrOutputWithContext(context.Context) ExampleEnumPtrOutput
|
||||
}
|
||||
|
||||
type exampleEnumPtr string
|
||||
|
||||
func ExampleEnumPtr(v string) ExampleEnumPtrInput {
|
||||
return (*exampleEnumPtr)(&v)
|
||||
}
|
||||
|
||||
func (*exampleEnumPtr) ElementType() reflect.Type {
|
||||
return exampleEnumPtrType
|
||||
}
|
||||
|
||||
func (in *exampleEnumPtr) ToExampleEnumPtrOutput() ExampleEnumPtrOutput {
|
||||
return pulumi.ToOutput(in).(ExampleEnumPtrOutput)
|
||||
}
|
||||
|
||||
func (in *exampleEnumPtr) ToExampleEnumPtrOutputWithContext(ctx context.Context) ExampleEnumPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, in).(ExampleEnumPtrOutput)
|
||||
}
|
||||
|
||||
type ExampleEnumInputEnum string
|
||||
|
||||
const (
|
||||
ExampleEnumInputEnumOne = ExampleEnumInputEnum("one")
|
||||
ExampleEnumInputEnumTwo = ExampleEnumInputEnum("two")
|
||||
)
|
||||
|
||||
func (ExampleEnumInputEnum) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ExampleEnumInputEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (e ExampleEnumInputEnum) ToExampleEnumInputEnumOutput() ExampleEnumInputEnumOutput {
|
||||
return pulumi.ToOutput(e).(ExampleEnumInputEnumOutput)
|
||||
}
|
||||
|
||||
func (e ExampleEnumInputEnum) ToExampleEnumInputEnumOutputWithContext(ctx context.Context) ExampleEnumInputEnumOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, e).(ExampleEnumInputEnumOutput)
|
||||
}
|
||||
|
||||
func (e ExampleEnumInputEnum) ToExampleEnumInputEnumPtrOutput() ExampleEnumInputEnumPtrOutput {
|
||||
return e.ToExampleEnumInputEnumPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e ExampleEnumInputEnum) ToExampleEnumInputEnumPtrOutputWithContext(ctx context.Context) ExampleEnumInputEnumPtrOutput {
|
||||
return ExampleEnumInputEnum(e).ToExampleEnumInputEnumOutputWithContext(ctx).ToExampleEnumInputEnumPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
func (e ExampleEnumInputEnum) ToStringOutput() pulumi.StringOutput {
|
||||
return pulumi.ToOutput(pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e ExampleEnumInputEnum) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e ExampleEnumInputEnum) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e ExampleEnumInputEnum) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringOutputWithContext(ctx).ToStringPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
type ExampleEnumInputEnumOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ExampleEnumInputEnumOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ExampleEnumInputEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumOutput) ToExampleEnumInputEnumOutput() ExampleEnumInputEnumOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumOutput) ToExampleEnumInputEnumOutputWithContext(ctx context.Context) ExampleEnumInputEnumOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumOutput) ToExampleEnumInputEnumPtrOutput() ExampleEnumInputEnumPtrOutput {
|
||||
return o.ToExampleEnumInputEnumPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumOutput) ToExampleEnumInputEnumPtrOutputWithContext(ctx context.Context) ExampleEnumInputEnumPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v ExampleEnumInputEnum) *ExampleEnumInputEnum {
|
||||
return &v
|
||||
}).(ExampleEnumInputEnumPtrOutput)
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumOutput) ToStringOutput() pulumi.StringOutput {
|
||||
return o.ToStringOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumOutput) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e ExampleEnumInputEnum) string {
|
||||
return string(e)
|
||||
}).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e ExampleEnumInputEnum) *string {
|
||||
v := string(e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
type ExampleEnumInputEnumPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ExampleEnumInputEnumPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ExampleEnumInputEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumPtrOutput) ToExampleEnumInputEnumPtrOutput() ExampleEnumInputEnumPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumPtrOutput) ToExampleEnumInputEnumPtrOutputWithContext(ctx context.Context) ExampleEnumInputEnumPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumPtrOutput) Elem() ExampleEnumInputEnumOutput {
|
||||
return o.ApplyT(func(v *ExampleEnumInputEnum) ExampleEnumInputEnum {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret ExampleEnumInputEnum
|
||||
return ret
|
||||
}).(ExampleEnumInputEnumOutput)
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumPtrOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ExampleEnumInputEnumPtrOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e *ExampleEnumInputEnum) *string {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
v := string(*e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// ExampleEnumInputEnumInput is an input type that accepts ExampleEnumInputEnumArgs and ExampleEnumInputEnumOutput values.
|
||||
// You can construct a concrete instance of `ExampleEnumInputEnumInput` via:
|
||||
//
|
||||
// ExampleEnumInputEnumArgs{...}
|
||||
type ExampleEnumInputEnumInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToExampleEnumInputEnumOutput() ExampleEnumInputEnumOutput
|
||||
ToExampleEnumInputEnumOutputWithContext(context.Context) ExampleEnumInputEnumOutput
|
||||
}
|
||||
|
||||
var exampleEnumInputEnumPtrType = reflect.TypeOf((**ExampleEnumInputEnum)(nil)).Elem()
|
||||
|
||||
type ExampleEnumInputEnumPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToExampleEnumInputEnumPtrOutput() ExampleEnumInputEnumPtrOutput
|
||||
ToExampleEnumInputEnumPtrOutputWithContext(context.Context) ExampleEnumInputEnumPtrOutput
|
||||
}
|
||||
|
||||
type exampleEnumInputEnumPtr string
|
||||
|
||||
func ExampleEnumInputEnumPtr(v string) ExampleEnumInputEnumPtrInput {
|
||||
return (*exampleEnumInputEnumPtr)(&v)
|
||||
}
|
||||
|
||||
func (*exampleEnumInputEnumPtr) ElementType() reflect.Type {
|
||||
return exampleEnumInputEnumPtrType
|
||||
}
|
||||
|
||||
func (in *exampleEnumInputEnumPtr) ToExampleEnumInputEnumPtrOutput() ExampleEnumInputEnumPtrOutput {
|
||||
return pulumi.ToOutput(in).(ExampleEnumInputEnumPtrOutput)
|
||||
}
|
||||
|
||||
func (in *exampleEnumInputEnumPtr) ToExampleEnumInputEnumPtrOutputWithContext(ctx context.Context) ExampleEnumInputEnumPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, in).(ExampleEnumInputEnumPtrOutput)
|
||||
}
|
||||
|
||||
type ResourceTypeEnum string
|
||||
|
||||
const (
|
||||
ResourceTypeEnumHaha = ResourceTypeEnum("haha")
|
||||
ResourceTypeEnumBusiness = ResourceTypeEnum("business")
|
||||
)
|
||||
|
||||
func (ResourceTypeEnum) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ResourceTypeEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (e ResourceTypeEnum) ToResourceTypeEnumOutput() ResourceTypeEnumOutput {
|
||||
return pulumi.ToOutput(e).(ResourceTypeEnumOutput)
|
||||
}
|
||||
|
||||
func (e ResourceTypeEnum) ToResourceTypeEnumOutputWithContext(ctx context.Context) ResourceTypeEnumOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, e).(ResourceTypeEnumOutput)
|
||||
}
|
||||
|
||||
func (e ResourceTypeEnum) ToResourceTypeEnumPtrOutput() ResourceTypeEnumPtrOutput {
|
||||
return e.ToResourceTypeEnumPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e ResourceTypeEnum) ToResourceTypeEnumPtrOutputWithContext(ctx context.Context) ResourceTypeEnumPtrOutput {
|
||||
return ResourceTypeEnum(e).ToResourceTypeEnumOutputWithContext(ctx).ToResourceTypeEnumPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
func (e ResourceTypeEnum) ToStringOutput() pulumi.StringOutput {
|
||||
return pulumi.ToOutput(pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e ResourceTypeEnum) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e ResourceTypeEnum) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e ResourceTypeEnum) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringOutputWithContext(ctx).ToStringPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
type ResourceTypeEnumOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ResourceTypeEnumOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ResourceTypeEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumOutput) ToResourceTypeEnumOutput() ResourceTypeEnumOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumOutput) ToResourceTypeEnumOutputWithContext(ctx context.Context) ResourceTypeEnumOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumOutput) ToResourceTypeEnumPtrOutput() ResourceTypeEnumPtrOutput {
|
||||
return o.ToResourceTypeEnumPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumOutput) ToResourceTypeEnumPtrOutputWithContext(ctx context.Context) ResourceTypeEnumPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v ResourceTypeEnum) *ResourceTypeEnum {
|
||||
return &v
|
||||
}).(ResourceTypeEnumPtrOutput)
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumOutput) ToStringOutput() pulumi.StringOutput {
|
||||
return o.ToStringOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumOutput) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e ResourceTypeEnum) string {
|
||||
return string(e)
|
||||
}).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e ResourceTypeEnum) *string {
|
||||
v := string(e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
type ResourceTypeEnumPtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ResourceTypeEnumPtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**ResourceTypeEnum)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumPtrOutput) ToResourceTypeEnumPtrOutput() ResourceTypeEnumPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumPtrOutput) ToResourceTypeEnumPtrOutputWithContext(ctx context.Context) ResourceTypeEnumPtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumPtrOutput) Elem() ResourceTypeEnumOutput {
|
||||
return o.ApplyT(func(v *ResourceTypeEnum) ResourceTypeEnum {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret ResourceTypeEnum
|
||||
return ret
|
||||
}).(ResourceTypeEnumOutput)
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumPtrOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o ResourceTypeEnumPtrOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e *ResourceTypeEnum) *string {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
v := string(*e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// ResourceTypeEnumInput is an input type that accepts ResourceTypeEnumArgs and ResourceTypeEnumOutput values.
|
||||
// You can construct a concrete instance of `ResourceTypeEnumInput` via:
|
||||
//
|
||||
// ResourceTypeEnumArgs{...}
|
||||
type ResourceTypeEnumInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToResourceTypeEnumOutput() ResourceTypeEnumOutput
|
||||
ToResourceTypeEnumOutputWithContext(context.Context) ResourceTypeEnumOutput
|
||||
}
|
||||
|
||||
var resourceTypeEnumPtrType = reflect.TypeOf((**ResourceTypeEnum)(nil)).Elem()
|
||||
|
||||
type ResourceTypeEnumPtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToResourceTypeEnumPtrOutput() ResourceTypeEnumPtrOutput
|
||||
ToResourceTypeEnumPtrOutputWithContext(context.Context) ResourceTypeEnumPtrOutput
|
||||
}
|
||||
|
||||
type resourceTypeEnumPtr string
|
||||
|
||||
func ResourceTypeEnumPtr(v string) ResourceTypeEnumPtrInput {
|
||||
return (*resourceTypeEnumPtr)(&v)
|
||||
}
|
||||
|
||||
func (*resourceTypeEnumPtr) ElementType() reflect.Type {
|
||||
return resourceTypeEnumPtrType
|
||||
}
|
||||
|
||||
func (in *resourceTypeEnumPtr) ToResourceTypeEnumPtrOutput() ResourceTypeEnumPtrOutput {
|
||||
return pulumi.ToOutput(in).(ResourceTypeEnumPtrOutput)
|
||||
}
|
||||
|
||||
func (in *resourceTypeEnumPtr) ToResourceTypeEnumPtrOutputWithContext(ctx context.Context) ResourceTypeEnumPtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, in).(ResourceTypeEnumPtrOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterOutputType(ExampleEnumOutput{})
|
||||
pulumi.RegisterOutputType(ExampleEnumPtrOutput{})
|
||||
pulumi.RegisterOutputType(ExampleEnumInputEnumOutput{})
|
||||
pulumi.RegisterOutputType(ExampleEnumInputEnumPtrOutput{})
|
||||
pulumi.RegisterOutputType(ResourceTypeEnumOutput{})
|
||||
pulumi.RegisterOutputType(ResourceTypeEnumPtrOutput{})
|
||||
}
|
|
@ -108,7 +108,57 @@ func (o ObjectInputTypeOutput) Bar() pulumi.StringPtrOutput {
|
|||
return o.ApplyT(func(v ObjectInputType) *string { return v.Bar }).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
type ResourceType struct {
|
||||
Name *string `pulumi:"name"`
|
||||
}
|
||||
|
||||
// ResourceTypeInput is an input type that accepts ResourceTypeArgs and ResourceTypeOutput values.
|
||||
// You can construct a concrete instance of `ResourceTypeInput` via:
|
||||
//
|
||||
// ResourceTypeArgs{...}
|
||||
type ResourceTypeInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToResourceTypeOutput() ResourceTypeOutput
|
||||
ToResourceTypeOutputWithContext(context.Context) ResourceTypeOutput
|
||||
}
|
||||
|
||||
type ResourceTypeArgs struct {
|
||||
Name pulumi.StringPtrInput `pulumi:"name"`
|
||||
}
|
||||
|
||||
func (ResourceTypeArgs) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ResourceType)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (i ResourceTypeArgs) ToResourceTypeOutput() ResourceTypeOutput {
|
||||
return i.ToResourceTypeOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (i ResourceTypeArgs) ToResourceTypeOutputWithContext(ctx context.Context) ResourceTypeOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, i).(ResourceTypeOutput)
|
||||
}
|
||||
|
||||
type ResourceTypeOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (ResourceTypeOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*ResourceType)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o ResourceTypeOutput) ToResourceTypeOutput() ResourceTypeOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ResourceTypeOutput) ToResourceTypeOutputWithContext(ctx context.Context) ResourceTypeOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o ResourceTypeOutput) Name() pulumi.StringPtrOutput {
|
||||
return o.ApplyT(func(v ResourceType) *string { return v.Name }).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterOutputType(ObjectOutput{})
|
||||
pulumi.RegisterOutputType(ObjectInputTypeOutput{})
|
||||
pulumi.RegisterOutputType(ResourceTypeOutput{})
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
"resource.ts",
|
||||
"resourceInput.ts",
|
||||
"tsconfig.json",
|
||||
"types/enums/index.ts",
|
||||
"types/index.ts",
|
||||
"types/input.ts",
|
||||
"types/output.ts",
|
|
@ -9,6 +9,9 @@ export * from "./provider";
|
|||
export * from "./resource";
|
||||
export * from "./resourceInput";
|
||||
|
||||
// Export enums:
|
||||
export * from "./types/enums";
|
||||
|
||||
// Export sub-modules:
|
||||
import * as types from "./types";
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
"provider.ts",
|
||||
"resource.ts",
|
||||
"resourceInput.ts",
|
||||
"types/enums/index.ts",
|
||||
"types/index.ts",
|
||||
"types/input.ts",
|
||||
"types/output.ts",
|
24
pkg/codegen/internal/test/testdata/naming-collisions/nodejs/types/enums/index.ts
vendored
Normal file
24
pkg/codegen/internal/test/testdata/naming-collisions/nodejs/types/enums/index.ts
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// *** WARNING: this file was generated by test. ***
|
||||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
|
||||
export const ExampleEnum = {
|
||||
One: "one",
|
||||
Two: "two",
|
||||
} as const;
|
||||
|
||||
export type ExampleEnum = (typeof ExampleEnum)[keyof typeof ExampleEnum];
|
||||
|
||||
export const ExampleEnumInput = {
|
||||
One: "one",
|
||||
Two: "two",
|
||||
} as const;
|
||||
|
||||
export type ExampleEnumInput = (typeof ExampleEnumInput)[keyof typeof ExampleEnumInput];
|
||||
|
||||
export const ResourceType = {
|
||||
Haha: "haha",
|
||||
Business: "business",
|
||||
} as const;
|
||||
|
||||
export type ResourceType = (typeof ResourceType)[keyof typeof ResourceType];
|
|
@ -2,10 +2,12 @@
|
|||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
// Export sub-modules:
|
||||
import * as enums from "./enums";
|
||||
import * as input from "./input";
|
||||
import * as output from "./output";
|
||||
|
||||
export {
|
||||
enums,
|
||||
input,
|
||||
output,
|
||||
};
|
|
@ -2,5 +2,5 @@
|
|||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
import * as pulumi from "@pulumi/pulumi";
|
||||
import { input as inputs, output as outputs } from "../types";
|
||||
import { input as inputs, output as outputs, enums } from "../types";
|
||||
|
|
@ -2,5 +2,5 @@
|
|||
// *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
import * as pulumi from "@pulumi/pulumi";
|
||||
import { input as inputs, output as outputs } from "../types";
|
||||
import { input as inputs, output as outputs, enums } from "../types";
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
"emittedFiles": [
|
||||
"pulumi_example/README.md",
|
||||
"pulumi_example/__init__.py",
|
||||
"pulumi_example/_enums.py",
|
||||
"pulumi_example/_utilities.py",
|
||||
"pulumi_example/provider.py",
|
||||
"pulumi_example/py.typed",
|
|
@ -5,6 +5,7 @@
|
|||
from . import _utilities
|
||||
import typing
|
||||
# Export this package's modules as members:
|
||||
from ._enums import *
|
||||
from .provider import *
|
||||
from .resource import *
|
||||
from .resource_input import *
|
26
pkg/codegen/internal/test/testdata/naming-collisions/python/pulumi_example/_enums.py
vendored
Normal file
26
pkg/codegen/internal/test/testdata/naming-collisions/python/pulumi_example/_enums.py
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
# coding=utf-8
|
||||
# *** WARNING: this file was generated by test. ***
|
||||
# *** Do not edit by hand unless you're certain you know what you are doing! ***
|
||||
|
||||
from enum import Enum
|
||||
|
||||
__all__ = [
|
||||
'ExampleEnum',
|
||||
'ExampleEnumInput',
|
||||
'ResourceType',
|
||||
]
|
||||
|
||||
|
||||
class ExampleEnum(str, Enum):
|
||||
ONE = "one"
|
||||
TWO = "two"
|
||||
|
||||
|
||||
class ExampleEnumInput(str, Enum):
|
||||
ONE = "one"
|
||||
TWO = "two"
|
||||
|
||||
|
||||
class ResourceType(str, Enum):
|
||||
HAHA = "haha"
|
||||
BUSINESS = "business"
|
|
@ -17,6 +17,35 @@
|
|||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"example::ExampleEnum": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
{"value": "one"},
|
||||
{"value": "two"}
|
||||
]
|
||||
},
|
||||
"example::ExampleEnumInput": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
{"value": "one"},
|
||||
{"value": "two"}
|
||||
]
|
||||
},
|
||||
"example::Resource": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example::ResourceType": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
{"value": "haha"},
|
||||
{"value": "business"}
|
||||
]
|
||||
}
|
||||
},
|
||||
"resources": {
|
|
@ -1556,7 +1556,7 @@ func validateSpec(spec PackageSpec) (hcl.Diagnostics, error) {
|
|||
// works as a singleton -- if it is nil, a new loader is instantiated, else the provided loader is used. This avoids
|
||||
// breaking downstream consumers of ImportSpec while allowing us to extend schema support to external packages.
|
||||
//
|
||||
// A few notes on diagnostsics and errors in spec binding:
|
||||
// A few notes on diagnostics and errors in spec binding:
|
||||
//
|
||||
// - Unless an error is *fatal*--i.e. binding is fundamentally unable to proceed (e.g. because a provider for a package
|
||||
// failed to load)--errors should be communicated as diagnostics. Fatal errors should be communicated as error values.
|
||||
|
@ -1565,7 +1565,7 @@ func validateSpec(spec PackageSpec) (hcl.Diagnostics, error) {
|
|||
// allows binding to continue and produce as much information as possible for the end user.
|
||||
// - Diagnostics may be rendered to users by downstream tools, and should be written with schema authors in mind.
|
||||
// - Diagnostics _must_ contain enough contextual information for a user to be able to understand the source of the
|
||||
// diagnostic. Until we have line/column information, we use JSON pointers to the offending entites. These pointers
|
||||
// diagnostic. Until we have line/column information, we use JSON pointers to the offending entities. These pointers
|
||||
// are passed around using `path` parameters. The `errorf` function is provided as a utility to easily create a
|
||||
// diagnostic error that is appropriately tagged with a JSON pointer.
|
||||
//
|
||||
|
@ -1659,7 +1659,7 @@ func bindSpec(spec PackageSpec, languages map[string]Language, loader Loader) (*
|
|||
typeList = append(typeList, t)
|
||||
}
|
||||
for _, t := range types.objects {
|
||||
// t is a plain shape: add it and its coresponding input shape to the type list.
|
||||
// t is a plain shape: add it and its corresponding input shape to the type list.
|
||||
typeList = append(typeList, t)
|
||||
typeList = append(typeList, t.InputShape)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue