From b25af94a3239ffe12ba4cd7b2f4b943ce7928cdf Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 17 Jan 2023 01:54:39 +0000 Subject: [PATCH 1/7] [CI/CD] release version v1.11.0-rc1 --- src/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VERSION b/src/VERSION index 80057b0..8ad7b8c 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -v1.10.4.2 +v1.11.0-rc1 From 3b56bed0b6e12c629aaf6506e266f7f561499c07 Mon Sep 17 00:00:00 2001 From: Jongmin Kim Date: Wed, 25 Jan 2023 12:56:27 +0900 Subject: [PATCH 2/7] feat add sub command for checking global configuration (cherry picked from commit 238db7f5b2fccb21a27c8fcf55f66e1e488ee5d2) --- src/spaceone/core/command.py | 51 +++++++++++++++++------- src/spaceone/core/config/__init__.py | 4 -- src/spaceone/core/config/default_conf.py | 1 - 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/spaceone/core/command.py b/src/spaceone/core/command.py index 5c93cfc..b812838 100644 --- a/src/spaceone/core/command.py +++ b/src/spaceone/core/command.py @@ -7,7 +7,7 @@ import click import pkg_resources -from spaceone.core import config, pygrpc, fastapi +from spaceone.core import config, pygrpc, fastapi, utils from spaceone.core import scheduler as scheduler_v1 from spaceone.core.unittest.runner import RichTestRunner @@ -29,11 +29,11 @@ def create_project(project_name=None, directory=None): @click.option('-p', '--port', type=int, default=lambda: os.environ.get('SPACEONE_PORT', 50051), help='Port of gRPC server', show_default=True) @click.option('-c', '--config', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), - help='config file path') + help='Config file path') @click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') def grpc(package, port=None, config=None, module_path=None): """Run a gRPC server""" - _set_server_config('grpc', package, module_path, port, config_file=config) + _set_server_config(package, module_path, port, config_file=config) pygrpc.serve() @@ -44,11 +44,11 @@ def grpc(package, port=None, config=None, module_path=None): @click.option('-p', '--port', type=int, default=lambda: os.environ.get('SPACEONE_PORT', 8000), help='Port of REST server', show_default=True) @click.option('-c', '--config', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), - help='config file path') + help='Config file path') @click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') def rest(package, host=None, port=None, config=None, module_path=None): """Run a FastAPI REST server""" - _set_server_config('rest', package, module_path, port, config_file=config) + _set_server_config(package, module_path, port, config_file=config) fastapi.serve() @@ -59,20 +59,33 @@ def rest(package, host=None, port=None, config=None, module_path=None): @click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') def scheduler(package, config=None, module_path=None): """Run a scheduler server""" - _set_server_config('scheduler', package, module_path, config_file=config) + _set_server_config(package, module_path, config_file=config) scheduler_v1.serve() @cli.command() -@click.option('-c', '--config', type=str, help='config file path for tester') -@click.option('-d', '--dir', type=str, help="directory containing test files", +@click.argument('package') +@click.option('-c', '--config', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), + help='Config file path') +@click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') +@click.option('-o', '--output', default='yaml', help='Output format', + type=click.Choice(['json', 'yaml']), show_default=True) +def show_config(package, config=None, module_path=None, output=None): + """Show global configurations""" + _set_server_config(package, module_path, config_file=config) + _print_config(output) + + +@cli.command() +@click.option('-c', '--config', type=str, help='Config file path') +@click.option('-d', '--dir', type=str, help="Directory containing test files", default=lambda: os.environ.get('SPACEONE_WORKING_DIR', os.getcwd())) -@click.option('-f', '--failfast', help="fast failure flag", is_flag=True) -@click.option('-s', '--scenario', type=str, help="scenario file path") -@click.option('-p', '--parameters', type=str, help="custom parameters to override a scenario file. " +@click.option('-f', '--failfast', help="Fast failure flag", is_flag=True) +@click.option('-s', '--scenario', type=str, help="Scenario file path") +@click.option('-p', '--parameters', type=str, help="Custom parameters to override a scenario file. " "ex) -p domain.domain.name=new_name -p options.update_mode=false", multiple=True) -@click.option('-v', '--verbose', count=True, help='verbosity level', default=1) +@click.option('-v', '--verbose', count=True, help='Verbosity level', default=1) def test(config=None, dir=None, failfast=False, scenario: str = None, parameters: List[str] = None, verbose=1): """Unit tests for source code""" # set config @@ -120,14 +133,13 @@ def _set_python_path(package, module_path): 'Please check the module path.') -def _set_server_config(command, package, module_path=None, port=None, config_file=None): +def _set_server_config(package, module_path=None, port=None, config_file=None): # 1. Set a python path _set_python_path(package, module_path) # 2. Initialize config from command argument config.init_conf( package=package, - server_type=command, port=port ) @@ -168,5 +180,16 @@ def _create_project(project_name, directory=None): init_project_file(os.path.join(project_path, 'conf', 'proto_conf.py'), proto_conf) +def _print_config(output): + data = { + 'GLOBAL': config.get_global() + } + + if output == 'json': + print(utils.dump_json(data, indent=4)) + else: + print(utils.dump_yaml(data)) + + if __name__ == '__main__': cli() diff --git a/src/spaceone/core/config/__init__.py b/src/spaceone/core/config/__init__.py index 0e5829f..b7429b5 100644 --- a/src/spaceone/core/config/__init__.py +++ b/src/spaceone/core/config/__init__.py @@ -1,6 +1,5 @@ import copy import logging -import sys import consul from spaceone.core import utils @@ -17,9 +16,6 @@ def init_conf(package, **kwargs): _GLOBAL['PACKAGE'] = package _GLOBAL['SERVICE'] = package.rsplit('.', 1)[-1:][0] - if 'server_type' in kwargs: - _GLOBAL['SERVER_TYPE'] = kwargs['server_type'] - if 'host' in kwargs: _GLOBAL['HOST'] = kwargs['HOST'] diff --git a/src/spaceone/core/config/default_conf.py b/src/spaceone/core/config/default_conf.py index 760cefc..c19def2 100644 --- a/src/spaceone/core/config/default_conf.py +++ b/src/spaceone/core/config/default_conf.py @@ -9,7 +9,6 @@ SERVICE = None # Server Configuration -SERVER_TYPE = None PORT = 50051 HOST = '127.0.0.1' From 33bab5ae37fa8c8a0990849f0385d3a0cc6fac55 Mon Sep 17 00:00:00 2001 From: Jongmin Kim Date: Wed, 25 Jan 2023 13:02:09 +0900 Subject: [PATCH 3/7] refactor: change command option name (cherry picked from commit 2de75c53aee386ec83a780b149a173feae14658b) --- src/spaceone/core/command.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/spaceone/core/command.py b/src/spaceone/core/command.py index b812838..286f383 100644 --- a/src/spaceone/core/command.py +++ b/src/spaceone/core/command.py @@ -28,12 +28,12 @@ def create_project(project_name=None, directory=None): @click.argument('package') @click.option('-p', '--port', type=int, default=lambda: os.environ.get('SPACEONE_PORT', 50051), help='Port of gRPC server', show_default=True) -@click.option('-c', '--config', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), +@click.option('-c', '--config-file', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), help='Config file path') @click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') -def grpc(package, port=None, config=None, module_path=None): +def grpc(package, port=None, config_file=None, module_path=None): """Run a gRPC server""" - _set_server_config(package, module_path, port, config_file=config) + _set_server_config(package, module_path, port, config_file=config_file) pygrpc.serve() @@ -43,41 +43,41 @@ def grpc(package, port=None, config=None, module_path=None): help='Host of REST server', show_default=True) @click.option('-p', '--port', type=int, default=lambda: os.environ.get('SPACEONE_PORT', 8000), help='Port of REST server', show_default=True) -@click.option('-c', '--config', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), +@click.option('-c', '--config-file', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), help='Config file path') @click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') -def rest(package, host=None, port=None, config=None, module_path=None): +def rest(package, host=None, port=None, config_file=None, module_path=None): """Run a FastAPI REST server""" - _set_server_config(package, module_path, port, config_file=config) + _set_server_config(package, module_path, port, config_file=config_file) fastapi.serve() @cli.command() @click.argument('package') -@click.option('-c', '--config', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), +@click.option('-c', '--config-file', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), help='config file path') @click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') -def scheduler(package, config=None, module_path=None): +def scheduler(package, config_file=None, module_path=None): """Run a scheduler server""" - _set_server_config(package, module_path, config_file=config) + _set_server_config(package, module_path, config_file=config_file) scheduler_v1.serve() @cli.command() @click.argument('package') -@click.option('-c', '--config', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), +@click.option('-c', '--config-file', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), help='Config file path') @click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') @click.option('-o', '--output', default='yaml', help='Output format', type=click.Choice(['json', 'yaml']), show_default=True) -def show_config(package, config=None, module_path=None, output=None): +def show_config(package, config_file=None, module_path=None, output=None): """Show global configurations""" - _set_server_config(package, module_path, config_file=config) + _set_server_config(package, module_path, config_file=config_file) _print_config(output) @cli.command() -@click.option('-c', '--config', type=str, help='Config file path') +@click.option('-c', '--config-file', type=str, help='Config file path') @click.option('-d', '--dir', type=str, help="Directory containing test files", default=lambda: os.environ.get('SPACEONE_WORKING_DIR', os.getcwd())) @click.option('-f', '--failfast', help="Fast failure flag", is_flag=True) @@ -86,11 +86,11 @@ def show_config(package, config=None, module_path=None, output=None): "ex) -p domain.domain.name=new_name -p options.update_mode=false", multiple=True) @click.option('-v', '--verbose', count=True, help='Verbosity level', default=1) -def test(config=None, dir=None, failfast=False, scenario: str = None, parameters: List[str] = None, verbose=1): +def test(config_file=None, dir=None, failfast=False, scenario: str = None, parameters: List[str] = None, verbose=1): """Unit tests for source code""" # set config if config: - os.environ['TEST_CONFIG'] = config + os.environ['TEST_CONFIG'] = config_file if scenario: os.environ['TEST_SCENARIO'] = scenario From 19c6271074d36310e817ab303497cbb363dd3cec Mon Sep 17 00:00:00 2001 From: Jongmin Kim Date: Wed, 25 Jan 2023 13:04:24 +0900 Subject: [PATCH 4/7] refactor: change command option name (cherry picked from commit 01a2c867aaa8f39c4bd4002457af3e88b0d5a646) --- src/spaceone/core/command.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/spaceone/core/command.py b/src/spaceone/core/command.py index 286f383..4ac08a7 100644 --- a/src/spaceone/core/command.py +++ b/src/spaceone/core/command.py @@ -30,7 +30,7 @@ def create_project(project_name=None, directory=None): help='Port of gRPC server', show_default=True) @click.option('-c', '--config-file', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), help='Config file path') -@click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') +@click.option('-m', '--module-path', type=click.Path(exists=True), multiple=True, help='Module path') def grpc(package, port=None, config_file=None, module_path=None): """Run a gRPC server""" _set_server_config(package, module_path, port, config_file=config_file) @@ -45,7 +45,7 @@ def grpc(package, port=None, config_file=None, module_path=None): help='Port of REST server', show_default=True) @click.option('-c', '--config-file', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), help='Config file path') -@click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') +@click.option('-m', '--module-path', type=click.Path(exists=True), multiple=True, help='Module path') def rest(package, host=None, port=None, config_file=None, module_path=None): """Run a FastAPI REST server""" _set_server_config(package, module_path, port, config_file=config_file) @@ -56,7 +56,7 @@ def rest(package, host=None, port=None, config_file=None, module_path=None): @click.argument('package') @click.option('-c', '--config-file', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), help='config file path') -@click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') +@click.option('-m', '--module-path', type=click.Path(exists=True), multiple=True, help='Module path') def scheduler(package, config_file=None, module_path=None): """Run a scheduler server""" _set_server_config(package, module_path, config_file=config_file) @@ -67,7 +67,7 @@ def scheduler(package, config_file=None, module_path=None): @click.argument('package') @click.option('-c', '--config-file', type=click.Path(exists=True), default=lambda: os.environ.get('SPACEONE_CONFIG_FILE'), help='Config file path') -@click.option('-m', '--module_path', type=click.Path(exists=True), multiple=True, help='Module path') +@click.option('-m', '--module-path', type=click.Path(exists=True), multiple=True, help='Module path') @click.option('-o', '--output', default='yaml', help='Output format', type=click.Choice(['json', 'yaml']), show_default=True) def show_config(package, config_file=None, module_path=None, output=None): From 188fa16072262d29d10a2985412532d50372ea32 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 25 Jan 2023 04:06:18 +0000 Subject: [PATCH 5/7] [CI/CD] release version v1.11.0-rc2 --- src/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VERSION b/src/VERSION index 8ad7b8c..b6bec8f 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -v1.11.0-rc1 +v1.11.0-rc2 From 215eb9296e74944cf12cd67a4afb318814f21b12 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 30 Jan 2023 02:14:35 +0000 Subject: [PATCH 6/7] [CI/CD] release version v1.11.0-rc3 --- src/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VERSION b/src/VERSION index b6bec8f..833d616 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -v1.11.0-rc2 +v1.11.0-rc3 From 3c7b0c1e02163b623d7677250455c93b6c6905d4 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 30 Jan 2023 02:59:14 +0000 Subject: [PATCH 7/7] [CI/CD] release version v1.11.0 --- src/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VERSION b/src/VERSION index 833d616..cd74ac3 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -v1.11.0-rc3 +v1.11.0