-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix(storagedirective): fix storage directive validator #538
Conversation
- Add validation logic to check for unknown or null values in the map elements. - Parse and validate storage directives using `juju/storage` package (use `jujustorage` name instead `storage`).
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.
I haven't completed QA yet, but I have a question.
// If the value of any element is unknown or null, there is nothing to validate. | ||
for _, element := range req.ConfigValue.Elements() { | ||
if element.IsUnknown() || element.IsNull() { | ||
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.
thought: Should this be continue
instead? What if there is more than one storage directive provided?
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 like we just need to stop validating if we have at least one unknown among variables.
I've updated QA to touch case with multiple vars and and storage directives.
It looks like it's working.
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.
todo: update the comment at line 33 to describe what is going on so we know if it breaks again. Below describes what I found and why this works.
It's only working because the method is called twice by terraform. I added some logging to see what is going on
Warning: CALLED ValidateMap "{\"block\":<unknown>,\"files\":\"73heather\"}"
Warning: CALLED ValidateMap "{\"block\":\"101M\",\"files\":\"73heather\"}"
The second call has the values filled in. I have no idea why terraform is doing this. If the behavior changes, we won't validate all the values.
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.
Once the comment is appropriately updated, approved.
It looks like the GitHub action fails, not because of the PR. So I'll merge it. |
Description
This fix add the following:
juju/storage
package (usejujustorage
name insteadstorage
).Fixes: #534
Type of change
Environment
Juju controller version:
Terraform version:
QA steps