Skip to content

Commit 8b8596c

Browse files
Add support for source_workstation in workstations_workstation resource. (#12549) (#8938)
[upstream:3141d28edde5caf84cd1fc574408e608c33e03dc] Signed-off-by: Modular Magician <[email protected]>
1 parent 8f49a84 commit 8b8596c

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Diff for: .changelog/12549.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
workstations: add `source_workstation` field to `google_workstations_workstation` resource
3+
```

Diff for: google-beta/services/workstations/resource_workstations_workstation.go

+24
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ Please refer to the field 'effective_annotations' for all of the annotations pre
109109
Please refer to the field 'effective_labels' for all of the labels present on the resource.`,
110110
Elem: &schema.Schema{Type: schema.TypeString},
111111
},
112+
"source_workstation": {
113+
Type: schema.TypeString,
114+
Optional: true,
115+
ForceNew: true,
116+
Description: `Full resource name of the source workstation from which the workstation's persistent
117+
directories will be cloned from during creation.`,
118+
},
112119
"create_time": {
113120
Type: schema.TypeString,
114121
Computed: true,
@@ -186,6 +193,12 @@ func resourceWorkstationsWorkstationCreate(d *schema.ResourceData, meta interfac
186193
} else if v, ok := d.GetOkExists("env"); !tpgresource.IsEmptyValue(reflect.ValueOf(envProp)) && (ok || !reflect.DeepEqual(v, envProp)) {
187194
obj["env"] = envProp
188195
}
196+
source_workstationProp, err := expandWorkstationsWorkstationSourceWorkstation(d.Get("source_workstation"), d, config)
197+
if err != nil {
198+
return err
199+
} else if v, ok := d.GetOkExists("source_workstation"); !tpgresource.IsEmptyValue(reflect.ValueOf(source_workstationProp)) && (ok || !reflect.DeepEqual(v, source_workstationProp)) {
200+
obj["source_workstation"] = source_workstationProp
201+
}
189202
labelsProp, err := expandWorkstationsWorkstationEffectiveLabels(d.Get("effective_labels"), d, config)
190203
if err != nil {
191204
return err
@@ -324,6 +337,9 @@ func resourceWorkstationsWorkstationRead(d *schema.ResourceData, meta interface{
324337
if err := d.Set("state", flattenWorkstationsWorkstationState(res["state"], d, config)); err != nil {
325338
return fmt.Errorf("Error reading Workstation: %s", err)
326339
}
340+
if err := d.Set("source_workstation", flattenWorkstationsWorkstationSourceWorkstation(res["source_workstation"], d, config)); err != nil {
341+
return fmt.Errorf("Error reading Workstation: %s", err)
342+
}
327343
if err := d.Set("terraform_labels", flattenWorkstationsWorkstationTerraformLabels(res["labels"], d, config)); err != nil {
328344
return fmt.Errorf("Error reading Workstation: %s", err)
329345
}
@@ -579,6 +595,10 @@ func flattenWorkstationsWorkstationState(v interface{}, d *schema.ResourceData,
579595
return v
580596
}
581597

598+
func flattenWorkstationsWorkstationSourceWorkstation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
599+
return v
600+
}
601+
582602
func flattenWorkstationsWorkstationTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
583603
if v == nil {
584604
return v
@@ -617,6 +637,10 @@ func expandWorkstationsWorkstationEnv(v interface{}, d tpgresource.TerraformReso
617637
return m, nil
618638
}
619639

640+
func expandWorkstationsWorkstationSourceWorkstation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
641+
return v, nil
642+
}
643+
620644
func expandWorkstationsWorkstationEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
621645
if v == nil {
622646
return map[string]string{}, nil

Diff for: website/docs/r/workstations_workstation.html.markdown

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ The following arguments are supported:
150150
(Optional)
151151
'Client-specified environment variables passed to the workstation container's entrypoint.'
152152

153+
* `source_workstation` -
154+
(Optional)
155+
Full resource name of the source workstation from which the workstation's persistent
156+
directories will be cloned from during creation.
157+
153158
* `project` - (Optional) The ID of the project in which the resource belongs.
154159
If it is not provided, the provider project is used.
155160

0 commit comments

Comments
 (0)