feat: Expose the values contained in an HCL validation string to the API#1587
Merged
Conversation
This allows the frontend to render inputs displaying these values!
johnstcn
reviewed
May 19, 2022
johnstcn
reviewed
May 19, 2022
Comment on lines
+33
to
+34
| SourceScheme database.ParameterSourceScheme `json:"source_scheme"` | ||
| DestinationScheme database.ParameterDestinationScheme `json:"destination_scheme"` |
Member
There was a problem hiding this comment.
We should avoid importing database types into codersdk. Since these are both strings under the hood, let's just call a spade a spade.
Co-authored-by: Cian Johnston <cian@coder.com>
johnstcn
reviewed
May 19, 2022
|
|
||
| func convertParameterSchema(parameterSchema database.ParameterSchema) (codersdk.ParameterSchema, error) { | ||
| contains := []string{} | ||
| if parameterSchema.ValidationCondition != "" { |
Member
There was a problem hiding this comment.
I figure we'll have validation conditions other than contains at some point, it's probably good to do this now:
switch parameterSchema.ValidationCondition {
case "contains": // parameter.Contains
default:
return codersdk.ParameterSchema{}, xerrors.Errorf(...)
}
Member
Author
There was a problem hiding this comment.
Our contains function already does this, and since it has to parse HCL I'd rather it be self-contained and reaaally well tested.
johnstcn
approved these changes
May 19, 2022
kylecarbs
added a commit
that referenced
this pull request
Jun 10, 2022
…API (#1587) * feat: Expose the values contained in an HCL validation string to the API This allows the frontend to render inputs displaying these values! * Update codersdk/parameters.go Co-authored-by: Cian Johnston <cian@coder.com> * Call a spade a space * Fix linting errors with type conversion Co-authored-by: Cian Johnston <cian@coder.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows the frontend to render inputs displaying these values!