Skip to content

Commit c7ab830

Browse files
committed
WIP
1 parent bded329 commit c7ab830

File tree

7 files changed

+180
-41
lines changed

7 files changed

+180
-41
lines changed

provisioner/terraform/resources.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,10 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string, rawParameterNa
493493
}
494494

495495
if !param.Validation[0].MaxDisabled {
496-
protoParam.ValidationMax = ptrInt32(param.Validation[0].Max)
496+
protoParam.ValidationMax = PtrInt32(param.Validation[0].Max)
497497
}
498498
if !param.Validation[0].MinDisabled {
499-
protoParam.ValidationMin = ptrInt32(param.Validation[0].Min)
499+
protoParam.ValidationMin = PtrInt32(param.Validation[0].Min)
500500
}
501501
protoParam.ValidationMonotonic = param.Validation[0].Monotonic
502502
}
@@ -540,7 +540,7 @@ func ConvertState(modules []*tfjson.StateModule, rawGraph string, rawParameterNa
540540
}, nil
541541
}
542542

543-
func ptrInt32(number int) *int32 {
543+
func PtrInt32(number int) *int32 {
544544
n := int32(number)
545545
return &n
546546
}

provisioner/terraform/resources_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@ func TestConvertResources(t *testing.T) {
323323
Type: "string",
324324
Description: "blah blah",
325325
DefaultValue: "ok",
326+
}, {
327+
Name: "number_example_min_max",
328+
Type: "number",
329+
DefaultValue: "4",
330+
ValidationMin: terraform.PtrInt32(3),
331+
ValidationMax: terraform.PtrInt32(6),
326332
}},
327333
},
328334
"git-auth-providers": {

provisioner/terraform/testdata/rich-parameters/rich-parameters.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder = {
44
source = "coder/coder"
5-
version = "0.6.20"
5+
version = "0.7.0"
66
}
77
}
88
}
@@ -27,6 +27,17 @@ data "coder_parameter" "example" {
2727
}
2828
}
2929

30+
// Plugin revision v0.7.0 requires defining "min" or "max" rules together.
31+
data "coder_parameter" "number_example_min_max" {
32+
name = "number_example_min_max"
33+
type = "number"
34+
default = 4
35+
validation {
36+
min = 3
37+
max = 6
38+
}
39+
}
40+
3041
resource "coder_agent" "dev" {
3142
os = "windows"
3243
arch = "arm64"

provisioner/terraform/testdata/rich-parameters/rich-parameters.tfplan.dot

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provisioner/terraform/testdata/rich-parameters/rich-parameters.tfplan.json

Lines changed: 80 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provisioner/terraform/testdata/rich-parameters/rich-parameters.tfstate.dot

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)