-
Notifications
You must be signed in to change notification settings - Fork 53
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
Accommodate non-Amazon data center info metadata #44
Conversation
Metadata metadataMap `xml:"metadata" json:"metadata"` | ||
} | ||
|
||
func bindValue(dst *string, m map[string]string, k string) bool { |
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.
Should m
here be src
instead like at line 236 below?
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.
Up to you. You are an artist in this PR :)
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 took my own advice.
} | ||
} | ||
|
||
return e.EncodeToken(start.End()) |
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.
Should we call Flush()
here?
https://golang.org/pkg/encoding/xml/#Encoder.EncodeToken
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.
The documentation mentions creating an Encoder
:
Callers that create an
Encoder
and then invokeEncodeToken
directly, without usingEncode
orEncodeElement
, need to callFlush
when finished to ensure that the XML is written to the underlying writer.
Here, I didn't create the Encoder
; it's created implicitly over in fargo.marshal
in file net.go. Note that xml.Marshal
creates an Encoder
and calls Encode
on it, which in turn flushes when it's done writing. Hence I don't think that calling Flush
explicitly here is necessary.
I had a few minor comments, other then that it looks good 👍 Thank you for great unit tests! |
The existing "Metadata" field in the DataCenterInfo struct conveys details specific to instances running within one of Amazon's data centers. For instances running in other types of data centers, introduce a sibling "AlternateMetadata" field, sending and populating it only when the DataCenterInfo's "Name" field is "Amazon". Retaining the original "Metadata" field maintains compatibility with existing callers, unless they had populated that field for data centers with names other than "Amazon".
6de7bd6
to
bb10d2c
Compare
PTAL. |
Changes are good to go. I need to test them and will release that. Thank you very much @seh |
Fantastic. Thank you. |
These proposed changes address #42, including tests to demonstrate the special marshaling policy for the
fargo.DataCenterInfo
struct.Let me know if you think we should define a method on
DataCenterInfo
likeAddMetadataEntry(key, value string)
that would create the map for theAlternateMetadata
field if it's still nil.