-
Notifications
You must be signed in to change notification settings - Fork 3
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
Return error for multiple config options set #854
Conversation
493aa41
to
e2c2a6b
Compare
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.
You forgot to add a test, I wrote one and it confirmed that your solution isn't working. See f9ba7a3 where I've added a different kind of check early in the function.
case types.S3 != nil: | ||
c.Value = types.S3 | ||
case types.SFTPConfig != nil: | ||
if reflect.ValueOf(c.Value).IsValid() { |
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 think that we can still use a simple nil check here, right? If you disagree please show me what's the value added because I can't see it. This could be a starting point for us to understand it: https://go.dev/play/p/y2XQtTZ1jnQ.
I expected this to work because I expected Cstyle switch statements. I this works if I write the fall through keywords then we don't need to unMarshall a struct and allocate any extra memory here. |
f9ba7a3
to
299fbc6
Compare
An error is now returned when the configuration document provides multiple storage configuration values. Co-authored-by: Jesús García Crespo <[email protected]>
299fbc6
to
f485022
Compare
I'd love to see what that looks like. Feel free to push a new commit with changes to UnmarshalJSON, ensuring the tests still pass. |
Going to merge, feel free to submit an additional PR showing your alternative to UnmarshalJSON if you feel like it. I personally feel like this is easy to read and the overhead is definitely not substantial. |
An error is now returned when a more than one storage configuration has
been set. Previously, this would not return an error and simply use what
-ever the user had set that was first in the storage switch options.
Closes #853