Skip to content

Commit c8bc19c

Browse files
committed
update connections
1 parent 2e5caa6 commit c8bc19c

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

testdata/connections/main.tf

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,35 @@ locals {
4141

4242
available_words = setsubtract(toset(local.word_bank), toset(local.used_words))
4343

44+
4445
colors = toset(["yellow", "green", "blue", "purple"])
4546

4647
solved = length([for color in local.colors : module.checker[color].solved if module.checker[color].solved]) == 4
4748
}
4849

4950

51+
locals {
52+
unpadded_items = tolist(local.available_words)
53+
target_width = 3
54+
remainder = length(local.unpadded_items) % local.target_width
55+
padding_needed = local.remainder == 0 ? 0 : local.target_width - local.remainder
56+
items = concat(local.unpadded_items, slice(["", "", ""], 0, local.padding_needed))
57+
58+
# Split into rows of 3 items each
59+
rows = [
60+
for i in range(0, length(local.items), local.target_width) : slice(local.items, i, i + local.target_width)
61+
]
62+
63+
# Generate Markdown rows
64+
markdown_rows = [
65+
for row in local.rows : "| ${join(" | ", concat(row, slice(["", "", ""], 0, local.target_width - length(row))))} |"
66+
]
67+
markdown = join("\n", concat(
68+
["| Item 1 | Item 2 | Item 3 |", "|--------|--------|--------|"],
69+
local.markdown_rows
70+
))
71+
}
72+
5073

5174
module "checker" {
5275
for_each = local.colors
@@ -57,8 +80,20 @@ module "checker" {
5780

5881
data "coder_parameter" display {
5982
name = "display"
60-
display_name = local.solved ? "Congrats, you won! You may now hit the switch!" : join(", ", local.available_words)
61-
description = local.solved ? "Hitting the switch enables workspace creation." : "Remaining words are above, you cannot use this switch until you solve the puzzle!"
83+
display_name = local.solved ? "Congrats, you won! You may now hit the switch!" : <<EOM
84+
Remaining words are below, you cannot use this switch until you solve the puzzle!
85+
86+
EOM
87+
88+
description = local.solved ? "Hitting the switch enables workspace creation." : <<EOM
89+
90+
| | | |
91+
|--|--|--|
92+
93+
94+
${local.markdown}
95+
96+
EOM
6297
type = "bool"
6398
form_type = "switch"
6499
default = local.solved ? false : true

0 commit comments

Comments
 (0)