working package

This commit is contained in:
jem 2019-09-06 12:10:10 +02:00
parent de2777d53a
commit 19688912d3
7 changed files with 37 additions and 24 deletions

View file

@ -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',
])

View file

@ -1,5 +0,0 @@
from .dda_pallet import *
from .meissa_build import *
from .terraform import *
__version__ = "${version}"

View file

@ -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}"

View file

@ -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')

View file

@ -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)