From 2245f90386e1c628e3ea25a5a8c5bea537be1663 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 10:17:52 +0200 Subject: [PATCH 1/9] Include scope in the result of the set command. --- st2client/st2client/commands/keyvalue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/st2client/st2client/commands/keyvalue.py b/st2client/st2client/commands/keyvalue.py index 4c8ae5fb58..e681d20aae 100644 --- a/st2client/st2client/commands/keyvalue.py +++ b/st2client/st2client/commands/keyvalue.py @@ -148,7 +148,7 @@ def run(self, args, **kwargs): class KeyValuePairSetCommand(resource.ResourceCommand): - display_attributes = ['name', 'value', 'expire_timestamp'] + display_attributes = ['name', 'value', 'scope', 'expire_timestamp'] def __init__(self, resource, *args, **kwargs): super(KeyValuePairSetCommand, self).__init__( From 5869c015bec57df45b6ec938cfebbc3f2f14d0f9 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 10:29:05 +0200 Subject: [PATCH 2/9] Add additional logging which makes it easier to debug scoping issues. --- contrib/runners/orchestra_runner/functions/st2kv.py | 2 -- st2common/st2common/util/keyvalue.py | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/runners/orchestra_runner/functions/st2kv.py b/contrib/runners/orchestra_runner/functions/st2kv.py index e749e1547f..f28f522687 100644 --- a/contrib/runners/orchestra_runner/functions/st2kv.py +++ b/contrib/runners/orchestra_runner/functions/st2kv.py @@ -43,8 +43,6 @@ def st2kv_(context, key, decrypt=False): except Exception as e: raise Exception('Failed to retrieve User object for user "%s" % (username)' % (str(e))) - LOG.debug('ST2KV Decrypt: %s', decrypt) - kvp = kvp_util.get_key(key=key, user_db=user_db, decrypt=decrypt) if not kvp: diff --git a/st2common/st2common/util/keyvalue.py b/st2common/st2common/util/keyvalue.py index 3055bd8e60..e5ef6f7662 100644 --- a/st2common/st2common/util/keyvalue.py +++ b/st2common/st2common/util/keyvalue.py @@ -99,7 +99,9 @@ def get_key(key=None, user_db=None, scope=None, decrypt=False): scope, key_id = _derive_scope_and_key(key=key, user=user_db.name, scope=scope) scope = get_datastore_full_scope(scope) - LOG.debug('get_key scope: %s', scope) + LOG.debug('get_key key_id: %s, scope: %s, user: %s, decrypt: %s' % (key_id, scope, + str(user_db.name), + decrypt)) _validate_scope(scope=scope) From 2bf5e9306505f3706247ec59e764e60a4c28629e Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 10:34:32 +0200 Subject: [PATCH 3/9] Use orchestra_functions prefix for package which is used to store orchestra functions. Using just "functions" means those functions will be copied / installed into "functions" package which could conflict with actual package named functions. --- contrib/runners/orchestra_runner/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/runners/orchestra_runner/setup.py b/contrib/runners/orchestra_runner/setup.py index b4028cf737..ef48ee58bc 100644 --- a/contrib/runners/orchestra_runner/setup.py +++ b/contrib/runners/orchestra_runner/setup.py @@ -50,7 +50,7 @@ 'orchestra = orchestra_runner.orchestra_runner', ], 'orchestra.expressions.functions': [ - 'st2kv = functions.st2kv:st2kv_', + 'st2kv = orchestra_functions.st2kv:st2kv_', ], } ) From 7149768e28802c76981459b5a5964e60f5616db3 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 10:38:33 +0200 Subject: [PATCH 4/9] Rename package from functions to orchestra_functions. --- .../{functions => orchestra_functions}/__init__.py | 0 .../orchestra_runner/{functions => orchestra_functions}/st2kv.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename contrib/runners/orchestra_runner/{functions => orchestra_functions}/__init__.py (100%) rename contrib/runners/orchestra_runner/{functions => orchestra_functions}/st2kv.py (100%) diff --git a/contrib/runners/orchestra_runner/functions/__init__.py b/contrib/runners/orchestra_runner/orchestra_functions/__init__.py similarity index 100% rename from contrib/runners/orchestra_runner/functions/__init__.py rename to contrib/runners/orchestra_runner/orchestra_functions/__init__.py diff --git a/contrib/runners/orchestra_runner/functions/st2kv.py b/contrib/runners/orchestra_runner/orchestra_functions/st2kv.py similarity index 100% rename from contrib/runners/orchestra_runner/functions/st2kv.py rename to contrib/runners/orchestra_runner/orchestra_functions/st2kv.py From 498ead5c3ac51e6dc14a665fc2484e8904dc6f4c Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 10:42:02 +0200 Subject: [PATCH 5/9] Add license header. --- .../orchestra_functions/__init__.py | 14 ++++++++++++++ st2common/st2common/util/keyvalue.py | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/runners/orchestra_runner/orchestra_functions/__init__.py b/contrib/runners/orchestra_runner/orchestra_functions/__init__.py index e69de29bb2..f6da6ca025 100644 --- a/contrib/runners/orchestra_runner/orchestra_functions/__init__.py +++ b/contrib/runners/orchestra_runner/orchestra_functions/__init__.py @@ -0,0 +1,14 @@ +# Licensed to the StackStorm, Inc ('StackStorm') under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/st2common/st2common/util/keyvalue.py b/st2common/st2common/util/keyvalue.py index e5ef6f7662..1b4ddc719e 100644 --- a/st2common/st2common/util/keyvalue.py +++ b/st2common/st2common/util/keyvalue.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - from __future__ import absolute_import import six import logging From 92568062d4b8a8b40cff61c4ce3b34b9eeb12fca Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 10:45:36 +0200 Subject: [PATCH 6/9] Remove license header from empty file. --- .../orchestra_functions/__init__.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/contrib/runners/orchestra_runner/orchestra_functions/__init__.py b/contrib/runners/orchestra_runner/orchestra_functions/__init__.py index f6da6ca025..e69de29bb2 100644 --- a/contrib/runners/orchestra_runner/orchestra_functions/__init__.py +++ b/contrib/runners/orchestra_runner/orchestra_functions/__init__.py @@ -1,14 +0,0 @@ -# Licensed to the StackStorm, Inc ('StackStorm') under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. From 02f65908a9064f35e9459da9760cd5b138c88e72 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 11:14:27 +0200 Subject: [PATCH 7/9] Update affected import. --- .../runners/orchestra_runner/tests/unit/test_expr_func_st2kv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/runners/orchestra_runner/tests/unit/test_expr_func_st2kv.py b/contrib/runners/orchestra_runner/tests/unit/test_expr_func_st2kv.py index 3e6fe1c746..98506c667d 100644 --- a/contrib/runners/orchestra_runner/tests/unit/test_expr_func_st2kv.py +++ b/contrib/runners/orchestra_runner/tests/unit/test_expr_func_st2kv.py @@ -23,7 +23,7 @@ import st2tests.config as tests_config tests_config.parse_args() -from functions import st2kv +from orchestra_functions import st2kv from orchestra import exceptions as exc from st2common.constants import keyvalue as kvp_const From 41769824b51aa19edb786a9e7e4b7f91b16f65d7 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 11:17:49 +0200 Subject: [PATCH 8/9] For now don't validate config permissions. We also need to fix installer so it won't warn user in the default install. --- st2client/st2client/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st2client/st2client/base.py b/st2client/st2client/base.py index 6ee204210a..1e01885160 100644 --- a/st2client/st2client/base.py +++ b/st2client/st2client/base.py @@ -153,7 +153,7 @@ def get_client(self, args, debug=False): return client - def _get_config_file_options(self, args, validate_config_permissions=True): + def _get_config_file_options(self, args, validate_config_permissions=False): """ Parse the config and return kwargs which can be passed to the Client constructor. @@ -168,7 +168,7 @@ def _get_config_file_options(self, args, validate_config_permissions=True): return result - def _parse_config_file(self, args, validate_config_permissions=True): + def _parse_config_file(self, args, validate_config_permissions=False): config_file_path = self._get_config_file_path(args=args) parser = CLIConfigParser(config_file_path=config_file_path, From e16a59ac029926f63fa1eb507653f19fef18f4c7 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 11:42:16 +0200 Subject: [PATCH 9/9] Disable warning tests until we re-enable the checks. --- st2client/tests/unit/test_shell.py | 1 + 1 file changed, 1 insertion(+) diff --git a/st2client/tests/unit/test_shell.py b/st2client/tests/unit/test_shell.py index aca0a0acc2..ece76fa250 100644 --- a/st2client/tests/unit/test_shell.py +++ b/st2client/tests/unit/test_shell.py @@ -463,6 +463,7 @@ def _write_mock_package_metadata_file(self): return package_metadata_path + @unittest2.skipIf(True, 'skipping until checks are re-enabled') @mock.patch.object( requests, 'get', mock.MagicMock(return_value=base.FakeResponse("{}", 200, 'OK')))