@@ -72,7 +72,7 @@ func resourceClouddeployTarget() *schema.Resource {
72
72
Description : "Information specifying an Anthos Cluster." ,
73
73
MaxItems : 1 ,
74
74
Elem : ClouddeployTargetAnthosClusterSchema (),
75
- ConflictsWith : []string {"gke" },
75
+ ConflictsWith : []string {"gke" , "run" },
76
76
},
77
77
78
78
"description" : {
@@ -95,7 +95,7 @@ func resourceClouddeployTarget() *schema.Resource {
95
95
Description : "Information specifying a GKE Cluster." ,
96
96
MaxItems : 1 ,
97
97
Elem : ClouddeployTargetGkeSchema (),
98
- ConflictsWith : []string {"anthos_cluster" },
98
+ ConflictsWith : []string {"anthos_cluster" , "run" },
99
99
},
100
100
101
101
"labels" : {
@@ -120,6 +120,15 @@ func resourceClouddeployTarget() *schema.Resource {
120
120
Description : "Optional. Whether or not the `Target` requires approval." ,
121
121
},
122
122
123
+ "run" : {
124
+ Type : schema .TypeList ,
125
+ Optional : true ,
126
+ Description : "Information specifying a Cloud Run deployment target." ,
127
+ MaxItems : 1 ,
128
+ Elem : ClouddeployTargetRunSchema (),
129
+ ConflictsWith : []string {"gke" , "anthos_cluster" },
130
+ },
131
+
123
132
"create_time" : {
124
133
Type : schema .TypeString ,
125
134
Computed : true ,
@@ -183,6 +192,12 @@ func ClouddeployTargetExecutionConfigsSchema() *schema.Resource {
183
192
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." ,
184
193
},
185
194
195
+ "execution_timeout" : {
196
+ Type : schema .TypeString ,
197
+ Optional : true ,
198
+ 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." ,
199
+ },
200
+
186
201
"service_account" : {
187
202
Type : schema .TypeString ,
188
203
Computed : true ,
@@ -219,6 +234,18 @@ func ClouddeployTargetGkeSchema() *schema.Resource {
219
234
}
220
235
}
221
236
237
+ func ClouddeployTargetRunSchema () * schema.Resource {
238
+ return & schema.Resource {
239
+ Schema : map [string ]* schema.Schema {
240
+ "location" : {
241
+ Type : schema .TypeString ,
242
+ Required : true ,
243
+ Description : "Required. The location where the Cloud Run Service should be located. Format is `projects/{project}/locations/{location}`." ,
244
+ },
245
+ },
246
+ }
247
+ }
248
+
222
249
func resourceClouddeployTargetCreate (d * schema.ResourceData , meta interface {}) error {
223
250
config := meta .(* Config )
224
251
project , err := getProject (d , config )
@@ -237,6 +264,7 @@ func resourceClouddeployTargetCreate(d *schema.ResourceData, meta interface{}) e
237
264
Labels : checkStringMap (d .Get ("labels" )),
238
265
Project : dcl .String (project ),
239
266
RequireApproval : dcl .Bool (d .Get ("require_approval" ).(bool )),
267
+ Run : expandClouddeployTargetRun (d .Get ("run" )),
240
268
}
241
269
242
270
id , err := obj .ID ()
@@ -294,6 +322,7 @@ func resourceClouddeployTargetRead(d *schema.ResourceData, meta interface{}) err
294
322
Labels : checkStringMap (d .Get ("labels" )),
295
323
Project : dcl .String (project ),
296
324
RequireApproval : dcl .Bool (d .Get ("require_approval" ).(bool )),
325
+ Run : expandClouddeployTargetRun (d .Get ("run" )),
297
326
}
298
327
299
328
userAgent , err := generateUserAgentString (d , config .userAgent )
@@ -348,6 +377,9 @@ func resourceClouddeployTargetRead(d *schema.ResourceData, meta interface{}) err
348
377
if err = d .Set ("require_approval" , res .RequireApproval ); err != nil {
349
378
return fmt .Errorf ("error setting require_approval in state: %s" , err )
350
379
}
380
+ if err = d .Set ("run" , flattenClouddeployTargetRun (res .Run )); err != nil {
381
+ return fmt .Errorf ("error setting run in state: %s" , err )
382
+ }
351
383
if err = d .Set ("create_time" , res .CreateTime ); err != nil {
352
384
return fmt .Errorf ("error setting create_time in state: %s" , err )
353
385
}
@@ -384,6 +416,7 @@ func resourceClouddeployTargetUpdate(d *schema.ResourceData, meta interface{}) e
384
416
Labels : checkStringMap (d .Get ("labels" )),
385
417
Project : dcl .String (project ),
386
418
RequireApproval : dcl .Bool (d .Get ("require_approval" ).(bool )),
419
+ Run : expandClouddeployTargetRun (d .Get ("run" )),
387
420
}
388
421
directive := UpdateDirective
389
422
userAgent , err := generateUserAgentString (d , config .userAgent )
@@ -436,6 +469,7 @@ func resourceClouddeployTargetDelete(d *schema.ResourceData, meta interface{}) e
436
469
Labels : checkStringMap (d .Get ("labels" )),
437
470
Project : dcl .String (project ),
438
471
RequireApproval : dcl .Bool (d .Get ("require_approval" ).(bool )),
472
+ Run : expandClouddeployTargetRun (d .Get ("run" )),
439
473
}
440
474
441
475
log .Printf ("[DEBUG] Deleting Target %q" , d .Id ())
@@ -535,10 +569,11 @@ func expandClouddeployTargetExecutionConfigs(o interface{}) *clouddeploy.TargetE
535
569
536
570
obj := o .(map [string ]interface {})
537
571
return & clouddeploy.TargetExecutionConfigs {
538
- Usages : expandClouddeployTargetExecutionConfigsUsagesArray (obj ["usages" ]),
539
- ArtifactStorage : dcl .StringOrNil (obj ["artifact_storage" ].(string )),
540
- ServiceAccount : dcl .StringOrNil (obj ["service_account" ].(string )),
541
- WorkerPool : dcl .String (obj ["worker_pool" ].(string )),
572
+ Usages : expandClouddeployTargetExecutionConfigsUsagesArray (obj ["usages" ]),
573
+ ArtifactStorage : dcl .StringOrNil (obj ["artifact_storage" ].(string )),
574
+ ExecutionTimeout : dcl .String (obj ["execution_timeout" ].(string )),
575
+ ServiceAccount : dcl .StringOrNil (obj ["service_account" ].(string )),
576
+ WorkerPool : dcl .String (obj ["worker_pool" ].(string )),
542
577
}
543
578
}
544
579
@@ -561,10 +596,11 @@ func flattenClouddeployTargetExecutionConfigs(obj *clouddeploy.TargetExecutionCo
561
596
return nil
562
597
}
563
598
transformed := map [string ]interface {}{
564
- "usages" : flattenClouddeployTargetExecutionConfigsUsagesArray (obj .Usages ),
565
- "artifact_storage" : obj .ArtifactStorage ,
566
- "service_account" : obj .ServiceAccount ,
567
- "worker_pool" : obj .WorkerPool ,
599
+ "usages" : flattenClouddeployTargetExecutionConfigsUsagesArray (obj .Usages ),
600
+ "artifact_storage" : obj .ArtifactStorage ,
601
+ "execution_timeout" : obj .ExecutionTimeout ,
602
+ "service_account" : obj .ServiceAccount ,
603
+ "worker_pool" : obj .WorkerPool ,
568
604
}
569
605
570
606
return transformed
@@ -597,6 +633,32 @@ func flattenClouddeployTargetGke(obj *clouddeploy.TargetGke) interface{} {
597
633
598
634
return []interface {}{transformed }
599
635
636
+ }
637
+
638
+ func expandClouddeployTargetRun (o interface {}) * clouddeploy.TargetRun {
639
+ if o == nil {
640
+ return clouddeploy .EmptyTargetRun
641
+ }
642
+ objArr := o .([]interface {})
643
+ if len (objArr ) == 0 || objArr [0 ] == nil {
644
+ return clouddeploy .EmptyTargetRun
645
+ }
646
+ obj := objArr [0 ].(map [string ]interface {})
647
+ return & clouddeploy.TargetRun {
648
+ Location : dcl .String (obj ["location" ].(string )),
649
+ }
650
+ }
651
+
652
+ func flattenClouddeployTargetRun (obj * clouddeploy.TargetRun ) interface {} {
653
+ if obj == nil || obj .Empty () {
654
+ return nil
655
+ }
656
+ transformed := map [string ]interface {}{
657
+ "location" : obj .Location ,
658
+ }
659
+
660
+ return []interface {}{transformed }
661
+
600
662
}
601
663
func flattenClouddeployTargetExecutionConfigsUsagesArray (obj []clouddeploy.TargetExecutionConfigsUsagesEnum ) interface {} {
602
664
if obj == nil {
0 commit comments