pulumi/tests/testdata/codegen/azure-native-pp/go/azure-native.go

94 lines
3.2 KiB
Go
Raw Permalink Normal View History

package main
import (
"github.com/pulumi/pulumi-azure-native/sdk/go/azure/cdn"
"github.com/pulumi/pulumi-azure-native/sdk/go/azure/network"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := network.NewFrontDoor(ctx, "frontDoor", &network.FrontDoorArgs{
ResourceGroupName: pulumi.String("someGroupName"),
RoutingRules: network.RoutingRuleArray{
&network.RoutingRuleArgs{
RouteConfiguration: network.ForwardingConfiguration{
OdataType: "#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration",
BackendPool: network.SubResource{
Id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1",
},
},
},
},
})
if err != nil {
return err
}
_, err = cdn.NewEndpoint(ctx, "endpoint", &cdn.EndpointArgs{
Origins: cdn.DeepCreatedOriginArray{},
DeliveryPolicy: &cdn.EndpointPropertiesUpdateParametersDeliveryPolicyArgs{
[docs/go-program-gen] Fix generating constructor syntax examples for kubernetes (#16574) In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463
2024-07-05 12:42:41 +00:00
Rules: cdn.DeliveryRuleArray{
&cdn.DeliveryRuleArgs{
Actions: pulumi.Array{
[docs/go-program-gen] Fix generating constructor syntax examples for kubernetes (#16574) In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463
2024-07-05 12:42:41 +00:00
cdn.DeliveryRuleCacheExpirationAction{
Name: "CacheExpiration",
[docs/go-program-gen] Fix generating constructor syntax examples for kubernetes (#16574) In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463
2024-07-05 12:42:41 +00:00
Parameters: cdn.CacheExpirationActionParameters{
[program-gen] Fix enum resolution from types of the form Union[string, Enum] and emit fully qualified enum cases (#15696) # Description This PR improves enum type resolution from strings. When we try to resolve `Union[string, Enum]` for a string expression, we choose `string` because it is the more general type since not every string is assignable to `Enum`. However, here we spacial case strings that are actually part of that `Enum`. The result is that `pcl.LowerConversion` will choose `Enum` from `Union[string, Enum]` when the value of the input string is compatible with the enum. This greatly improves program-gen for all of typescript, python, csharp and go which now will emit the fully qualified enum cases instead of emitting strings. Closes https://github.com/pulumi/pulumi-dotnet/issues/41 which is supposed to be a duplicate of https://github.com/pulumi/pulumi-azure-native/issues/2616 but that is not the case (the former is about unions of objects, the latter is unions of enums and strings) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-15 17:49:12 +00:00
CacheBehavior: cdn.CacheBehaviorOverride,
CacheDuration: "10:10:09",
[program-gen] Fix enum resolution from types of the form Union[string, Enum] and emit fully qualified enum cases (#15696) # Description This PR improves enum type resolution from strings. When we try to resolve `Union[string, Enum]` for a string expression, we choose `string` because it is the more general type since not every string is assignable to `Enum`. However, here we spacial case strings that are actually part of that `Enum`. The result is that `pcl.LowerConversion` will choose `Enum` from `Union[string, Enum]` when the value of the input string is compatible with the enum. This greatly improves program-gen for all of typescript, python, csharp and go which now will emit the fully qualified enum cases instead of emitting strings. Closes https://github.com/pulumi/pulumi-dotnet/issues/41 which is supposed to be a duplicate of https://github.com/pulumi/pulumi-azure-native/issues/2616 but that is not the case (the former is about unions of objects, the latter is unions of enums and strings) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-15 17:49:12 +00:00
CacheType: cdn.CacheTypeAll,
OdataType: "#Microsoft.Azure.Cdn.Models.DeliveryRuleCacheExpirationActionParameters",
},
},
[docs/go-program-gen] Fix generating constructor syntax examples for kubernetes (#16574) In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463
2024-07-05 12:42:41 +00:00
cdn.DeliveryRuleResponseHeaderAction{
Name: "ModifyResponseHeader",
[docs/go-program-gen] Fix generating constructor syntax examples for kubernetes (#16574) In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463
2024-07-05 12:42:41 +00:00
Parameters: cdn.HeaderActionParameters{
[program-gen] Fix enum resolution from types of the form Union[string, Enum] and emit fully qualified enum cases (#15696) # Description This PR improves enum type resolution from strings. When we try to resolve `Union[string, Enum]` for a string expression, we choose `string` because it is the more general type since not every string is assignable to `Enum`. However, here we spacial case strings that are actually part of that `Enum`. The result is that `pcl.LowerConversion` will choose `Enum` from `Union[string, Enum]` when the value of the input string is compatible with the enum. This greatly improves program-gen for all of typescript, python, csharp and go which now will emit the fully qualified enum cases instead of emitting strings. Closes https://github.com/pulumi/pulumi-dotnet/issues/41 which is supposed to be a duplicate of https://github.com/pulumi/pulumi-azure-native/issues/2616 but that is not the case (the former is about unions of objects, the latter is unions of enums and strings) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-15 17:49:12 +00:00
HeaderAction: cdn.HeaderActionOverwrite,
HeaderName: "Access-Control-Allow-Origin",
OdataType: "#Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters",
Value: "*",
},
},
[docs/go-program-gen] Fix generating constructor syntax examples for kubernetes (#16574) In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463
2024-07-05 12:42:41 +00:00
cdn.DeliveryRuleRequestHeaderAction{
Name: "ModifyRequestHeader",
[docs/go-program-gen] Fix generating constructor syntax examples for kubernetes (#16574) In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463
2024-07-05 12:42:41 +00:00
Parameters: cdn.HeaderActionParameters{
[program-gen] Fix enum resolution from types of the form Union[string, Enum] and emit fully qualified enum cases (#15696) # Description This PR improves enum type resolution from strings. When we try to resolve `Union[string, Enum]` for a string expression, we choose `string` because it is the more general type since not every string is assignable to `Enum`. However, here we spacial case strings that are actually part of that `Enum`. The result is that `pcl.LowerConversion` will choose `Enum` from `Union[string, Enum]` when the value of the input string is compatible with the enum. This greatly improves program-gen for all of typescript, python, csharp and go which now will emit the fully qualified enum cases instead of emitting strings. Closes https://github.com/pulumi/pulumi-dotnet/issues/41 which is supposed to be a duplicate of https://github.com/pulumi/pulumi-azure-native/issues/2616 but that is not the case (the former is about unions of objects, the latter is unions of enums and strings) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-15 17:49:12 +00:00
HeaderAction: cdn.HeaderActionOverwrite,
HeaderName: "Accept-Encoding",
OdataType: "#Microsoft.Azure.Cdn.Models.DeliveryRuleHeaderActionParameters",
Value: "gzip",
},
},
},
Conditions: pulumi.Array{
[docs/go-program-gen] Fix generating constructor syntax examples for kubernetes (#16574) In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463
2024-07-05 12:42:41 +00:00
cdn.DeliveryRuleRemoteAddressCondition{
Name: "RemoteAddress",
[docs/go-program-gen] Fix generating constructor syntax examples for kubernetes (#16574) In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463
2024-07-05 12:42:41 +00:00
Parameters: cdn.RemoteAddressMatchConditionParameters{
MatchValues: []string{
"192.168.1.0/24",
"10.0.0.0/24",
},
NegateCondition: true,
OdataType: "#Microsoft.Azure.Cdn.Models.DeliveryRuleRemoteAddressConditionParameters",
[program-gen] Fix enum resolution from types of the form Union[string, Enum] and emit fully qualified enum cases (#15696) # Description This PR improves enum type resolution from strings. When we try to resolve `Union[string, Enum]` for a string expression, we choose `string` because it is the more general type since not every string is assignable to `Enum`. However, here we spacial case strings that are actually part of that `Enum`. The result is that `pcl.LowerConversion` will choose `Enum` from `Union[string, Enum]` when the value of the input string is compatible with the enum. This greatly improves program-gen for all of typescript, python, csharp and go which now will emit the fully qualified enum cases instead of emitting strings. Closes https://github.com/pulumi/pulumi-dotnet/issues/41 which is supposed to be a duplicate of https://github.com/pulumi/pulumi-azure-native/issues/2616 but that is not the case (the former is about unions of objects, the latter is unions of enums and strings) ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [x] I have run `make lint` to verify my code passes the lint check - [x] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [x] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [x] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2024-03-15 17:49:12 +00:00
Operator: cdn.RemoteAddressOperatorIPMatch,
},
},
},
Name: pulumi.String("rule1"),
Order: pulumi.Int(1),
},
},
},
EndpointName: pulumi.String("endpoint1"),
IsCompressionEnabled: pulumi.Bool(true),
IsHttpAllowed: pulumi.Bool(true),
IsHttpsAllowed: pulumi.Bool(true),
Location: pulumi.String("WestUs"),
ProfileName: pulumi.String("profileName"),
ResourceGroupName: pulumi.String("resourceGroupName"),
})
if err != nil {
return err
}
return nil
})
}