-
Notifications
You must be signed in to change notification settings - Fork 57
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 YAMLRemoteRefParser with empty input #94
Conversation
Do not treat empty input as an invalid remote reference, since apps may use an empty file as an on/off switch. Also add some tests for parsing, since there are several edge cases now.
This is messier than I'd like, but I couldn't think of a better way to detect empty files (which may be all comments or whitespace, and thus not literally empty) without parsing the input twice. Edit: I fixed this by making |
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.
this seems better than what it is currently, so +1
just some non-blocking questions
Ref *string `yaml:"ref"` | ||
} | ||
|
||
if err := yaml.UnmarshalStrict(b, &maybeRef); err != 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.
curious: why not just Unmarshal
?
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.
If there are any fields that aren't part of the RemoteRef
structure, the parser assumes the file is not a remote reference. Using UnmarshalStrict
returns an error if there are unknown fields.
Do not treat empty input as an invalid remote reference, since apps may
use an empty file as an on/off switch. Also add some tests for parsing,
since there are several edge cases now.