From 19688912d36367bd4fb165ba9bb6de654b688a70 Mon Sep 17 00:00:00 2001 From: jem Date: Fri, 6 Sep 2019 12:10:10 +0200 Subject: [PATCH] working package --- build.py | 22 ++++++++++++------- src/main/python/__init.py__ | 5 ----- src/main/python/ddadevops/__init__.py | 11 ++++++++++ src/main/python/{ => ddadevops}/credential.py | 0 src/main/python/{ => ddadevops}/dda_pallet.py | 0 .../python/{ => ddadevops}/meissa_build.py | 6 ++--- src/main/python/{ => ddadevops}/terraform.py | 17 +++++++------- 7 files changed, 37 insertions(+), 24 deletions(-) delete mode 100644 src/main/python/__init.py__ create mode 100644 src/main/python/ddadevops/__init__.py rename src/main/python/{ => ddadevops}/credential.py (100%) rename src/main/python/{ => ddadevops}/dda_pallet.py (100%) rename src/main/python/{ => ddadevops}/meissa_build.py (73%) rename src/main/python/{ => ddadevops}/terraform.py (86%) diff --git a/build.py b/build.py index 9289627..78898cd 100644 --- a/build.py +++ b/build.py @@ -1,4 +1,4 @@ -# dda-devops-build +# dda_devops_build # Copyright 2019 meissa GmbH. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,16 +17,17 @@ from pybuilder.core import init, use_plugin, Author use_plugin("python.core") +use_plugin("filter_resources") #use_plugin("python.unittest") #use_plugin("python.coverage") use_plugin("python.distutils") -use_plugin("python.install_dependencies") +#use_plugin("python.install_dependencies") default_task = "publish" -name = 'dda_devops_build' -version = "0.1.4" +name = "ddadevops" +version = "0.1.13" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" description = __doc__ authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] @@ -38,14 +39,19 @@ def initialize(project): #project.build_depends_on('mockito') #project.build_depends_on('unittest-xml-reporting') - project.set_property("dir_source_unittest_python", "src/unittest/python") - + project.set_property("verbose", True) + project.get_property("filter_resources_glob").append("**/ddadevops/__init__.py") + #project.set_property("dir_source_unittest_python", "src/unittest/python") + #project.set_property('distutils_upload_sign', True) #project.set_property('distutils_upload_sign_identity', '') - project.set_property('distutils_readme_file', 'README.md') + project.set_property("distutils_readme_description", True) + project.set_property("distutils_description_overwrite", True) project.set_property("distutils_classifiers", [ 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7',]) + 'Programming Language :: Python :: 3.7', + 'Topic :: Software Development :: Build Tools', + ]) diff --git a/src/main/python/__init.py__ b/src/main/python/__init.py__ deleted file mode 100644 index 8012c52..0000000 --- a/src/main/python/__init.py__ +++ /dev/null @@ -1,5 +0,0 @@ -from .dda_pallet import * -from .meissa_build import * -from .terraform import * - -__version__ = "${version}" \ No newline at end of file diff --git a/src/main/python/ddadevops/__init__.py b/src/main/python/ddadevops/__init__.py new file mode 100644 index 0000000..fd1a716 --- /dev/null +++ b/src/main/python/ddadevops/__init__.py @@ -0,0 +1,11 @@ +""" +ddadevops provide tools to support builds combining gopass, +terraform, dda-pallet, aws & hetzner-cloud. + +""" + +from .dda_pallet import * +from .meissa_build import * +from .terraform import * + +__version__ = "${version}" \ No newline at end of file diff --git a/src/main/python/credential.py b/src/main/python/ddadevops/credential.py similarity index 100% rename from src/main/python/credential.py rename to src/main/python/ddadevops/credential.py diff --git a/src/main/python/dda_pallet.py b/src/main/python/ddadevops/dda_pallet.py similarity index 100% rename from src/main/python/dda_pallet.py rename to src/main/python/ddadevops/dda_pallet.py diff --git a/src/main/python/meissa_build.py b/src/main/python/ddadevops/meissa_build.py similarity index 73% rename from src/main/python/meissa_build.py rename to src/main/python/ddadevops/meissa_build.py index 0f45a25..f837f4d 100644 --- a/src/main/python/meissa_build.py +++ b/src/main/python/ddadevops/meissa_build.py @@ -1,12 +1,12 @@ -import credential import os +from .credential import gopass_credential_from_env_path def init_project(project): project.set_property('stage', os.environ.get('STAGE', 'intergation')) project.set_property('http_net_api_key', - credential.gopass_credential_from_env_path('HTTP_NET_API_KEY_PATH')) + gopass_credential_from_env_path('HTTP_NET_API_KEY_PATH')) project.set_property('hetzner_api_key', - credential.gopass_credential_from_env_path('HETZNER_API_KEY_PATH')) + gopass_credential_from_env_path('HETZNER_API_KEY_PATH')) def hetzner_api_key(project): return project.get_property('hetzner_api_key') diff --git a/src/main/python/terraform.py b/src/main/python/ddadevops/terraform.py similarity index 86% rename from src/main/python/terraform.py rename to src/main/python/ddadevops/terraform.py index cb5215a..a9007d0 100644 --- a/src/main/python/terraform.py +++ b/src/main/python/ddadevops/terraform.py @@ -1,8 +1,9 @@ -from subprocess import check_output, call, Popen, PIPE import os import sys import json -import meissa_build + +from subprocess import check_output, call, Popen, PIPE +from .meissa_build import stage, hetzner_api_key, tf_import_name, tf_import_resource APPLY_PLAN = "proposed_apply.plan" DESTROY_PLAN = "proposed_destroy.plan" @@ -43,9 +44,9 @@ def terraform(cmd, credentials=None, options=None): def init(project): terraform(TF_INIT_CMD) try: - terraform(TF_SELECT_WORKSPACE_CMD, None, [meissa_build.stage(project)]) + terraform(TF_SELECT_WORKSPACE_CMD, None, [stage(project)]) except: - terraform(TF_NEW_WORKSPACE_CMD, None, [meissa_build.stage(project)]) + terraform(TF_NEW_WORKSPACE_CMD, None, [stage(project)]) def write_output(): output = terraform(TF_OUTPUT_CMD) @@ -57,10 +58,10 @@ def read_output_json(): return json.load(f) def get_hetzner_api_key_as_var(project): - hetzner_api_key = meissa_build.hetzner_api_key(project) + my_hetzner_api_key = hetzner_api_key(project) ret = [] - if hetzner_api_key: - ret.extend(['-var', 'hetzner_api_key=' + hetzner_api_key]) + if my_hetzner_api_key: + ret.extend(['-var', 'hetzner_api_key=' + my_hetzner_api_key]) return ret def plan_apply(project): @@ -69,7 +70,7 @@ def plan_apply(project): def tf_import(project): init(project) - terraform(TF_IMPORT_CMD, get_hetzner_api_key_as_var(project), [meissa_build.tf_import_name(project), meissa_build.tf_import_resource(project)]) + terraform(TF_IMPORT_CMD, get_hetzner_api_key_as_var(project), [tf_import_name(project), tf_import_resource(project)]) def plan_destroy(project): init(project)