Skip to content

Commit

Permalink
Fixed KV; Updated ProcRun
Browse files Browse the repository at this point in the history
  • Loading branch information
marlinspike committed Jan 23, 2022
1 parent 70ce293 commit 65d3d13
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ venv
.vscode
working
.DS_Store
_test.py
_test.log

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ RUN apt-get update && apt-get install -y \
gettext-base \
&& rm -rf /var/lib/apt/lists/*

#Fixing KeyVault bug in AZ CLI (issue/13507)
RUN pip3 uninstall azure-keyvault && \
pip3 install azure-keyvault==1.1.0

#Terraform
RUN wget https://releases.hashicorp.com/terraform/1.1.4/terraform_1.1.4_linux_amd64.zip
RUN unzip terraform*.zip
Expand All @@ -52,6 +56,12 @@ RUN curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/v${KU
#SOPS
ADD https://github.com/mozilla/sops/releases/download/v${SOPS_VER}/sops-v${SOPS_VER}.linux /usr/local/bin/sops

#AZCopy
RUN set -ex \
&& curl -L -o azcopy.tar.gz https://aka.ms/downloadazcopy-v10-linux \
&& tar -xf azcopy.tar.gz --strip-components=1 \
&& mv ./azcopy /usr/local/bin

#PyBuilder
COPY . /PyBuilder
WORKDIR /PyBuilder
Expand Down
Binary file added img/tf_deployed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
rich
click
azure-keyvault==1.1.0
24 changes: 14 additions & 10 deletions util/streams.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from rich import print as rprint
import os
import subprocess
from subprocess import PIPE
import pathlib
import logging
log_format = '%(asctime)s %(filename)s: %(message)s'
Expand Down Expand Up @@ -59,23 +60,26 @@ def _clone_env_repo(self, dsop_customization_required: bool):
res = self._run_process(args)

def run_console(self, ):
res = self._run_process(['echo', 'Hello', 'World!'])
res = self._run_process(['ls', '-l', '-a'],True)
res = self._run_process(['echo', 'Hello', 'World!'],True)


def _run_terraform_init(self):
res = self._run_process(['terraform', f"-chdir={self.working_dir}/{self.repo_name}/example" ,'init'])

def _run_terraform(self):
res = self._run_process(['terraform', f"-chdir={self.working_dir}/{self.repo_name}/example" ,'apply', '-auto-approve'])

work_dir = f"{self.base_dir}/{self.working_dir}/{self.repo_name}/example"
args = ['terraform', f"-chdir={work_dir}", 'apply', '-auto-approve']
res = self._run_process(args)


def _run_process(self, args):
def _run_process(self, args:list, read_output:bool=False, cwd:str=""):
logger.debug(f"Running process: {locals()}")
process = subprocess.Popen(args)

stdout, stderr = process.communicate()
status = process.wait()
if stderr != None : self.cout(f"StdErr: {stderr}")
return stdout, stderr
if cwd.strip() == "":
result = subprocess.run(args, capture_output=False, text=True)
else:
result = subprocess.run(args, capture_output=True, text=True, cwd=cwd )
return result.stdout

if __name__ == '__main__':
_stream = Stream()
Expand Down

0 comments on commit 65d3d13

Please sign in to comment.