Skip to content

Commit

Permalink
refactor: Eliminate variable field that's no longer required.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The "type" field for Waypoint variable options is no longer required by the API. It is "output only" and need not be set by clients. Therefore, it can be removed from the input config file for variable options.
  • Loading branch information
paladin-devops committed Oct 16, 2024
1 parent 15c65ee commit ec06f38
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .changelog/174.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:breaking-change
waypoint: Remove type field from variable options config file.
```
4 changes: 0 additions & 4 deletions internal/commands/waypoint/internal/variable_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ func ParseVariableOptionsFile(path string) ([]*models.HashicorpCloudWaypointTFMo
// # Example contents of a vars.hcl file
//
// variable_option "string_variable" {
// type = "string"
// options = [
// "a string value",
// ]
// user_editable = false
// }
//
// variable_option "misc_variable" {
// type = "string"
// options = [
// "another string value",
// ]
Expand All @@ -53,7 +51,6 @@ func parseVariableOptions(filename string, input []byte) ([]*models.HashicorpClo
for _, v := range hc.VariableOptions {
variables = append(variables, &models.HashicorpCloudWaypointTFModuleVariable{
Name: v.Name,
VariableType: v.Type,
Options: v.Options,
UserEditable: v.UserEditable,
})
Expand All @@ -64,7 +61,6 @@ func parseVariableOptions(filename string, input []byte) ([]*models.HashicorpClo

type hclVariableOption struct {
Name string `hcl:",label"`
Type string `hcl:"type"`
Options []string `hcl:"options"`
UserEditable bool `hcl:"user_editable,optional"`
}
Expand Down
13 changes: 1 addition & 12 deletions internal/commands/waypoint/internal/variable_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func Test_VariableOptionsFileParse(t *testing.T) {

hcl := `
variable_option "string_variable" {
type = "string"
options = [
"a string value",
]
Expand All @@ -30,7 +29,6 @@ func Test_VariableOptionsFileParse(t *testing.T) {
r.NoError(err)
r.Equal(1, len(variableInputs))
r.Equal("string_variable", variableInputs[0].Name)
r.Equal("string", variableInputs[0].VariableType)
r.Equal(false, variableInputs[0].UserEditable)
})

Expand All @@ -41,7 +39,6 @@ func Test_VariableOptionsFileParse(t *testing.T) {

hcl := `
variable_option "string_variable" {
type = "string"
options = [
"a string value",
"another string value",
Expand All @@ -65,7 +62,6 @@ func Test_VariableOptionsFileParse(t *testing.T) {

hcl := `
variable_option "string_variable" {
type = "string"
options = [
"a string value",
"another",
Expand All @@ -74,7 +70,6 @@ variable_option "string_variable" {
}
variable_option "misc_variable" {
type = "int"
options = [
8,
2,
Expand All @@ -92,7 +87,6 @@ variable_option "misc_variable" {

r.Equal("misc_variable", variableInputs[1].Name)
r.Equal(2, len(variableInputs[1].Options))
r.Equal("int", variableInputs[1].VariableType)
r.Equal(false, variableInputs[1].UserEditable)
})

Expand All @@ -102,12 +96,7 @@ variable_option "misc_variable" {
r := require.New(t)

hcl := `
variable_option "" {
options = [
8,
2,
]
}
variable_option "" {}
`

_, err := parseVariableOptions("blah.hcl", []byte(hcl))
Expand Down

0 comments on commit ec06f38

Please sign in to comment.