Skip to content

Commit

Permalink
Fix crossplane-contrib#385, provide LOAD_BALANCER_TYPE_UNSPECIFIED as…
Browse files Browse the repository at this point in the history
… default if nothing is set
  • Loading branch information
edenreich committed May 15, 2022
1 parent 6caeb70 commit 060ed05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/clients/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ func GenerateAddonsConfig(in *v1beta2.AddonsConfig, cluster *container.Cluster)
if cluster.AddonsConfig.CloudRunConfig == nil {
cluster.AddonsConfig.CloudRunConfig = &container.CloudRunConfig{}
}
if in.CloudRunConfig.LoadBalancerType == nil {
cluster.AddonsConfig.CloudRunConfig.LoadBalancerType = "LOAD_BALANCER_TYPE_UNSPECIFIED"
}
cluster.AddonsConfig.CloudRunConfig.Disabled = in.CloudRunConfig.Disabled
cluster.AddonsConfig.CloudRunConfig.LoadBalancerType = gcp.StringValue(in.CloudRunConfig.LoadBalancerType)
cluster.AddonsConfig.CloudRunConfig.ForceSendFields = []string{"Disabled", "LoadBalancerType"}
}
if in.ConfigConnectorConfig != nil {
Expand Down
8 changes: 8 additions & 0 deletions pkg/clients/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ func TestGenerateAddonsConfig(t *testing.T) {
cluster: &container.Cluster{},
params: params(func(p *v1beta2.ClusterParameters) {
p.AddonsConfig = &v1beta2.AddonsConfig{
CloudRunConfig: &v1beta2.CloudRunConfig{
Disabled: true,
},
HorizontalPodAutoscaling: &v1beta2.HorizontalPodAutoscaling{
Disabled: true,
},
Expand All @@ -349,6 +352,11 @@ func TestGenerateAddonsConfig(t *testing.T) {
},
want: cluster(func(c *container.Cluster) {
c.AddonsConfig = &container.AddonsConfig{
CloudRunConfig: &container.CloudRunConfig{
Disabled: true,
LoadBalancerType: "LOAD_BALANCER_TYPE_UNSPECIFIED",
ForceSendFields: []string{"Disabled", "LoadBalancerType"},
},
HorizontalPodAutoscaling: &container.HorizontalPodAutoscaling{
Disabled: true,
ForceSendFields: []string{"Disabled"},
Expand Down

0 comments on commit 060ed05

Please sign in to comment.