Skip to content

Commit 6ca152d

Browse files
committed
add open_in option to coder_app
1 parent c9dbd6f commit 6ca152d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

provider/app.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,28 @@ func appResource() *schema.Resource {
223223
ForceNew: true,
224224
Optional: true,
225225
},
226+
"open_in": {
227+
Type: schema.TypeString,
228+
Description: "Determines where the app will be opened. Valid values are `\"tab\"`, `\"window\"`, and `\"slim-window\" (default)`. " +
229+
"`\"tab\"` opens in a new tab in the same browser window. `\"window\"` opens a fresh browser window with navigation options. " +
230+
"`\"slim-window\"` opens a fresh browser window with slim navigation options.",
231+
ForceNew: true,
232+
Optional: true,
233+
Default: "slim-window",
234+
ValidateDiagFunc: func(val interface{}, c cty.Path) diag.Diagnostics {
235+
valStr, ok := val.(string)
236+
if !ok {
237+
return diag.Errorf("expected string, got %T", val)
238+
}
239+
240+
switch valStr {
241+
case "tab", "window", "slim-window":
242+
return nil
243+
}
244+
245+
return diag.Errorf(`invalid "coder_app" open_in value, must be one of "tab", "window", "slim-window": %q`, valStr)
246+
},
247+
},
226248
},
227249
}
228250
}

provider/app_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func TestApp(t *testing.T) {
4242
}
4343
order = 4
4444
hidden = false
45+
open_in = "slim-window"
4546
}
4647
`,
4748
Check: func(state *terraform.State) error {
@@ -64,6 +65,7 @@ func TestApp(t *testing.T) {
6465
"healthcheck.0.threshold",
6566
"order",
6667
"hidden",
68+
"open_in",
6769
} {
6870
value := resource.Primary.Attributes[key]
6971
t.Logf("%q = %q", key, value)
@@ -98,6 +100,7 @@ func TestApp(t *testing.T) {
98100
display_name = "Testing"
99101
url = "https://google.com"
100102
external = true
103+
open_in = "slim-window"
101104
}
102105
`,
103106
external: true,
@@ -116,6 +119,7 @@ func TestApp(t *testing.T) {
116119
url = "https://google.com"
117120
external = true
118121
subdomain = true
122+
open_in = "slim-window"
119123
}
120124
`,
121125
expectError: regexp.MustCompile("conflicts with subdomain"),
@@ -209,6 +213,7 @@ func TestApp(t *testing.T) {
209213
interval = 5
210214
threshold = 6
211215
}
216+
open_in = "slim-window"
212217
}
213218
`, sharingLine)
214219

@@ -248,6 +253,7 @@ func TestApp(t *testing.T) {
248253
name string
249254
config string
250255
hidden bool
256+
openIn string
251257
}{{
252258
name: "Is Hidden",
253259
config: `
@@ -263,9 +269,11 @@ func TestApp(t *testing.T) {
263269
url = "https://google.com"
264270
external = true
265271
hidden = true
272+
open_in = "slim-window"
266273
}
267274
`,
268275
hidden: true,
276+
openIn: "slim-window",
269277
}, {
270278
name: "Is Not Hidden",
271279
config: `
@@ -281,9 +289,11 @@ func TestApp(t *testing.T) {
281289
url = "https://google.com"
282290
external = true
283291
hidden = false
292+
open_in = "window"
284293
}
285294
`,
286295
hidden: false,
296+
openIn: "window",
287297
}}
288298
for _, tc := range cases {
289299
tc := tc
@@ -300,6 +310,7 @@ func TestApp(t *testing.T) {
300310
resource := state.Modules[0].Resources["coder_app.test"]
301311
require.NotNil(t, resource)
302312
require.Equal(t, strconv.FormatBool(tc.hidden), resource.Primary.Attributes["hidden"])
313+
require.Equal(t, tc.openIn, resource.Primary.Attributes["open_in"])
303314
return nil
304315
},
305316
ExpectError: nil,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy