1+ data "coder_parameter" "team" {
2+ name = " Team"
3+ description = " Which team are you on?"
4+ type = " string"
5+ default = " fullstack"
6+ order = 10
7+
8+ dynamic "option" {
9+ for_each = local. teams
10+ content {
11+ name = option. value . display_name
12+ value = option. key
13+ description = option. value . description
14+ icon = option. value . icon
15+ }
16+ }
17+
18+ validation {
19+ regex = " ^frontend|backend|fullstack$"
20+ error = " You must select either frontend, backend, or fullstack."
21+ }
22+ }
23+
24+ data "coder_parameter" "browser" {
25+ name = " browser"
26+ description = " Which browser do you prefer?"
27+ type = " string"
28+ default = " chromium"
29+ order = 12
30+ count = (
31+ data. coder_parameter . team . value == " frontend" ||
32+ data. coder_parameter . team . value == " fullstack" ? 1 : 0
33+ )
34+
35+ option {
36+ name = " Chrome"
37+ value = " chrome"
38+ }
39+
40+ option {
41+ name = " Firefox"
42+ value = " firefox"
43+ }
44+
45+ option {
46+ name = " Safari"
47+ value = " safari"
48+ }
49+
50+ option {
51+ name = " Edge"
52+ value = " edge"
53+ }
54+
55+ option {
56+ name = " Chromium"
57+ value = " chromium"
58+ }
59+ }
60+
61+
62+ data "coder_parameter" "cpu" {
63+ name = " cpu"
64+ display_name = " CPU"
65+ description = " The number of CPU cores"
66+ type = " number"
67+ default = " 2"
68+ icon = " /icon/memory.svg"
69+ mutable = true
70+ order = 20
71+
72+ validation {
73+ min = 1
74+ // Confidential instances are more expensive, or some justification like
75+ // that
76+ // TODO: This breaks when the user is an admin
77+ max = local. secutity_level == " high" ? 4 : 8
78+ error = " CPU range must be between {min} and {max}."
79+ }
80+ }
81+
82+ data "coder_workspace_tags" "test" {
83+ tags = {
84+ " hash" : trimprefix (data. docker_registry_image . coder . sha256_digest , " sha256:" )
85+ }
86+ }
87+
88+ // Advanced admin parameter
89+ data "coder_parameter" "image_hash" {
90+ count = local. isAdmin ? 1 : 0
91+ name = " Image Hash"
92+ description = " Override the hash of the image to use. Only available to admins."
93+ // Value can get stale
94+ default = trimprefix (data. docker_registry_image . coder . sha256_digest , " sha256:" )
95+ order = 100
96+
97+ validation {
98+ regex = " ^[a-f0-9A-F]{64}$"
99+ error = " The image hash must be a 64-character hexadecimal string."
100+ }
101+ }
102+
103+ data "docker_registry_image" "coder" {
104+ name = " ghcr.io/coder/coder:latest"
105+ }
106+
107+ data "coder_parameter" "region" {
108+ name = " Region"
109+ display_name = " Region"
110+ description = " What region are you in?"
111+ default = local. default_region
112+ icon = " /icon/memory.svg"
113+ mutable = false
114+ order = 1
115+
116+ dynamic "option" {
117+ for_each = local. regions
118+ content {
119+ name = option. value . name
120+ value = option. value . value
121+ icon = option. value . icon
122+ }
123+ }
124+ }
0 commit comments