Skip to content

Commit fcd0f5f

Browse files
feat: add 'hidden' field to 'coder_app' provider
1 parent 5f660a0 commit fcd0f5f

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

provider/app.go

+7
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ func appResource() *schema.Resource {
187187
ForceNew: true,
188188
Optional: true,
189189
},
190+
"hidden": {
191+
Type: schema.TypeBool,
192+
Description: "Determines if the app is visible in the UI.",
193+
Default: false,
194+
ForceNew: true,
195+
Optional: true,
196+
},
190197
},
191198
}
192199
}

provider/app_test.go

+73
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func TestApp(t *testing.T) {
4545
threshold = 6
4646
}
4747
order = 4
48+
hidden = false
4849
}
4950
`,
5051
Check: func(state *terraform.State) error {
@@ -66,6 +67,7 @@ func TestApp(t *testing.T) {
6667
"healthcheck.0.interval",
6768
"healthcheck.0.threshold",
6869
"order",
70+
"hidden",
6971
} {
7072
value := resource.Primary.Attributes[key]
7173
t.Logf("%q = %q", key, value)
@@ -246,4 +248,75 @@ func TestApp(t *testing.T) {
246248
})
247249
}
248250
})
251+
252+
t.Run("Hidden", func(t *testing.T) {
253+
t.Parallel()
254+
255+
cases := []struct {
256+
name string
257+
config string
258+
hidden bool
259+
}{{
260+
name: "Is Hidden",
261+
config: `
262+
provider "coder" {}
263+
resource "coder_agent" "dev" {
264+
os = "linux"
265+
arch = "amd64"
266+
}
267+
resource "coder_app" "test" {
268+
agent_id = coder_agent.dev.id
269+
slug = "test"
270+
display_name = "Testing"
271+
url = "https://google.com"
272+
external = true
273+
hidden = true
274+
}
275+
`,
276+
hidden: true,
277+
}, {
278+
name: "Is Not Hidden",
279+
config: `
280+
provider "coder" {}
281+
resource "coder_agent" "dev" {
282+
os = "linux"
283+
arch = "amd64"
284+
}
285+
resource "coder_app" "test" {
286+
agent_id = coder_agent.dev.id
287+
slug = "test"
288+
display_name = "Testing"
289+
url = "https://google.com"
290+
external = true
291+
hidden = false
292+
}
293+
`,
294+
hidden: false,
295+
}}
296+
for _, tc := range cases {
297+
tc := tc
298+
t.Run(tc.name, func(t *testing.T) {
299+
t.Parallel()
300+
resource.Test(t, resource.TestCase{
301+
Providers: map[string]*schema.Provider{
302+
"coder": provider.New(),
303+
},
304+
IsUnitTest: true,
305+
Steps: []resource.TestStep{{
306+
Config: tc.config,
307+
Check: func(state *terraform.State) error {
308+
require.Len(t, state.Modules, 1)
309+
require.Len(t, state.Modules[0].Resources, 2)
310+
resource := state.Modules[0].Resources["coder_app.test"]
311+
require.NotNil(t, resource)
312+
require.Equal(t, strconv.FormatBool(tc.hidden), resource.Primary.Attributes["hidden"])
313+
return nil
314+
},
315+
ExpectError: nil,
316+
}},
317+
})
318+
})
319+
}
320+
})
321+
249322
}

0 commit comments

Comments
 (0)