File tree 3 files changed +23
-2
lines changed
3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ resource "kubernetes_pod" "dev" {
30
30
- ` id ` (String) UUID of the workspace.
31
31
- ` name ` (String) Name of the workspace.
32
32
- ` owner ` (String) Username of the workspace owner.
33
+ - ` owner_email ` (String) Email address of the workspace owner.
33
34
- ` owner_id ` (String) UUID of the workspace owner.
34
35
- ` start_count ` (Number) A computed count based on "transition" state. If "start", count will equal 1.
35
36
- ` transition ` (String) Either "start" or "stop". Use this to start/stop resources with "count".
Original file line number Diff line number Diff line change @@ -69,31 +69,40 @@ func New() *schema.Provider {
69
69
count = 1
70
70
}
71
71
_ = rd .Set ("start_count" , count )
72
+
72
73
owner := os .Getenv ("CODER_WORKSPACE_OWNER" )
73
74
if owner == "" {
74
75
owner = "default"
75
76
}
76
77
_ = rd .Set ("owner" , owner )
78
+
79
+ ownerEmail := os .Getenv ("CODER_WORKSPACE_OWNER_EMAIL" )
80
+ _ = rd .Set ("owner_email" , ownerEmail )
81
+
77
82
ownerID := os .Getenv ("CODER_WORKSPACE_OWNER_ID" )
78
83
if ownerID == "" {
79
84
ownerID = uuid .Nil .String ()
80
85
}
81
86
_ = rd .Set ("owner_id" , ownerID )
87
+
82
88
name := os .Getenv ("CODER_WORKSPACE_NAME" )
83
89
if name == "" {
84
90
name = "default"
85
91
}
86
92
rd .Set ("name" , name )
93
+
87
94
id := os .Getenv ("CODER_WORKSPACE_ID" )
88
95
if id == "" {
89
96
id = uuid .NewString ()
90
97
}
91
98
rd .SetId (id )
99
+
92
100
config , valid := i .(config )
93
101
if ! valid {
94
102
return diag .Errorf ("config was unexpected type %q" , reflect .TypeOf (i ).String ())
95
103
}
96
104
rd .Set ("access_url" , config .URL .String ())
105
+
97
106
return nil
98
107
},
99
108
Schema : map [string ]* schema.Schema {
@@ -117,6 +126,11 @@ func New() *schema.Provider {
117
126
Computed : true ,
118
127
Description : "Username of the workspace owner." ,
119
128
},
129
+ "owner_email" : {
130
+ Type : schema .TypeString ,
131
+ Computed : true ,
132
+ Description : "Email address of the workspace owner." ,
133
+ },
120
134
"owner_id" : {
121
135
Type : schema .TypeString ,
122
136
Computed : true ,
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ func TestProvider(t *testing.T) {
19
19
}
20
20
21
21
func TestWorkspace (t * testing.T ) {
22
- t .Parallel ()
22
+ t .Setenv ("CODER_WORKSPACE_OWNER" , "owner123" )
23
+ t .
Setenv (
"CODER_WORKSPACE_OWNER_EMAIL" ,
"[email protected] " )
24
+
23
25
resource .Test (t , resource.TestCase {
24
26
Providers : map [string ]* schema.Provider {
25
27
"coder" : provider .New (),
@@ -37,9 +39,13 @@ func TestWorkspace(t *testing.T) {
37
39
require .Len (t , state .Modules [0 ].Resources , 1 )
38
40
resource := state .Modules [0 ].Resources ["data.coder_workspace.me" ]
39
41
require .NotNil (t , resource )
40
- value := resource .Primary .Attributes ["transition" ]
42
+
43
+ attribs := resource .Primary .Attributes
44
+ value := attribs ["transition" ]
41
45
require .NotNil (t , value )
42
46
t .Log (value )
47
+ require .Equal (t , "owner123" , attribs ["owner" ])
48
+ require .
Equal (
t ,
"[email protected] " ,
attribs [
"owner_email" ])
43
49
return nil
44
50
},
45
51
}},
You can’t perform that action at this time.
0 commit comments