-
Notifications
You must be signed in to change notification settings - Fork 13
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
Feat: Adding JSON Format to configuration variables #196
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just one question, making sure there's no lingering bug here
if variable.Schema.Format == client.HCL { | ||
d.Set("format", string(client.HCL)) | ||
if variable.Schema.Format != "" { | ||
d.Set("format", variable.Schema.Format) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this whole logic be duplicated to environment resource's configuration variables as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RLRabinowitz looks like it's already there...
terraform-provider-env0/env0/resource_environment.go
Lines 579 to 583 in 2ad99bb
configurationSchema := client.ConfigurationVariableSchema{ | |
Type: "string", | |
Format: client.Format(variable["schema_format"].(string)), | |
Enum: nil, | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done! 🚀
func ValidateConfigurationPropertySchema(val interface{}, key string) (warns []string, errs []error) { | ||
value := val.(string) | ||
if value != string(client.HCL) && value != string(client.Text) && value != string(client.JSON) { | ||
errs = append(errs, fmt.Errorf("%q can be either \"HCL\", \"JSON\" or empty, got: %q", key, value)) | ||
} | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
var mockWithFormat = ConfigurationVariable{} | ||
copier.Copy(&mockWithFormat, &mockConfigurationVariable) | ||
mockWithFormat.Schema.Format = schemaFormat | ||
requestWithFormat := GetExpectedRequest(mockWithFormat) | ||
|
||
DoCreateRequest(mockWithFormat, requestWithFormat) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was not easy to follow here, maybe take requestWithFormat
inside DoCreateRequest
because they both use mockWithFormat
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed in 67d139d
LMK WDYT
Issue & Steps to Reproduce / Feature Request
Add support for JSON Format configuration variables
Solution
TEST_PATTERN
option when running provider tests, since those take like 10 minutes