Skip to content
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

Merged
merged 2 commits into from
Sep 27, 2016

Conversation

seh
Copy link
Contributor

@seh seh commented Aug 30, 2016

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 like AddMetadataEntry(key, value string) that would create the map for the AlternateMetadata field if it's still nil.

Metadata metadataMap `xml:"metadata" json:"metadata"`
}

func bindValue(dst *string, m map[string]string, k string) bool {
Copy link
Contributor Author

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?

Copy link
Contributor

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 :)

Copy link
Contributor Author

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())
Copy link
Contributor

@damtur damtur Sep 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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 invoke EncodeToken directly, without using Encode or EncodeElement, need to call Flush 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.

@damtur
Copy link
Contributor

damtur commented Sep 9, 2016

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".
@seh
Copy link
Contributor Author

seh commented Sep 19, 2016

PTAL.

@damtur
Copy link
Contributor

damtur commented Sep 21, 2016

Changes are good to go. I need to test them and will release that. Thank you very much @seh

@seh
Copy link
Contributor Author

seh commented Sep 21, 2016

Fantastic. Thank you.

@damtur damtur merged commit 9a362c8 into hudl:master Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants