From e4fef8b61c5a2ee59f717ccdbc218843ee3d1dd6 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Wed, 24 May 2023 14:16:27 +0200 Subject: [PATCH] add a terraform api --- .../python/ddadevops/infrastructure/__init__.py | 1 + .../ddadevops/infrastructure/infrastructure.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/python/ddadevops/infrastructure/__init__.py b/src/main/python/ddadevops/infrastructure/__init__.py index a0e975e..1bb11b5 100644 --- a/src/main/python/ddadevops/infrastructure/__init__.py +++ b/src/main/python/ddadevops/infrastructure/__init__.py @@ -6,5 +6,6 @@ from .infrastructure import ( EnvironmentApi, CredentialsApi, GitApi, + TerraformApi, ) from .repository import DevopsRepository, BuildFileRepository diff --git a/src/main/python/ddadevops/infrastructure/infrastructure.py b/src/main/python/ddadevops/infrastructure/infrastructure.py index 814660e..6cef62f 100644 --- a/src/main/python/ddadevops/infrastructure/infrastructure.py +++ b/src/main/python/ddadevops/infrastructure/infrastructure.py @@ -8,7 +8,7 @@ import yaml class ResourceApi: def read_resource(self, path: str) -> bytes: - return resource_string('ddadevops', path) + return resource_string("ddadevops", path) class FileApi: @@ -19,6 +19,9 @@ class FileApi: self.execution_api.execute("rm -rf " + directory) self.execution_api.execute("mkdir -p " + directory) + def cp(self, src: str, target_dir: str): + self.execution_api.execute(f"cp {src} {target_dir}") + def cp_force(self, src: str, target_dir: str): self.execution_api.execute("cp -f " + src + "* " + target_dir) @@ -122,7 +125,9 @@ class CredentialsApi: credential = None if path and field: print("get field for: " + path + ", " + field) - credential = self.execution_api.execute(["gopass", "show", path, field], shell=False) + credential = self.execution_api.execute( + ["gopass", "show", path, field], shell=False + ) return credential def gopass_password_from_path(self, path): @@ -182,3 +187,7 @@ class GitApi: def checkout(self, branch: str): return self.execution_api.execute(f"git checkout {branch}") + + +class TerraformApi: + pass