@@ -83,6 +83,12 @@ func ResourceWorkstationsWorkstation() *schema.Resource {
8383 Optional : true ,
8484 Description : `Human-readable name for this resource.` ,
8585 },
86+ "env" : {
87+ Type : schema .TypeMap ,
88+ Optional : true ,
89+ Description : `'Client-specified environment variables passed to the workstation container's entrypoint.'` ,
90+ Elem : & schema.Schema {Type : schema .TypeString },
91+ },
8692 "labels" : {
8793 Type : schema .TypeMap ,
8894 Optional : true ,
@@ -153,6 +159,12 @@ func resourceWorkstationsWorkstationCreate(d *schema.ResourceData, meta interfac
153159 } else if v , ok := d .GetOkExists ("annotations" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (annotationsProp )) && (ok || ! reflect .DeepEqual (v , annotationsProp )) {
154160 obj ["annotations" ] = annotationsProp
155161 }
162+ envProp , err := expandWorkstationsWorkstationEnv (d .Get ("env" ), d , config )
163+ if err != nil {
164+ return err
165+ } else if v , ok := d .GetOkExists ("env" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (envProp )) && (ok || ! reflect .DeepEqual (v , envProp )) {
166+ obj ["env" ] = envProp
167+ }
156168
157169 url , err := tpgresource .ReplaceVars (d , config , "{{WorkstationsBasePath}}projects/{{project}}/locations/{{location}}/workstationClusters/{{workstation_cluster_id}}/workstationConfigs/{{workstation_config_id}}/workstations?workstationId={{workstation_id}}" )
158170 if err != nil {
@@ -263,6 +275,9 @@ func resourceWorkstationsWorkstationRead(d *schema.ResourceData, meta interface{
263275 if err := d .Set ("annotations" , flattenWorkstationsWorkstationAnnotations (res ["annotations" ], d , config )); err != nil {
264276 return fmt .Errorf ("Error reading Workstation: %s" , err )
265277 }
278+ if err := d .Set ("env" , flattenWorkstationsWorkstationEnv (res ["env" ], d , config )); err != nil {
279+ return fmt .Errorf ("Error reading Workstation: %s" , err )
280+ }
266281 if err := d .Set ("create_time" , flattenWorkstationsWorkstationCreateTime (res ["createTime" ], d , config )); err != nil {
267282 return fmt .Errorf ("Error reading Workstation: %s" , err )
268283 }
@@ -310,6 +325,12 @@ func resourceWorkstationsWorkstationUpdate(d *schema.ResourceData, meta interfac
310325 } else if v , ok := d .GetOkExists ("annotations" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , annotationsProp )) {
311326 obj ["annotations" ] = annotationsProp
312327 }
328+ envProp , err := expandWorkstationsWorkstationEnv (d .Get ("env" ), d , config )
329+ if err != nil {
330+ return err
331+ } else if v , ok := d .GetOkExists ("env" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , envProp )) {
332+ obj ["env" ] = envProp
333+ }
313334
314335 url , err := tpgresource .ReplaceVars (d , config , "{{WorkstationsBasePath}}projects/{{project}}/locations/{{location}}/workstationClusters/{{workstation_cluster_id}}/workstationConfigs/{{workstation_config_id}}/workstations/{{workstation_id}}" )
315336 if err != nil {
@@ -330,6 +351,10 @@ func resourceWorkstationsWorkstationUpdate(d *schema.ResourceData, meta interfac
330351 if d .HasChange ("annotations" ) {
331352 updateMask = append (updateMask , "annotations" )
332353 }
354+
355+ if d .HasChange ("env" ) {
356+ updateMask = append (updateMask , "env" )
357+ }
333358 // updateMask is a URL parameter but not present in the schema, so ReplaceVars
334359 // won't set it
335360 url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -462,6 +487,10 @@ func flattenWorkstationsWorkstationAnnotations(v interface{}, d *schema.Resource
462487 return v
463488}
464489
490+ func flattenWorkstationsWorkstationEnv (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
491+ return v
492+ }
493+
465494func flattenWorkstationsWorkstationCreateTime (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
466495 return v
467496}
@@ -499,3 +528,14 @@ func expandWorkstationsWorkstationAnnotations(v interface{}, d tpgresource.Terra
499528 }
500529 return m , nil
501530}
531+
532+ func expandWorkstationsWorkstationEnv (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
533+ if v == nil {
534+ return map [string ]string {}, nil
535+ }
536+ m := make (map [string ]string )
537+ for k , val := range v .(map [string ]interface {}) {
538+ m [k ] = val .(string )
539+ }
540+ return m , nil
541+ }
0 commit comments