File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ resource "kubernetes_pod" "dev" {
2626
2727### Read-Only
2828
29+ - ` access_port ` (Number) The access port of the Coder deployment provisioning this workspace.
2930- ` access_url ` (String) The access URL of the Coder deployment provisioning this workspace.
3031- ` id ` (String) UUID of the workspace.
3132- ` name ` (String) Name of the workspace.
Original file line number Diff line number Diff line change 88 "os"
99 "reflect"
1010 "runtime"
11+ "strconv"
1112 "strings"
1213
1314 "github.com/google/uuid"
@@ -106,6 +107,19 @@ func New() *schema.Provider {
106107 }
107108 rd .Set ("access_url" , config .URL .String ())
108109
110+ rawPort := config .URL .Port ()
111+ if rawPort == "" {
112+ rawPort = "80"
113+ if config .URL .Scheme == "https" {
114+ rawPort = "443"
115+ }
116+ }
117+ port , err := strconv .Atoi (rawPort )
118+ if err != nil {
119+ return diag .Errorf ("couldn't parse port %q" , port )
120+ }
121+ rd .Set ("access_port" , port )
122+
109123 return nil
110124 },
111125 Schema : map [string ]* schema.Schema {
@@ -114,6 +128,11 @@ func New() *schema.Provider {
114128 Computed : true ,
115129 Description : "The access URL of the Coder deployment provisioning this workspace." ,
116130 },
131+ "access_port" : {
132+ Type : schema .TypeInt ,
133+ Computed : true ,
134+ Description : "The access port of the Coder deployment provisioning this workspace." ,
135+ },
117136 "start_count" : {
118137 Type : schema .TypeInt ,
119138 Computed : true ,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ func TestWorkspace(t *testing.T) {
3131 Steps : []resource.TestStep {{
3232 Config : `
3333 provider "coder" {
34- url = "https://example.com"
34+ url = "https://example.com:8080 "
3535 }
3636 data "coder_workspace" "me" {
3737 }` ,
@@ -45,6 +45,7 @@ func TestWorkspace(t *testing.T) {
4545 value := attribs ["transition" ]
4646 require .NotNil (t , value )
4747 t .Log (value )
48+ require .Equal (t , "8080" , attribs ["access_port" ])
4849 require .Equal (t , "owner123" , attribs ["owner" ])
4950 require .
Equal (
t ,
"[email protected] " ,
attribs [
"owner_email" ])
5051 return nil
You can’t perform that action at this time.
0 commit comments