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}
107108rd .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+
109123return nil
110124},
111125Schema : map [string ]* schema.Schema {
@@ -114,6 +128,11 @@ func New() *schema.Provider {
114128Computed : true ,
115129Description : "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" : {
118137Type : schema .TypeInt ,
119138Computed : true ,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ func TestWorkspace(t *testing.T) {
3131Steps : []resource.TestStep {{
3232Config : `
3333provider "coder" {
34- url = "https://example.com"
34+ url = "https://example.com:8080 "
3535}
3636data "coder_workspace" "me" {
3737}` ,
@@ -45,6 +45,7 @@ func TestWorkspace(t *testing.T) {
4545value := attribs ["transition" ]
4646require .NotNil (t , value )
4747t .Log (value )
48+ require .Equal (t , "8080" , attribs ["access_port" ])
4849require .Equal (t , "owner123" , attribs ["owner" ])
4950require .Equal (t , "owner123@example.com" , attribs ["owner_email" ])
5051return nil
You can’t perform that action at this time.
0 commit comments