Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade DCL to v1.21.1 #12619

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changelog/6576.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:enhancement
eventarc: added `channels` and `conditions` fields to `google_eventarc_trigger`
```
```release-note:enhancement
clouddeploy: added `serial_pipeline.stages.strategy` field to `google_clouddeploy_delivery_pipeline
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ go 1.18

require (
cloud.google.com/go/bigtable v1.16.0
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.19.0
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.21.1
github.com/apparentlymart/go-cidr v1.1.0
github.com/client9/misspell v0.3.4
github.com/davecgh/go-spew v1.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM=
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.19.0 h1:4YAtk4xuOCxUSkGdwlDhkX7DTP4VwLZCoebGGEsU+U4=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.19.0/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.21.1 h1:WPrdiImW8A7kmMZF95dVAybR3H/ItAfJXPdRJnwf/yg=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.21.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
Expand Down
88 changes: 88 additions & 0 deletions google/resource_clouddeploy_delivery_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ func ClouddeployDeliveryPipelineSerialPipelineStagesSchema() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
},

"strategy": {
Type: schema.TypeList,
Optional: true,
Description: "Optional. The strategy to use for a `Rollout` to this stage.",
MaxItems: 1,
Elem: ClouddeployDeliveryPipelineSerialPipelineStagesStrategySchema(),
},

"target_id": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -168,6 +176,32 @@ func ClouddeployDeliveryPipelineSerialPipelineStagesSchema() *schema.Resource {
}
}

func ClouddeployDeliveryPipelineSerialPipelineStagesStrategySchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"standard": {
Type: schema.TypeList,
Optional: true,
Description: "Standard deployment strategy executes a single deploy and allows verifying the deployment.",
MaxItems: 1,
Elem: ClouddeployDeliveryPipelineSerialPipelineStagesStrategyStandardSchema(),
},
},
}
}

func ClouddeployDeliveryPipelineSerialPipelineStagesStrategyStandardSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"verify": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether to verify a deployment.",
},
},
}
}

func ClouddeployDeliveryPipelineConditionSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -534,6 +568,7 @@ func expandClouddeployDeliveryPipelineSerialPipelineStages(o interface{}) *cloud
obj := o.(map[string]interface{})
return &clouddeploy.DeliveryPipelineSerialPipelineStages{
Profiles: expandStringArray(obj["profiles"]),
Strategy: expandClouddeployDeliveryPipelineSerialPipelineStagesStrategy(obj["strategy"]),
TargetId: dcl.String(obj["target_id"].(string)),
}
}
Expand All @@ -558,13 +593,66 @@ func flattenClouddeployDeliveryPipelineSerialPipelineStages(obj *clouddeploy.Del
}
transformed := map[string]interface{}{
"profiles": obj.Profiles,
"strategy": flattenClouddeployDeliveryPipelineSerialPipelineStagesStrategy(obj.Strategy),
"target_id": obj.TargetId,
}

return transformed

}

func expandClouddeployDeliveryPipelineSerialPipelineStagesStrategy(o interface{}) *clouddeploy.DeliveryPipelineSerialPipelineStagesStrategy {
if o == nil {
return clouddeploy.EmptyDeliveryPipelineSerialPipelineStagesStrategy
}
objArr := o.([]interface{})
if len(objArr) == 0 || objArr[0] == nil {
return clouddeploy.EmptyDeliveryPipelineSerialPipelineStagesStrategy
}
obj := objArr[0].(map[string]interface{})
return &clouddeploy.DeliveryPipelineSerialPipelineStagesStrategy{
Standard: expandClouddeployDeliveryPipelineSerialPipelineStagesStrategyStandard(obj["standard"]),
}
}

func flattenClouddeployDeliveryPipelineSerialPipelineStagesStrategy(obj *clouddeploy.DeliveryPipelineSerialPipelineStagesStrategy) interface{} {
if obj == nil || obj.Empty() {
return nil
}
transformed := map[string]interface{}{
"standard": flattenClouddeployDeliveryPipelineSerialPipelineStagesStrategyStandard(obj.Standard),
}

return []interface{}{transformed}

}

func expandClouddeployDeliveryPipelineSerialPipelineStagesStrategyStandard(o interface{}) *clouddeploy.DeliveryPipelineSerialPipelineStagesStrategyStandard {
if o == nil {
return clouddeploy.EmptyDeliveryPipelineSerialPipelineStagesStrategyStandard
}
objArr := o.([]interface{})
if len(objArr) == 0 || objArr[0] == nil {
return clouddeploy.EmptyDeliveryPipelineSerialPipelineStagesStrategyStandard
}
obj := objArr[0].(map[string]interface{})
return &clouddeploy.DeliveryPipelineSerialPipelineStagesStrategyStandard{
Verify: dcl.Bool(obj["verify"].(bool)),
}
}

func flattenClouddeployDeliveryPipelineSerialPipelineStagesStrategyStandard(obj *clouddeploy.DeliveryPipelineSerialPipelineStagesStrategyStandard) interface{} {
if obj == nil || obj.Empty() {
return nil
}
transformed := map[string]interface{}{
"verify": obj.Verify,
}

return []interface{}{transformed}

}

func flattenClouddeployDeliveryPipelineCondition(obj *clouddeploy.DeliveryPipelineCondition) interface{} {
if obj == nil || obj.Empty() {
return nil
Expand Down
82 changes: 72 additions & 10 deletions google/resource_clouddeploy_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func resourceClouddeployTarget() *schema.Resource {
Description: "Information specifying an Anthos Cluster.",
MaxItems: 1,
Elem: ClouddeployTargetAnthosClusterSchema(),
ConflictsWith: []string{"gke"},
ConflictsWith: []string{"gke", "run"},
},

"description": {
Expand All @@ -95,7 +95,7 @@ func resourceClouddeployTarget() *schema.Resource {
Description: "Information specifying a GKE Cluster.",
MaxItems: 1,
Elem: ClouddeployTargetGkeSchema(),
ConflictsWith: []string{"anthos_cluster"},
ConflictsWith: []string{"anthos_cluster", "run"},
},

"labels": {
Expand All @@ -120,6 +120,15 @@ func resourceClouddeployTarget() *schema.Resource {
Description: "Optional. Whether or not the `Target` requires approval.",
},

"run": {
Type: schema.TypeList,
Optional: true,
Description: "Information specifying a Cloud Run deployment target.",
MaxItems: 1,
Elem: ClouddeployTargetRunSchema(),
ConflictsWith: []string{"gke", "anthos_cluster"},
},

"create_time": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -183,6 +192,12 @@ func ClouddeployTargetExecutionConfigsSchema() *schema.Resource {
Description: "Optional. Cloud Storage location in which to store execution outputs. This can either be a bucket (\"gs://my-bucket\") or a path within a bucket (\"gs://my-bucket/my-dir\"). If unspecified, a default bucket located in the same region will be used.",
},

"execution_timeout": {
Type: schema.TypeString,
Optional: true,
Description: "Optional. Execution timeout for a Cloud Build Execution. This must be between 10m and 24h in seconds format. If unspecified, a default timeout of 1h is used.",
},

"service_account": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -219,6 +234,18 @@ func ClouddeployTargetGkeSchema() *schema.Resource {
}
}

func ClouddeployTargetRunSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"location": {
Type: schema.TypeString,
Required: true,
Description: "Required. The location where the Cloud Run Service should be located. Format is `projects/{project}/locations/{location}`.",
},
},
}
}

func resourceClouddeployTargetCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
project, err := getProject(d, config)
Expand All @@ -237,6 +264,7 @@ func resourceClouddeployTargetCreate(d *schema.ResourceData, meta interface{}) e
Labels: checkStringMap(d.Get("labels")),
Project: dcl.String(project),
RequireApproval: dcl.Bool(d.Get("require_approval").(bool)),
Run: expandClouddeployTargetRun(d.Get("run")),
}

id, err := obj.ID()
Expand Down Expand Up @@ -294,6 +322,7 @@ func resourceClouddeployTargetRead(d *schema.ResourceData, meta interface{}) err
Labels: checkStringMap(d.Get("labels")),
Project: dcl.String(project),
RequireApproval: dcl.Bool(d.Get("require_approval").(bool)),
Run: expandClouddeployTargetRun(d.Get("run")),
}

userAgent, err := generateUserAgentString(d, config.userAgent)
Expand Down Expand Up @@ -348,6 +377,9 @@ func resourceClouddeployTargetRead(d *schema.ResourceData, meta interface{}) err
if err = d.Set("require_approval", res.RequireApproval); err != nil {
return fmt.Errorf("error setting require_approval in state: %s", err)
}
if err = d.Set("run", flattenClouddeployTargetRun(res.Run)); err != nil {
return fmt.Errorf("error setting run in state: %s", err)
}
if err = d.Set("create_time", res.CreateTime); err != nil {
return fmt.Errorf("error setting create_time in state: %s", err)
}
Expand Down Expand Up @@ -384,6 +416,7 @@ func resourceClouddeployTargetUpdate(d *schema.ResourceData, meta interface{}) e
Labels: checkStringMap(d.Get("labels")),
Project: dcl.String(project),
RequireApproval: dcl.Bool(d.Get("require_approval").(bool)),
Run: expandClouddeployTargetRun(d.Get("run")),
}
directive := UpdateDirective
userAgent, err := generateUserAgentString(d, config.userAgent)
Expand Down Expand Up @@ -436,6 +469,7 @@ func resourceClouddeployTargetDelete(d *schema.ResourceData, meta interface{}) e
Labels: checkStringMap(d.Get("labels")),
Project: dcl.String(project),
RequireApproval: dcl.Bool(d.Get("require_approval").(bool)),
Run: expandClouddeployTargetRun(d.Get("run")),
}

log.Printf("[DEBUG] Deleting Target %q", d.Id())
Expand Down Expand Up @@ -535,10 +569,11 @@ func expandClouddeployTargetExecutionConfigs(o interface{}) *clouddeploy.TargetE

obj := o.(map[string]interface{})
return &clouddeploy.TargetExecutionConfigs{
Usages: expandClouddeployTargetExecutionConfigsUsagesArray(obj["usages"]),
ArtifactStorage: dcl.StringOrNil(obj["artifact_storage"].(string)),
ServiceAccount: dcl.StringOrNil(obj["service_account"].(string)),
WorkerPool: dcl.String(obj["worker_pool"].(string)),
Usages: expandClouddeployTargetExecutionConfigsUsagesArray(obj["usages"]),
ArtifactStorage: dcl.StringOrNil(obj["artifact_storage"].(string)),
ExecutionTimeout: dcl.String(obj["execution_timeout"].(string)),
ServiceAccount: dcl.StringOrNil(obj["service_account"].(string)),
WorkerPool: dcl.String(obj["worker_pool"].(string)),
}
}

Expand All @@ -561,10 +596,11 @@ func flattenClouddeployTargetExecutionConfigs(obj *clouddeploy.TargetExecutionCo
return nil
}
transformed := map[string]interface{}{
"usages": flattenClouddeployTargetExecutionConfigsUsagesArray(obj.Usages),
"artifact_storage": obj.ArtifactStorage,
"service_account": obj.ServiceAccount,
"worker_pool": obj.WorkerPool,
"usages": flattenClouddeployTargetExecutionConfigsUsagesArray(obj.Usages),
"artifact_storage": obj.ArtifactStorage,
"execution_timeout": obj.ExecutionTimeout,
"service_account": obj.ServiceAccount,
"worker_pool": obj.WorkerPool,
}

return transformed
Expand Down Expand Up @@ -597,6 +633,32 @@ func flattenClouddeployTargetGke(obj *clouddeploy.TargetGke) interface{} {

return []interface{}{transformed}

}

func expandClouddeployTargetRun(o interface{}) *clouddeploy.TargetRun {
if o == nil {
return clouddeploy.EmptyTargetRun
}
objArr := o.([]interface{})
if len(objArr) == 0 || objArr[0] == nil {
return clouddeploy.EmptyTargetRun
}
obj := objArr[0].(map[string]interface{})
return &clouddeploy.TargetRun{
Location: dcl.String(obj["location"].(string)),
}
}

func flattenClouddeployTargetRun(obj *clouddeploy.TargetRun) interface{} {
if obj == nil || obj.Empty() {
return nil
}
transformed := map[string]interface{}{
"location": obj.Location,
}

return []interface{}{transformed}

}
func flattenClouddeployTargetExecutionConfigsUsagesArray(obj []clouddeploy.TargetExecutionConfigsUsagesEnum) interface{} {
if obj == nil {
Expand Down
Loading