File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ func workspaceDataSource() *schema.Resource {
51
51
}
52
52
rd .Set ("name" , name )
53
53
54
+ sessionToken := os .Getenv ("CODER_SESSION_TOKEN" )
55
+ _ = rd .Set ("coder_session_token" , sessionToken )
56
+
54
57
id := os .Getenv ("CODER_WORKSPACE_ID" )
55
58
if id == "" {
56
59
id = uuid .NewString ()
@@ -131,6 +134,11 @@ func workspaceDataSource() *schema.Resource {
131
134
Computed : true ,
132
135
Description : "Name of the workspace." ,
133
136
},
137
+ "coder_session_token" : {
138
+ Type : schema .TypeString ,
139
+ Computed : true ,
140
+ Description : "Session token for interfacing with a Coder deployment. It is regenerated everytime a workspace is started." ,
141
+ },
134
142
},
135
143
}
136
144
}
Original file line number Diff line number Diff line change @@ -3,16 +3,18 @@ package provider_test
3
3
import (
4
4
"testing"
5
5
6
- "github.com/coder/terraform-provider-coder/provider"
7
6
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
8
7
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
9
8
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
10
9
"github.com/stretchr/testify/require"
10
+
11
+ "github.com/coder/terraform-provider-coder/provider"
11
12
)
12
13
13
14
func TestWorkspace (t * testing.T ) {
14
15
t .Setenv ("CODER_WORKSPACE_OWNER" , "owner123" )
15
16
t .Setenv ("CODER_WORKSPACE_OWNER_EMAIL" , "owner123@example.com" )
17
+ t .Setenv ("CODER_SESSION_TOKEN" , "abc123" )
16
18
17
19
resource .Test (t , resource.TestCase {
18
20
Providers : map [string ]* schema.Provider {
@@ -39,6 +41,7 @@ func TestWorkspace(t *testing.T) {
39
41
require .Equal (t , "8080" , attribs ["access_port" ])
40
42
require .Equal (t , "owner123" , attribs ["owner" ])
41
43
require .Equal (t , "owner123@example.com" , attribs ["owner_email" ])
44
+ require .Equal (t , "abc123" , attribs ["coder_session_token" ])
42
45
return nil
43
46
},
44
47
}},
You can’t perform that action at this time.
0 commit comments