-
Notifications
You must be signed in to change notification settings - Fork 25
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(lwcomponent): better JSON handling components #946
Conversation
@@ -255,12 +255,45 @@ type Component struct { | |||
Name string `json:"name"` | |||
Description string `json:"description"` | |||
Type Type `json:"type"` | |||
LatestVersion semver.Version `json:"version"` | |||
LatestVersion semver.Version `json:"-"` |
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.
We need this field.
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.
Please see MarshalJSON()
and UnmarshalJSON()
methods for Component
which properly handles this field via LatestVersionString
. Also TestJSON
shows this properly being marshaled and unmarshaled.
@@ -255,12 +255,45 @@ type Component struct { | |||
Name string `json:"name"` | |||
Description string `json:"description"` | |||
Type Type `json:"type"` | |||
LatestVersion semver.Version `json:"version"` | |||
LatestVersion semver.Version `json:"-"` |
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.
Maybe:
LatestVersion semver.Version `json:"-"` | |
LatestVersion semver.Version `json:"version,omitempty"` |
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.
Please see MarshalJSON()
and UnmarshalJSON()
methods for Component
which properly handles this field via LatestVersionString
. Also TestJSON
shows this properly being marshaled and unmarshaled.
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're way to smart!
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.
Way to smart!!
Thanks for the speedy review @afiune |
Summary
When attempting to
json.Unmarshal
thelwcomponent.Component
object several quirks are present.url
andcommand_name
)version
should be a string not a dictHow did you test this change?
Unit tests added
Issue
https://lacework.atlassian.net/browse/ALLY-1229