Fix 7913 Python codegen issue with double-quote inside docstrings (#7914)
* Introduce a test that showcases the invalid generated code * Use shared printComment function * Check for triple quote escaping * Accept go * Accept dotnet * Accept nodejs * Move codegen exampe into an existing schema * Add CHANGELOG entry
This commit is contained in:
parent
1e235330d6
commit
c247f6e283
|
@ -30,3 +30,7 @@
|
|||
|
||||
- [automation/go] Fix loading of stack settings/configs from yaml files.
|
||||
[#pulumi-kubernetes-operator/183](https://github.com/pulumi/pulumi-kubernetes-operator/issues/183)
|
||||
|
||||
- [codegen/python] - Fix invalid Python docstring generation for enums
|
||||
that contain doc comments with double quotes
|
||||
[#7914](https://github.com/pulumi/pulumi/pull/7914)
|
||||
|
|
|
@ -7,6 +7,51 @@ using Pulumi;
|
|||
|
||||
namespace Pulumi.Plant
|
||||
{
|
||||
/// <summary>
|
||||
/// The log_name to populate in the Cloud Audit Record. This is added to regress pulumi/pulumi issue #7913
|
||||
/// </summary>
|
||||
[EnumType]
|
||||
public readonly struct CloudAuditOptionsLogName : IEquatable<CloudAuditOptionsLogName>
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
private CloudAuditOptionsLogName(string value)
|
||||
{
|
||||
_value = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default. Should not be used.
|
||||
/// </summary>
|
||||
public static CloudAuditOptionsLogName UnspecifiedLogName { get; } = new CloudAuditOptionsLogName("UNSPECIFIED_LOG_NAME");
|
||||
/// <summary>
|
||||
/// Corresponds to "cloudaudit.googleapis.com/activity"
|
||||
/// </summary>
|
||||
public static CloudAuditOptionsLogName AdminActivity { get; } = new CloudAuditOptionsLogName("ADMIN_ACTIVITY");
|
||||
/// <summary>
|
||||
/// Corresponds to "cloudaudit.googleapis.com/data_access"
|
||||
/// </summary>
|
||||
public static CloudAuditOptionsLogName DataAccess { get; } = new CloudAuditOptionsLogName("DATA_ACCESS");
|
||||
/// <summary>
|
||||
/// What if triple quotes """ are used in the description
|
||||
/// </summary>
|
||||
public static CloudAuditOptionsLogName Synthetic { get; } = new CloudAuditOptionsLogName("SYNTHETIC");
|
||||
|
||||
public static bool operator ==(CloudAuditOptionsLogName left, CloudAuditOptionsLogName right) => left.Equals(right);
|
||||
public static bool operator !=(CloudAuditOptionsLogName left, CloudAuditOptionsLogName right) => !left.Equals(right);
|
||||
|
||||
public static explicit operator string(CloudAuditOptionsLogName value) => value._value;
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override bool Equals(object? obj) => obj is CloudAuditOptionsLogName other && Equals(other);
|
||||
public bool Equals(CloudAuditOptionsLogName 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 ContainerBrightness : IEquatable<ContainerBrightness>
|
||||
{
|
||||
|
|
|
@ -10,6 +10,177 @@ import (
|
|||
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
||||
)
|
||||
|
||||
// The log_name to populate in the Cloud Audit Record. This is added to regress pulumi/pulumi issue #7913
|
||||
type CloudAuditOptionsLogName string
|
||||
|
||||
const (
|
||||
// Default. Should not be used.
|
||||
CloudAuditOptionsLogNameUnspecifiedLogName = CloudAuditOptionsLogName("UNSPECIFIED_LOG_NAME")
|
||||
// Corresponds to "cloudaudit.googleapis.com/activity"
|
||||
CloudAuditOptionsLogNameAdminActivity = CloudAuditOptionsLogName("ADMIN_ACTIVITY")
|
||||
// Corresponds to "cloudaudit.googleapis.com/data_access"
|
||||
CloudAuditOptionsLogNameDataAccess = CloudAuditOptionsLogName("DATA_ACCESS")
|
||||
// What if triple quotes """ are used in the description
|
||||
CloudAuditOptionsLogNameSynthetic = CloudAuditOptionsLogName("SYNTHETIC")
|
||||
)
|
||||
|
||||
func (CloudAuditOptionsLogName) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*CloudAuditOptionsLogName)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (e CloudAuditOptionsLogName) ToCloudAuditOptionsLogNameOutput() CloudAuditOptionsLogNameOutput {
|
||||
return pulumi.ToOutput(e).(CloudAuditOptionsLogNameOutput)
|
||||
}
|
||||
|
||||
func (e CloudAuditOptionsLogName) ToCloudAuditOptionsLogNameOutputWithContext(ctx context.Context) CloudAuditOptionsLogNameOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, e).(CloudAuditOptionsLogNameOutput)
|
||||
}
|
||||
|
||||
func (e CloudAuditOptionsLogName) ToCloudAuditOptionsLogNamePtrOutput() CloudAuditOptionsLogNamePtrOutput {
|
||||
return e.ToCloudAuditOptionsLogNamePtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e CloudAuditOptionsLogName) ToCloudAuditOptionsLogNamePtrOutputWithContext(ctx context.Context) CloudAuditOptionsLogNamePtrOutput {
|
||||
return CloudAuditOptionsLogName(e).ToCloudAuditOptionsLogNameOutputWithContext(ctx).ToCloudAuditOptionsLogNamePtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
func (e CloudAuditOptionsLogName) ToStringOutput() pulumi.StringOutput {
|
||||
return pulumi.ToOutput(pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e CloudAuditOptionsLogName) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, pulumi.String(e)).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (e CloudAuditOptionsLogName) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (e CloudAuditOptionsLogName) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return pulumi.String(e).ToStringOutputWithContext(ctx).ToStringPtrOutputWithContext(ctx)
|
||||
}
|
||||
|
||||
type CloudAuditOptionsLogNameOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CloudAuditOptionsLogNameOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((*CloudAuditOptionsLogName)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNameOutput) ToCloudAuditOptionsLogNameOutput() CloudAuditOptionsLogNameOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNameOutput) ToCloudAuditOptionsLogNameOutputWithContext(ctx context.Context) CloudAuditOptionsLogNameOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNameOutput) ToCloudAuditOptionsLogNamePtrOutput() CloudAuditOptionsLogNamePtrOutput {
|
||||
return o.ToCloudAuditOptionsLogNamePtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNameOutput) ToCloudAuditOptionsLogNamePtrOutputWithContext(ctx context.Context) CloudAuditOptionsLogNamePtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, v CloudAuditOptionsLogName) *CloudAuditOptionsLogName {
|
||||
return &v
|
||||
}).(CloudAuditOptionsLogNamePtrOutput)
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNameOutput) ToStringOutput() pulumi.StringOutput {
|
||||
return o.ToStringOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNameOutput) ToStringOutputWithContext(ctx context.Context) pulumi.StringOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e CloudAuditOptionsLogName) string {
|
||||
return string(e)
|
||||
}).(pulumi.StringOutput)
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNameOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNameOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e CloudAuditOptionsLogName) *string {
|
||||
v := string(e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
type CloudAuditOptionsLogNamePtrOutput struct{ *pulumi.OutputState }
|
||||
|
||||
func (CloudAuditOptionsLogNamePtrOutput) ElementType() reflect.Type {
|
||||
return reflect.TypeOf((**CloudAuditOptionsLogName)(nil)).Elem()
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNamePtrOutput) ToCloudAuditOptionsLogNamePtrOutput() CloudAuditOptionsLogNamePtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNamePtrOutput) ToCloudAuditOptionsLogNamePtrOutputWithContext(ctx context.Context) CloudAuditOptionsLogNamePtrOutput {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNamePtrOutput) Elem() CloudAuditOptionsLogNameOutput {
|
||||
return o.ApplyT(func(v *CloudAuditOptionsLogName) CloudAuditOptionsLogName {
|
||||
if v != nil {
|
||||
return *v
|
||||
}
|
||||
var ret CloudAuditOptionsLogName
|
||||
return ret
|
||||
}).(CloudAuditOptionsLogNameOutput)
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNamePtrOutput) ToStringPtrOutput() pulumi.StringPtrOutput {
|
||||
return o.ToStringPtrOutputWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (o CloudAuditOptionsLogNamePtrOutput) ToStringPtrOutputWithContext(ctx context.Context) pulumi.StringPtrOutput {
|
||||
return o.ApplyTWithContext(ctx, func(_ context.Context, e *CloudAuditOptionsLogName) *string {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
v := string(*e)
|
||||
return &v
|
||||
}).(pulumi.StringPtrOutput)
|
||||
}
|
||||
|
||||
// CloudAuditOptionsLogNameInput is an input type that accepts CloudAuditOptionsLogNameArgs and CloudAuditOptionsLogNameOutput values.
|
||||
// You can construct a concrete instance of `CloudAuditOptionsLogNameInput` via:
|
||||
//
|
||||
// CloudAuditOptionsLogNameArgs{...}
|
||||
type CloudAuditOptionsLogNameInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToCloudAuditOptionsLogNameOutput() CloudAuditOptionsLogNameOutput
|
||||
ToCloudAuditOptionsLogNameOutputWithContext(context.Context) CloudAuditOptionsLogNameOutput
|
||||
}
|
||||
|
||||
var cloudAuditOptionsLogNamePtrType = reflect.TypeOf((**CloudAuditOptionsLogName)(nil)).Elem()
|
||||
|
||||
type CloudAuditOptionsLogNamePtrInput interface {
|
||||
pulumi.Input
|
||||
|
||||
ToCloudAuditOptionsLogNamePtrOutput() CloudAuditOptionsLogNamePtrOutput
|
||||
ToCloudAuditOptionsLogNamePtrOutputWithContext(context.Context) CloudAuditOptionsLogNamePtrOutput
|
||||
}
|
||||
|
||||
type cloudAuditOptionsLogNamePtr string
|
||||
|
||||
func CloudAuditOptionsLogNamePtr(v string) CloudAuditOptionsLogNamePtrInput {
|
||||
return (*cloudAuditOptionsLogNamePtr)(&v)
|
||||
}
|
||||
|
||||
func (*cloudAuditOptionsLogNamePtr) ElementType() reflect.Type {
|
||||
return cloudAuditOptionsLogNamePtrType
|
||||
}
|
||||
|
||||
func (in *cloudAuditOptionsLogNamePtr) ToCloudAuditOptionsLogNamePtrOutput() CloudAuditOptionsLogNamePtrOutput {
|
||||
return pulumi.ToOutput(in).(CloudAuditOptionsLogNamePtrOutput)
|
||||
}
|
||||
|
||||
func (in *cloudAuditOptionsLogNamePtr) ToCloudAuditOptionsLogNamePtrOutputWithContext(ctx context.Context) CloudAuditOptionsLogNamePtrOutput {
|
||||
return pulumi.ToOutputWithContext(ctx, in).(CloudAuditOptionsLogNamePtrOutput)
|
||||
}
|
||||
|
||||
type ContainerBrightness float64
|
||||
|
||||
const (
|
||||
|
@ -508,6 +679,8 @@ func (in *containerSizePtr) ToContainerSizePtrOutputWithContext(ctx context.Cont
|
|||
}
|
||||
|
||||
func init() {
|
||||
pulumi.RegisterOutputType(CloudAuditOptionsLogNameOutput{})
|
||||
pulumi.RegisterOutputType(CloudAuditOptionsLogNamePtrOutput{})
|
||||
pulumi.RegisterOutputType(ContainerBrightnessOutput{})
|
||||
pulumi.RegisterOutputType(ContainerBrightnessPtrOutput{})
|
||||
pulumi.RegisterOutputType(ContainerColorOutput{})
|
||||
|
|
|
@ -8,6 +8,30 @@ export {
|
|||
tree,
|
||||
};
|
||||
|
||||
export const CloudAuditOptionsLogName = {
|
||||
/**
|
||||
* Default. Should not be used.
|
||||
*/
|
||||
UnspecifiedLogName: "UNSPECIFIED_LOG_NAME",
|
||||
/**
|
||||
* Corresponds to "cloudaudit.googleapis.com/activity"
|
||||
*/
|
||||
AdminActivity: "ADMIN_ACTIVITY",
|
||||
/**
|
||||
* Corresponds to "cloudaudit.googleapis.com/data_access"
|
||||
*/
|
||||
DataAccess: "DATA_ACCESS",
|
||||
/**
|
||||
* What if triple quotes """ are used in the description
|
||||
*/
|
||||
Synthetic: "SYNTHETIC",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* The log_name to populate in the Cloud Audit Record. This is added to regress pulumi/pulumi issue #7913
|
||||
*/
|
||||
export type CloudAuditOptionsLogName = (typeof CloudAuditOptionsLogName)[keyof typeof CloudAuditOptionsLogName];
|
||||
|
||||
export const ContainerBrightness = {
|
||||
ZeroPointOne: 0.1,
|
||||
One: 1,
|
||||
|
|
|
@ -5,12 +5,35 @@
|
|||
from enum import Enum
|
||||
|
||||
__all__ = [
|
||||
'CloudAuditOptionsLogName',
|
||||
'ContainerBrightness',
|
||||
'ContainerColor',
|
||||
'ContainerSize',
|
||||
]
|
||||
|
||||
|
||||
class CloudAuditOptionsLogName(str, Enum):
|
||||
"""
|
||||
The log_name to populate in the Cloud Audit Record. This is added to regress pulumi/pulumi issue #7913
|
||||
"""
|
||||
UNSPECIFIED_LOG_NAME = "UNSPECIFIED_LOG_NAME"
|
||||
"""
|
||||
Default. Should not be used.
|
||||
"""
|
||||
ADMIN_ACTIVITY = "ADMIN_ACTIVITY"
|
||||
"""
|
||||
Corresponds to "cloudaudit.googleapis.com/activity"
|
||||
"""
|
||||
DATA_ACCESS = "DATA_ACCESS"
|
||||
"""
|
||||
Corresponds to "cloudaudit.googleapis.com/data_access"
|
||||
"""
|
||||
SYNTHETIC = "SYNTHETIC"
|
||||
"""
|
||||
What if triple quotes \"\"\" are used in the description
|
||||
"""
|
||||
|
||||
|
||||
class ContainerBrightness(float, Enum):
|
||||
ZERO_POINT_ONE = 0.1
|
||||
ONE = 1
|
||||
|
|
|
@ -27,11 +27,17 @@ class RubberTreeVariety(str, Enum):
|
|||
types of rubber trees
|
||||
"""
|
||||
BURGUNDY = "Burgundy"
|
||||
"""A burgundy rubber tree."""
|
||||
"""
|
||||
A burgundy rubber tree.
|
||||
"""
|
||||
RUBY = "Ruby"
|
||||
"""A ruby rubber tree."""
|
||||
"""
|
||||
A ruby rubber tree.
|
||||
"""
|
||||
TINEKE = "Tineke"
|
||||
"""A tineke rubber tree."""
|
||||
"""
|
||||
A tineke rubber tree.
|
||||
"""
|
||||
|
||||
|
||||
class TreeSize(str, Enum):
|
||||
|
|
|
@ -84,6 +84,32 @@
|
|||
}
|
||||
},
|
||||
"types": {
|
||||
"plant::CloudAuditOptionsLogName": {
|
||||
"description": "The log_name to populate in the Cloud Audit Record. This is added to regress pulumi/pulumi issue #7913",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
{
|
||||
"name": "UnspecifiedLogName",
|
||||
"description": "Default. Should not be used.",
|
||||
"value": "UNSPECIFIED_LOG_NAME"
|
||||
},
|
||||
{
|
||||
"name": "AdminActivity",
|
||||
"description": "Corresponds to \"cloudaudit.googleapis.com/activity\"",
|
||||
"value": "ADMIN_ACTIVITY"
|
||||
},
|
||||
{
|
||||
"name": "DataAccess",
|
||||
"description": "Corresponds to \"cloudaudit.googleapis.com/data_access\"",
|
||||
"value": "DATA_ACCESS"
|
||||
},
|
||||
{
|
||||
"name": "Synthetic",
|
||||
"description": "What if triple quotes \"\"\" are used in the description",
|
||||
"value": "SYNTHETIC"
|
||||
}
|
||||
]
|
||||
},
|
||||
"plant::Container": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
@ -14,8 +14,14 @@ class RubberTreeVariety(str, Enum):
|
|||
types of rubber trees
|
||||
"""
|
||||
BURGUNDY = "Burgundy"
|
||||
"""A burgundy rubber tree."""
|
||||
"""
|
||||
A burgundy rubber tree.
|
||||
"""
|
||||
RUBY = "Ruby"
|
||||
"""A ruby rubber tree."""
|
||||
"""
|
||||
A ruby rubber tree.
|
||||
"""
|
||||
TINEKE = "Tineke"
|
||||
"""A tineke rubber tree."""
|
||||
"""
|
||||
A tineke rubber tree.
|
||||
"""
|
||||
|
|
|
@ -1812,7 +1812,7 @@ func (mod *modContext) genEnum(w io.Writer, enum *schema.EnumType) error {
|
|||
fmt.Fprintf(w, "%v\n", e.Value)
|
||||
}
|
||||
if e.Comment != "" {
|
||||
fmt.Fprintf(w, "%s\"\"\"%s\"\"\"\n", indent, e.Comment)
|
||||
printComment(w, e.Comment, indent)
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue