Added task labels modeling to http helpers. Review: https://reviews.apache.org/r/28155
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8ed19187 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8ed19187 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8ed19187 Branch: refs/heads/master Commit: 8ed19187ca9389a580aefe24eeedce188f3ace68 Parents: 77b9d3d Author: Niklas Nielsen <[email protected]> Authored: Tue Nov 18 16:21:40 2014 -0800 Committer: Niklas Q. Nielsen <[email protected]> Committed: Tue Nov 18 16:21:40 2014 -0800 ---------------------------------------------------------------------- src/common/http.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/8ed19187/src/common/http.cpp ---------------------------------------------------------------------- diff --git a/src/common/http.cpp b/src/common/http.cpp index 58050e9..b21e18d 100644 --- a/src/common/http.cpp +++ b/src/common/http.cpp @@ -130,6 +130,15 @@ JSON::Object model(const Task& task) } object.values["statuses"] = array; + JSON::Array labels; + foreach (const Label& label, task.labels()) { + JSON::Object labelObject; + labelObject.values["key"] = label.key(); + labelObject.values["value"] = label.has_value() ? label.value() : ""; + labels.values.push_back(labelObject); + } + object.values["labels"] = labels; + return object; } @@ -162,6 +171,15 @@ JSON::Object model( } object.values["statuses"] = array; + JSON::Array labels; + foreach (const Label& label, task.labels()) { + JSON::Object labelObject; + labelObject.values["key"] = label.key(); + labelObject.values["value"] = label.has_value() ? label.value() : ""; + labels.values.push_back(labelObject); + } + object.values["labels"] = labels; + return object; }
