Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions provider/parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,9 @@ func TestParameterValidationEnforcement(t *testing.T) {
// - [NumIns/DefInv] So the default can be invalid if an input value is valid.
// The value is therefore not really optional, but it is marked as such.
// - [NumInsNotOptsVal | NumsInsNotOpts] values do not need to be in the option set?
// - [NumInsNotNum] number params do not require the value to be a number
// - [LStrInsNotList] list(string) do not require the value to be a list(string)
// - Same with [MulInsNotListOpts]
table, err := os.ReadFile("testdata/parameter_table.md")
require.NoError(t, err)

Expand Down
9 changes: 9 additions & 0 deletions provider/testdata/parameter_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
|----------------------|---------------|-----------|---------|-------------------|------------|----|--------|----------|--------------|
| | Empty Vals | | | | | | | | |
| Empty | string,number | | | | | | "" | false | |
| EmptyDupeOps | string,number | | | 1,1,1 | | | | | unique |
| EmptyList | list(string) | | | | | | "" | false | |
| EmptyListDupeOpts | list(string) | | | ["a"],["a"] | | | | | unique |
| EmptyMulti | tag-select | | | | | | "" | false | |
| EmptyOpts | string,number | | | 1,2,3 | | | "" | false | |
| EmptyRegex | string | | | | world | | | | regex error |
Expand All @@ -18,6 +20,8 @@
| NumDefOpts | number | | 5 | 1,3,5,7 | 2-6 | | 5 | true | |
| NumDefNotOpts | number | | 5 | 1,3,7,9 | 2-6 | | | | valid option |
| NumDefInvOpt | number | | 5 | 1,3,5,7 | 6-10 | | | | 6 < 5 < 10 |
| NumDefNotNum | number | | a | | | | | | a number |
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you can pass in "a" for a "number" param... interesting.

You can see it for yourself:

data "coder_parameter" "region" {
  name        = "region"
  type        = "number"
  order       = 1
}
$ CODER_PARAMETER_c697d2981bf416569a16cfbcdec1542b5398f3cc77d2b905819aa99c46ecf6f6=nan terraform apply && terraform show 
# data.coder_parameter.region:
data "coder_parameter" "region" {
    description = "Which region would you like to deploy to?"
    ephemeral   = false
    form_type   = "input"
    id          = "2aec6abf-883a-4618-98c6-6e262e2bfd9b"
    mutable     = false
    name        = "region"
    optional    = false
    order       = 1
    styling     = jsonencode({})
    type        = "number"
    value       = "nan"
}

| NumDefOptsNotNum | number | | 1 | 1,a,2 | | | | | a number |
| | | | | | | | | | |
| StrDef | string | | hello | | | | hello | true | |
| StrDefInv | string | | hello | | world | | | | regex error |
Expand All @@ -36,6 +40,8 @@
| | | | | | | | | | |
| | Input Vals | | | | | | | | |
| NumIns | number | 3 | | | | | 3 | false | |
| NumInsNotNum | number | a | | | | | a | false | |
| NumInsNotNumInv | number | a | | | 1-3 | | | | 1 < a < 3 |
| NumInsDef | number | 3 | 5 | | | | 3 | true | |
| NumIns/DefInv | number | 3 | 5 | | 1-3 | | 3 | true | |
| NumIns=DefInv | number | 5 | 5 | | 1-3 | | | | 1 < 5 < 3 |
Expand All @@ -46,6 +52,7 @@
| NumInsNotOpts/NoDef | number | 3 | | 1,2,4,5 | | | 3 | false | |
| | | | | | | | | | |
| StrIns | string | c | | | | | c | false | |
| StrInsDupeOpts | string | c | | a,b,c,c | | | | | unique |
| StrInsDef | string | c | e | | | | c | true | |
| StrIns/DefInv | string | c | e | | [a-c] | | c | true | |
| StrIns=DefInv | string | e | e | | [a-c] | | | | regex error |
Expand All @@ -58,13 +65,15 @@
| | | | | | | | | | |
| | list(string) | | | | | | | | |
| LStrIns | list(string) | ["c"] | | | | | ["c"] | false | |
| LStrInsNotList | list(string) | c | | | | | c | false | |
| LStrInsDef | list(string) | ["c"] | ["e"] | | | | ["c"] | true | |
| LStrIns/DefInv | list(string) | ["c"] | ["e"] | | [a-c] | | | | regex cannot |
| LStrInsOpts | list(string) | ["c"] | ["e"] | ["c"],["d"],["e"] | | | ["c"] | true | |
| LStrInsNotOpts | list(string) | ["c"] | ["e"] | ["d"],["e"] | | | ["c"] | true | |
| LStrInsNotOpts/NoDef | list(string) | ["c"] | | ["d"],["e"] | | | ["c"] | false | |
| | | | | | | | | | |
| MulInsOpts | multi-select | ["c"] | ["e"] | c,d,e | | | ["c"] | true | |
| MulInsNotListOpts | multi-select | c | ["e"] | c,d,e | | | c | true | |
| MulInsNotOpts | multi-select | ["c"] | ["e"] | d,e | | | ["c"] | true | |
| MulInsNotOpts/NoDef | multi-select | ["c"] | | d,e | | | ["c"] | false | |
| MulInsInvOpts | multi-select | ["c"] | ["e"] | c,d,e | [a-c] | | | | regex cannot |
Loading