Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: ephemeral parameters must be optional#141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mtojek merged 1 commit intocoder:mainfrommtojek:6828-conflict-required-ephemeral
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes fromall 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
1 change: 1 addition & 0 deletionsexamples/resources/coder_parameter/resource.tf
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,6 +75,7 @@ data "coder_parameter" "fairy_tale" {
name = "Fairy Tale"
type = "string"
mutable = true
default = "Hansel and Gretel"
ephemeral = true
}

Expand Down
4 changes: 4 additions & 0 deletionsprovider/parameter.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -134,6 +134,10 @@ func parameterDataSource() *schema.Resource {
return diag.Errorf("parameter can't be immutable and ephemeral")
}

if !parameter.Optional && parameter.Ephemeral {
return diag.Errorf("ephemeral parameter requires the default property")
Copy link
Member

Choose a reason for hiding this comment

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

Sanity check: do parameters have an optional field or is it inferred by setting default, and is that the only way to do it? (I always stop to ask when I see the check and message say something different.)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

do parameters have an optional field

No.

is it inferred by setting default

Yes 👍

is that the only way to do it

Yes 👍

}

if len(parameter.Validation) == 1 {
validation := &parameter.Validation[0]
err = validation.Valid(parameter.Type, value)
Expand Down
14 changes: 14 additions & 0 deletionsprovider/parameter_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,7 @@ func TestParameter(t *testing.T) {
EOT
mutable = true
icon = "/icon/region.svg"
default = "us-east1-a"
option {
name = "US Central"
value = "us-central1-a"
Expand DownExpand Up@@ -65,6 +66,7 @@ func TestParameter(t *testing.T) {
"option.1.icon": "/icon/east.svg",
"option.1.description": "Select for east!",
"order": "5",
"default": "us-east1-a",
"ephemeral": "true",
} {
require.Equal(t, value, attrs[key])
Expand DownExpand Up@@ -558,11 +560,23 @@ data "coder_parameter" "region" {
data "coder_parameter" "region" {
name = "Region"
type = "string"
default = "abc"
mutable = false
ephemeral = true
}
`,
ExpectError: regexp.MustCompile("parameter can't be immutable and ephemeral"),
}, {
Name: "RequiredEphemeralError",
Config: `
data "coder_parameter" "region" {
name = "Region"
type = "string"
mutable = true
ephemeral = true
}
`,
ExpectError: regexp.MustCompile("ephemeral parameter requires the default property"),
}} {
tc := tc
t.Run(tc.Name, func(t *testing.T) {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp