use dda-python-teraform instead of outdated python-terraform

This commit is contained in:
jem 2021-06-25 17:15:42 +02:00
parent 8e204af9a4
commit 1fea3afa73
7 changed files with 11 additions and 59 deletions

View file

@ -20,11 +20,11 @@ jobs:
- name: install dependencies - name: install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install pybuilder ddadevops deprecation setuptools pip install -r requirements.txt
- name: build stable release - name: build stable release
env: env:
TWINE_USERNAME: dda TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_DDA }} TWINE_PASSWORD: ${{ secrets.PYPI_DDA }}
run: | run: |
pyb -P version=${{ github.ref }} publish upload pyb -P version=${{ github.ref }} publish upload

View file

@ -20,11 +20,11 @@ jobs:
- name: install dependencies - name: install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install pybuilder ddadevops deprecation setuptools pip install -r requirements.txt
- name: build unstable release - name: build unstable release
env: env:
TWINE_USERNAME: dda TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_DDA }} TWINE_PASSWORD: ${{ secrets.PYPI_DDA }}
run: | run: |
pyb publish upload pyb publish upload

View file

@ -1,7 +0,0 @@
language: python
python:
- "3.7"
before_script: sudo apt-get install pychecker
install: pip install pybuilder
script: pyb clean install_dependencies publish

View file

@ -25,7 +25,7 @@ pip3 install pybuilder ddadevops deprecation --user
export PATH=$PATH:~/.local/bin export PATH=$PATH:~/.local/bin
# in case of using terraform # in case of using terraform
pip3 install python-terraform --user pip3 install dda-python-terraform --user
# in case of using AwsMixin # in case of using AwsMixin
pip3 install boto3 --user pip3 install boto3 --user

4
requirements.txt Normal file
View file

@ -0,0 +1,4 @@
pybuilder
ddadevops
deprecation
setuptools

View file

@ -6,7 +6,7 @@ terraform, dda-pallet, aws & hetzner-cloud.
from .credential import gopass_credential_from_env_path, gopass_credential_from_path, gopass_password_from_path, gopass_field_from_path from .credential import gopass_credential_from_env_path, gopass_credential_from_path, gopass_password_from_path, gopass_field_from_path
from .devops_build import DevopsBuild, create_devops_build_config, get_devops_build, get_tag_from_latest_commit from .devops_build import DevopsBuild, create_devops_build_config, get_devops_build, get_tag_from_latest_commit
from .devops_terraform_build import WorkaroundTerraform, DevopsTerraformBuild, create_devops_terraform_build_config from .devops_terraform_build import DevopsTerraformBuild, create_devops_terraform_build_config
from .devops_docker_build import DevopsDockerBuild, create_devops_docker_build_config from .devops_docker_build import DevopsDockerBuild, create_devops_docker_build_config
from .hetzner_mixin import HetznerMixin, add_hetzner_mixin_config from .hetzner_mixin import HetznerMixin, add_hetzner_mixin_config
from .aws_backend_properties_mixin import AwsBackendPropertiesMixin, add_aws_backend_properties_mixin_config from .aws_backend_properties_mixin import AwsBackendPropertiesMixin, add_aws_backend_properties_mixin_config

View file

@ -5,7 +5,6 @@ from pkg_resources import *
from python_terraform import * from python_terraform import *
from .python_util import filter_none from .python_util import filter_none
from .devops_build import DevopsBuild, create_devops_build_config from .devops_build import DevopsBuild, create_devops_build_config
from typing import Optional
import sys import sys
@ -33,50 +32,6 @@ def create_devops_terraform_build_config(stage,
'additional_tfvar_files': additional_tfvar_files}) 'additional_tfvar_files': additional_tfvar_files})
return ret return ret
class WorkaroundTerraform(Terraform):
def __init__(self, working_dir=None,
targets=None,
state=None,
variables=None,
parallelism=None,
var_file=None,
terraform_bin_path=None,
is_env_vars_included=True,
):
super().__init__(working_dir, targets, state, variables, parallelism,
var_file, terraform_bin_path, is_env_vars_included)
self.latest_cmd = ''
def refresh(
self,
dir_or_plan: Optional[str] = None,
input: bool = False,
no_color: Type[TerraformFlag] = IsFlagged,
**kwargs,
) -> CommandOutput:
"""Refer to https://terraform.io/docs/commands/refresh.html
no-color is flagged by default
:param no_color: disable color of stdout
:param input: disable prompt for a missing variable
:param dir_or_plan: folder relative to working folder
:param kwargs: same as kwags in method 'cmd'
:returns return_code, stdout, stderr
"""
default = kwargs.copy()
default["input"] = input
default["no_color"] = no_color
option_dict = self._generate_default_options(default)
args = self._generate_default_args(dir_or_plan)
return self.cmd("refresh", *args, **option_dict)
def generate_cmd_string(self, cmd, *args, **kwargs):
result = super().generate_cmd_string(cmd, *args, **kwargs)
self.latest_cmd = ' '.join(result)
return result
class DevopsTerraformBuild(DevopsBuild): class DevopsTerraformBuild(DevopsBuild):
def __init__(self, project, config): def __init__(self, project, config):
@ -140,7 +95,7 @@ class DevopsTerraformBuild(DevopsBuild):
self.rescue_local_state() self.rescue_local_state()
def init_client(self): def init_client(self):
tf = WorkaroundTerraform(working_dir=self.build_path()) tf = Terraform(working_dir=self.build_path())
tf.init() tf.init()
self.print_terraform_command(tf) self.print_terraform_command(tf)
if self.use_workspace: if self.use_workspace: