From 52d66baadb25b4f68f70bbbbf415a673e4b6ab5f Mon Sep 17 00:00:00 2001 From: jem Date: Tue, 3 Mar 2020 10:20:18 +0100 Subject: [PATCH] rename & use class --- src/main/python/ddadevops/build.py | 47 ----------------------- src/main/python/ddadevops/devops_build.py | 31 +++++++++++++++ 2 files changed, 31 insertions(+), 47 deletions(-) delete mode 100644 src/main/python/ddadevops/build.py create mode 100644 src/main/python/ddadevops/devops_build.py diff --git a/src/main/python/ddadevops/build.py b/src/main/python/ddadevops/build.py deleted file mode 100644 index 682dc4c..0000000 --- a/src/main/python/ddadevops/build.py +++ /dev/null @@ -1,47 +0,0 @@ -import os -from .credential import gopass_credential_from_env_path -from subprocess import run - -STAGE = 'stage' -PROJECT_ROOT_PATH = 'project_root_path' -BUILD_COMMONS_PATH = 'build_commons_path' -MODULE = 'module' - -def init_project(project, project_root_path, \ - build_commons_path, module): - project.set_property(STAGE, os.environ.get('STAGE', 'intergation')) - project.set_property(PROJECT_ROOT_PATH, project_root_path) - project.set_property(BUILD_COMMONS_PATH, build_commons_path) - project.set_property(MODULE, module) - return project - -def stage(project): - return project.get_property(STAGE) - -def name(project): - return project.get_property('name') - -def module(project): - return project.get_property(MODULE) - -def project_root_path(project): - return project.get_property(PROJECT_ROOT_PATH) - -def build_commons_path(project): - return project.get_property(BUILD_COMMONS_PATH) - -def build_target_path(project): - return project_root_path(project) + 'target/' + project.name + '/' - -def tf_import_name(project): - return project.get_property('tf_import_name') - -def tf_import_resource(project): - return project.get_property('tf_import_resource') - -def initialize_target(project): - run('rm -rf ' + build_target_path(project), shell=True) - run('mkdir -p ' + build_target_path(project), shell=True) - run('cp *.tf ' + build_target_path(project), shell=True) - run('cp *.tfars ' + build_target_path(project), shell=True) - run('cp *.edn ' + build_target_path(project), shell=True) diff --git a/src/main/python/ddadevops/devops_build.py b/src/main/python/ddadevops/devops_build.py new file mode 100644 index 0000000..8c84ca3 --- /dev/null +++ b/src/main/python/ddadevops/devops_build.py @@ -0,0 +1,31 @@ +from .credential import gopass_credential_from_env_path +from subprocess import run + +class DevopsBuild: + + def __init__(self, project, project_root_path, build_commons_path, module, stage): + self.stage = stage + self.project_root_path = project_root_path + self.build_commons_path = build_commons_path + self.module = module + self.project = project + self.build_dir_name = 'target' + project.set_property("devops_build", self) + + def name(self): + return self.project.get_property('name') + + def build_path(self): + return self.project_root_path + self.build_dir_name + '/' + self.module + '/' + + def initialize_build_dir(self): + run('rm -rf ' + self.build_path(), shell=True) + run('mkdir -p ' + self.build_path(), shell=True) + + +def tf_import_name(project): + return project.get_property('tf_import_name') + +def tf_import_resource(project): + return project.get_property('tf_import_resource') +