Repository: aurora Updated Branches: refs/heads/master 31b7ea6fb -> 805a53f72
aurora update info command should print out update metadata * Metadata is represented as a list of key value pair Bugs closed: AURORA-1906 Reviewed at https://reviews.apache.org/r/66980/ Project: http://git-wip-us.apache.org/repos/asf/aurora/repo Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/805a53f7 Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/805a53f7 Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/805a53f7 Branch: refs/heads/master Commit: 805a53f72f183ed863bb1acd58ab0bb01cff4189 Parents: 31b7ea6 Author: Jing Chen <milantr...@gmail.com> Authored: Mon May 7 11:49:31 2018 -0700 Committer: Renan DelValle <re...@apache.org> Committed: Mon May 7 11:49:31 2018 -0700 ---------------------------------------------------------------------- .../python/apache/aurora/client/cli/update.py | 12 +++++++++++ .../apache/aurora/client/cli/test_supdate.py | 21 ++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aurora/blob/805a53f7/src/main/python/apache/aurora/client/cli/update.py ---------------------------------------------------------------------- diff --git a/src/main/python/apache/aurora/client/cli/update.py b/src/main/python/apache/aurora/client/cli/update.py index 7abc5d1..f9d8417 100644 --- a/src/main/python/apache/aurora/client/cli/update.py +++ b/src/main/python/apache/aurora/client/cli/update.py @@ -585,6 +585,11 @@ class UpdateInfo(Verb): "instance_update_events": [] } + if details.update.summary.metadata is not None: + result["metadata"] = [{metadata.key: metadata.value} for metadata in sorted( + [update_metadata for update_metadata in details.update.summary.metadata], + key=lambda x: (x.key, x.value))] + update_events = details.updateEvents if update_events is not None and len(update_events) > 0: for event in update_events: @@ -632,6 +637,13 @@ class UpdateInfo(Verb): event.instanceId, format_timestamp(event.timestampMs), JobUpdateAction._VALUES_TO_NAMES[event.action] ), indent=2) + if details.update.summary.metadata is not None: + update_metadata = sorted( + [metadata for metadata in details.update.summary.metadata], + key=lambda x: (x.key, x.value)) + context.print_out("Metadata:") + for metadata in update_metadata: + context.print_out("%s: %s" % (metadata.key, metadata.value), indent=2) return EXIT_OK http://git-wip-us.apache.org/repos/asf/aurora/blob/805a53f7/src/test/python/apache/aurora/client/cli/test_supdate.py ---------------------------------------------------------------------- diff --git a/src/test/python/apache/aurora/client/cli/test_supdate.py b/src/test/python/apache/aurora/client/cli/test_supdate.py index a3bb5b9..5dfa38f 100644 --- a/src/test/python/apache/aurora/client/cli/test_supdate.py +++ b/src/test/python/apache/aurora/client/cli/test_supdate.py @@ -616,9 +616,13 @@ class TestUpdateInfo(AuroraClientCommandTest): key=UPDATE_KEY, user="me", state=JobUpdateState( - status=JobUpdateStatus.ROLLING_FORWARD, - createdTimestampMs=1000, - lastModifiedTimestampMs=2000))), + status=JobUpdateStatus.ROLLING_FORWARD, + createdTimestampMs=1000, + lastModifiedTimestampMs=2000), + metadata={ + Metadata("issue", "test"), + Metadata("country", "America"), + Metadata("country", "Canada")})), updateEvents=[ JobUpdateEvent( status=JobUpdateStatus.ROLLING_FORWARD, @@ -671,7 +675,11 @@ Instance events: Instance 1 at 1970-01-01T00:00:06: INSTANCE_UPDATING Instance 2 at 1970-01-01T00:00:07: INSTANCE_UPDATING Instance 1 at 1970-01-01T00:00:08: INSTANCE_UPDATED - Instance 2 at 1970-01-01T00:00:09: INSTANCE_UPDATED""" + Instance 2 at 1970-01-01T00:00:09: INSTANCE_UPDATED +Metadata: + country: America + country: Canada + issue: test""" def test_update_info(self): self._mock_options.id = 'update_id' @@ -734,6 +742,11 @@ Instance events: "instance": 2, "timestamp": 9000 } + ], + "metadata": [ + {"country": "America"}, + {"country": "Canada"}, + {"issue": "test"} ] }