Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Disallow passing input that is not apart of the optionset #29

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Emyrk opened this issue Mar 10, 2025 · 2 comments
Closed

Disallow passing input that is not apart of the optionset #29

Emyrk opened this issue Mar 10, 2025 · 2 comments
Assignees
Labels
beta candidate for a beta release

Comments

@Emyrk
Copy link
Member

Emyrk commented Mar 10, 2025

If options are provided, these are the only valid options that can inputted.

If the input value is not apart of the optionset, throw an error.

Try to mimic behavior of terraform apply

Default value is invalid, or passed in via user: preview -v region=asia

data "coder_parameter" "region" {
  name        = "region"
  description = "Which region would you like to deploy to?"
  type        = "string"
  default     = "aus"
  order       = 1

  option {
    name  = "Europe"
    value = "eu"
  }
  option {
    name  = "United States"
    value = "us"
  }
}
╷
│ Error: default value "aus" must be defined as one of options
│ 
│   with data.coder_parameter.region2,
│   on main.tf line 45, in data "coder_parameter" "region2":
│   45: data "coder_parameter" "region2" {
│ 
╵

Add the diagnostic in the parameter function:

func ParameterFromBlock(block *terraform.Block) (*types.Parameter, hcl.Diagnostics) {

What about this???

data "coder_parameter" "region" {
  name        = "region"
  description = "Which region would you like to deploy to?"
  type        = "string"
  default     = "aus"
  order       = 1

  option {
    name  = "Default"
    value = data.coder_parameter.region.default
  }
}
@Emyrk
Copy link
Member Author

Emyrk commented Mar 20, 2025

Also do this for multi-select options

@Kira-Pilot Kira-Pilot added the beta candidate for a beta release label Apr 4, 2025
@Emyrk
Copy link
Member Author

Emyrk commented May 9, 2025

Closed by coder/terraform-provider-coder#381

@Emyrk Emyrk closed this as completed May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta candidate for a beta release
Projects
None yet
Development

No branches or pull requests

3 participants