From d586b3a7cd05a8c46c250f6f4db8505ffbc384b5 Mon Sep 17 00:00:00 2001 From: Alexander Kislitsky Date: Thu, 15 Sep 2016 14:27:46 +0300 Subject: [PATCH] Lookup path handled in the fuel2 Show lookup parameter added to 'config get' command Change-Id: I889139c015e469c9b6a5350b7048f8f74062cba0 Closes-Bug: #1623898 --- tuning_box/cli/resources.py | 11 ++++++++++- tuning_box/tests/cli/test_resources.py | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tuning_box/cli/resources.py b/tuning_box/cli/resources.py index f8bb600..4f9ca3a 100644 --- a/tuning_box/cli/resources.py +++ b/tuning_box/cli/resources.py @@ -64,12 +64,21 @@ class Get(show.ShowOne, ResourcesCommand): type=str, help="Name of key to get from the resource", ) + parser.add_argument( + '-s', '--show-lookup', + dest='show_lookup', + help="Show lookup path for the value in the result", + action='store_true' + ) return parser def take_action(self, parsed_args): + params = {'effective': True} + if parsed_args.show_lookup: + params['show_lookup'] = True response = self.get_client().get( self.get_resource_url(parsed_args), - params='effective', + params=params ) key = parsed_args.key if key is not None: diff --git a/tuning_box/tests/cli/test_resources.py b/tuning_box/tests/cli/test_resources.py index 815dcc0..fb2a503 100644 --- a/tuning_box/tests/cli/test_resources.py +++ b/tuning_box/tests/cli/test_resources.py @@ -53,6 +53,11 @@ class TestGet(testscenarios.WithScenarios, _BaseCLITest): 'get --env 1 --resource 1 --format=json', '{\n "hello": "world"\n}', )), + ('global,lookup', ( + '/environments/1/resources/1/values?effective', + 'get --env 1 --resource 1 --format=json --show-lookup', + '{\n "hello": "world"\n}', + )), ('lowlevel,json', ( '/environments/1/lvl1/value1/resources/1/values?effective', 'get --env 1 --level lvl1=value1 --resource 1 --format=json', @@ -73,6 +78,11 @@ class TestGet(testscenarios.WithScenarios, _BaseCLITest): 'get --env 1 --resource 1 --key hello --format json', '{\n "hello": "world"\n}', )), + ('key,lookup', ( + '/environments/1/resources/1/values?effective', + 'get --env 1 --resource 1 --key hello --format json -s', + '{\n "hello": "world"\n}', + )), ('key,yaml', ( '/environments/1/resources/1/values?effective', 'get --env 1 --resource 1 --key hello --format yaml',