From 7dd0273db9b5e60e031571346ccb44d6f9b89a16 Mon Sep 17 00:00:00 2001 From: Grashalmbeisser <57599830+Grashalmbeisser@users.noreply.github.com> Date: Mon, 6 May 2024 15:50:33 +0200 Subject: [PATCH] Merge develop branch into main (#142) * deployment version name now extendable (#89) Co-authored-by: Christos * Feature/develop y (#90) * edded acceptall flag for deployment * redid comment * PEP8 fixes * deleted debug output --------- Co-authored-by: Christos * Fix/project.json (#88) * changed projectConfig globaly to project_config * @wip write delete method * @wip: delte process * fixed format from default.format, to just format * new reformatting in conf.py for project.json format 1.2.0 * using lstrip instead of rege * @WIP viur install * Project Config is now a singleton * pycharm is about to crash * env now shows Versions depending on builds * new config usage in install.py and build.py * @wip new config usage throughout the project * added profile usage in all project.conf related functions * format changes from project.json v1.1.1 to 2.0.0 * touch ups on project.json functionality * added project.json example in readme.md * version and changelog * fixed typo * readme.md does is not ugly anymore * resolved PR suggestions * fixed typo --------- Co-authored-by: Christos * fixed merge conflict related bugs (#91) Co-authored-by: Christos * Deployment/v2.0.0dev (#94) * fixed merge conflict related bugs * added tag --------- Co-authored-by: Christos * Deployment/v2.0.0dev (#95) * fixed merge conflict related bugs * added tag * typo in version string --------- Co-authored-by: Christos * Deployment/v2.0.0dev (#96) * fixed merge conflict related bugs * added tag * typo in version string * test --------- Co-authored-by: Christos * feat: Add newline in `project.json` (#102) * fixed merge conflict related bugs * added/trailingline * Update src/viur_cli/conf.py Co-authored-by: Sven Eberth * refactore --------- Co-authored-by: Sven Eberth * feat: `viur install update` command (#103) * fixed merge conflict related bugs * feature/updateAllForBuilds * PEP8 Fixes * refactored old install.py into packtet.py as a pseudo packet manager for viur tools * Ai generated Documentation * refactoring and documentation * Update README.md Co-authored-by: Jan Max Meyer --------- Co-authored-by: Jan Max Meyer * Feature/gcloud functions (#98) * fixed merge conflict related bugs * @wip shit * @wip cloud function creation, deployment and disable backups * implemented glcoud setup in viur cli * fixed pep8 errors * @WIP: need to finalize SETUP and do PEP8 stuff * refactored Role administration via viur cloud command * added changelog and readme.md to the project * bumped version to 2.0.0.dev3 * refinement of gcloud setup script * Update src/viur_cli/cloud.py Co-authored-by: Sven Eberth * Update src/viur_cli/cloud.py Co-authored-by: Sven Eberth * Update src/viur_cli/cloud.py Co-authored-by: Jan Max Meyer * Update src/viur_cli/cloud.py Co-authored-by: Jan Max Meyer --------- Co-authored-by: Sven Eberth Co-authored-by: Jan Max Meyer * changed github workflow * new workflow file * uodated vorkflows and version * Renewed Docstrings and Helptexts (#110) * documentation * Update README.md Co-authored-by: Jan Max Meyer * Update README.md Co-authored-by: Jan Max Meyer * Update README.md Co-authored-by: Jan Max Meyer * Update README.md Co-authored-by: Jan Max Meyer * Update README.md Co-authored-by: Jan Max Meyer * Update README.md Co-authored-by: Jan Max Meyer * Update README.md Co-authored-by: Jan Max Meyer --------- Co-authored-by: Jan Max Meyer * Feature/indexfix (#111) * clean indices * clean indices and smaller bugfixes * Update src/viur_cli/update.py Co-authored-by: Jan Max Meyer --------- Co-authored-by: Jan Max Meyer * One * new rc * updated setup.cfg * Fixes for v2.0 (#112) * Use correct argument name for profile * Provide a "skip" option for vi/admin-decision ... and ask only once, when the project.json version is changed initially. * Update src/viur_cli/conf.py --------- Co-authored-by: Grashalmbeisser <57599830+Grashalmbeisser@users.noreply.github.com> * added fixes * typo fixes * fixed broken deploy comand * added default gcloud accounnt ptint for env * fixed typo * Update CHANGELOG.md * added default gcloud accounnt print for env (#117) * added default gcloud accounnt ptint for env * fixed typo * Update CHANGELOG.md --------- Co-authored-by: Jan Max Meyer * release candidate * fixed typo * develop to default * delete old format in default * added format fixes in project.json * bugfixes * added cloud initiation deployment (#124) * Feature/show changelog (#126) * CLI shows changelog after update, on first run * undid changes in cli.py * renamed master to main * added suggestions * added chage suggestions * redid changelog to show diff in main branches and tags * fixed format * added changelog and versioning * feature/addedDeprecationWarnings (#132) * added project json key rewriting and addition (#122) * added project json key rewriting and addition * deleted obsolete imports * @wip generalize find key function * fixed it * bugfixed multiple core entries * Apply suggestions from code review Co-authored-by: Jan Max Meyer * added recommendations * deleted comments * deleted obsolete level in findkey * resolved conflicts --------- Co-authored-by: Jan Max Meyer * enforcing gcloud tool usage and LogIn (#135) * enforcing gcloud tool usage and LogIn * formatted file * Added hints to saeveral viur-cli commands (#144) * Update setup.cfg Co-authored-by: Sven Eberth * Bugfix/coreversion (#143) * bugfix: project.json core on level0 breaks deployment * refactor, deleted unused code * removed project.json core usage completely * removed obsolete comments * fix: remove duplicate dependency definititions --------- Co-authored-by: Sven Eberth Co-authored-by: Jan Max Meyer --- CHANGELOG.md | 2 +- setup.cfg | 10 ++++----- src/viur_cli/cloud.py | 18 +++++++++++++++ src/viur_cli/conf.py | 22 +++++++++--------- src/viur_cli/local.py | 3 +-- src/viur_cli/update.py | 51 +++++++++++++++++++----------------------- 6 files changed, 58 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb3ac49..53af5f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This file documents any relevant changes. -## [2.0.0] 2024-04-11git +## [2.0.0] 2024-04-11: - chore: added deprecation warnings - feature: Enforcing gcloud tool usage for ViUR Projects - feature: `viur gcloud init` command diff --git a/setup.cfg b/setup.cfg index 80f1384..59c2175 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,11 +20,11 @@ package_dir = packages = find: python_requires = >=3.11 install_requires = - app_server~=0.9.9 - click==8.1.7 - pipfile-requirements==0.3.0 - requests==2.31.0 - semver==3.0.2 + app_server~=0.9 + click~=8.1.7 + pipfile-requirements~=0.3 + requests~=2.31 + semver~=3.0 [options.packages.find] diff --git a/src/viur_cli/cloud.py b/src/viur_cli/cloud.py index 0f4ab97..0358b08 100644 --- a/src/viur_cli/cloud.py +++ b/src/viur_cli/cloud.py @@ -87,6 +87,14 @@ def enable_gcp_backup(): @click.argument("service", type=click.Choice(["gcloud"]), default="gcloud") @click.argument("profile", default="default") def init(service, profile): + """ + Initializes the cloud service deployment. + + Parameters: + - service (str): The cloud service to be initialized. Expected values are 'gcloud'. + - profile (str): The profile name to be used for initialization. Default value is 'default'. + + """ deployments = ["cron", "queue", "cron"] if service == "gcloud": for element in deployments: @@ -97,6 +105,15 @@ def init(service, profile): @click.argument("option", type=click.Choice(["datastore"]), default="datastore") @click.argument("profile", default="default") def cleanup(service, option, profile): + """ + Cleans up the indexes in the specified service and option. + + Parameters: + - service (str): The service to clean up the indexes for. + - option (str): The option to clean up the indexes for. + - profile (str): The profile to use for configuration. + + """ conf = config.get_profile(profile) if service == "gcloud" and option == "datastore": @@ -575,6 +592,7 @@ def deploy(action, profile, name, ext, yes, additional_args): f'gcloud app deploy --project={conf["application_name"]} {" ".join(additional_args)} {yaml_file} {"-q" if yes else ""}') + def build_deploy_command(name, conf): """ diff --git a/src/viur_cli/conf.py b/src/viur_cli/conf.py index 65a1806..d5004b6 100644 --- a/src/viur_cli/conf.py +++ b/src/viur_cli/conf.py @@ -95,7 +95,6 @@ def find_key(self, dictionary, target_key, target, keep=False): value = dictionary[target_key] else: value = dictionary.pop(target_key) - if not target: self[target_key] = value else: @@ -103,8 +102,17 @@ def find_key(self, dictionary, target_key, target, keep=False): else: for value in list(dictionary.values()): if isinstance(value, dict): + self.find_key(value, target_key, target, keep=keep) + def remove_key(self, dictionary, target_key): + if target_key in dictionary: + del dictionary[target_key] + + for value in list(dictionary.values()): + if isinstance(value, dict): + self.remove_key(value, target_key) + def migrate(self): if "application_name" not in self["default"]: @@ -112,9 +120,7 @@ def migrate(self): if "application_name" in self: del self["application_name"] - #check if core is in any profile - if "core" not in self: - self.find_key(self, target_key="core", target=None) + self.remove_key(self, target_key="core") if old_format := self["default"].get("format"): @@ -202,15 +208,7 @@ def migrate(self): :return: None """ - try: - result = os.popen('pip list --format=json').read() - core_version = [x for x in json.loads(result) if x["name"] == "viur-core"][0]["version"] - self["core"] = core_version - - except: - self["core"] = "submodule" - # conf updates must increase format version self.save() diff --git a/src/viur_cli/local.py b/src/viur_cli/local.py index 34bc8f3..8e01652 100644 --- a/src/viur_cli/local.py +++ b/src/viur_cli/local.py @@ -37,7 +37,6 @@ def run(profile, additional_args): """ Start your application locally. The 'run' command launches your ViUR application locally specified configuration and optional arguments. - This Enforces the Usage of gcloud tool """ try: @@ -157,7 +156,7 @@ def env(profile): else: click.echo(f"{failed_icon} gcloud") - click.echo(f"Your default gcloud user Info:") + click.echo(f"\nYour default gcloud user Info:\n--------------------------------") for k, v in get_user_info().items(): click.echo(f"{k}: {v}") diff --git a/src/viur_cli/update.py b/src/viur_cli/update.py index a4d1165..20bdc4d 100644 --- a/src/viur_cli/update.py +++ b/src/viur_cli/update.py @@ -3,7 +3,7 @@ import sys import re from .conf import config -from . import cli, echo_error, echo_positive, echo_info, utils +from . import cli, echo_error, echo_info, utils @cli.command(context_settings={"ignore_unknown_options": True}) @@ -20,20 +20,14 @@ def update(action, profile, additional_args): that the specified project configuration exists. Note: - - Ensure that the specified project configuration ('name') is valid and defined in your project's configuration. - - Additional arguments can be used to customize the update process if supported by the action. - """ - conf = config.get_profile(profile) if action == "requirements": create_req(True, profile) - - def create_req(yes, profile, confirm_value=True): """ Load project's pipenv and build a requirements.txt. @@ -53,27 +47,28 @@ def create_req(yes, profile, confirm_value=True): """ conf = config.get_profile(profile) dist_folder = conf["distribution_folder"] - if conf["core"] != "submodule": - if yes or click.confirm( - text=f"Do you want to regenerate the requirements.txt located in the {dist_folder}?", - default=confirm_value): - os.system(f"pipfile2req --hashes > {dist_folder}/requirements.txt") - file_object = open(f"{dist_folder}/requirements.txt", 'r') - generated_requirements = file_object.read() - for line in generated_requirements.splitlines(): - if "]==" in line: - # we got a dependency with extras - generated_requirements += re.sub(r"\[.*?\]", "", line) + "\n" - file_object.close() - - file_obj = open(f"{dist_folder}/requirements.txt", 'w') - file_obj.write(generated_requirements) - file_obj.close() - echo_info("requirements.txt successfully generated") - - if check_req(f"{dist_folder}/requirements.txt"): - if not click.confirm(f"There are some depencency errors, are you sure you want to continue?"): - sys.exit(0) + + if yes or click.confirm( text=f"Do you want to regenerate the requirements.txt located in the {dist_folder}?", + default=confirm_value): + os.system(f"pipfile2req --hashes > {dist_folder}/requirements.txt") + file_object = open(f"{dist_folder}/requirements.txt", 'r') + generated_requirements = file_object.read() + + for line in generated_requirements.splitlines(): + if "]==" in line: + # we got a dependency with extras + generated_requirements += re.sub(r"\[.*?\]", "", line) + "\n" + file_object.close() + + + file_obj = open(f"{dist_folder}/requirements.txt", 'w') + file_obj.write(generated_requirements) + file_obj.close() + echo_info("requirements.txt successfully generated") + + if check_req(f"{dist_folder}/requirements.txt"): + if not click.confirm(f"There are some depencency errors, are you sure you want to continue?"): + sys.exit(0) def check_req(projects_requirements_path):