Use execute

merge-requests/17/head
erik 12 months ago
parent 1cc7221c44
commit d2bc3cd9f3

@ -53,37 +53,37 @@ class ImageApi:
self.execution_api = ExecutionApi()
def image(self, name: str, path: Path):
self.execution_api.run_handled(
self.execution_api.execute(
f"docker build -t {name} --file {path}/image/Dockerfile {path}/image"
)
def drun(self, name: str):
self.execution_api.run_handled(
self.execution_api.execute(
f'docker run -it --entrypoint="" {name} /bin/bash'
)
def dockerhub_login(self, username: str, password: str):
self.execution_api.run_handled(
self.execution_api.execute(
f"docker login --username {username} --password {password}"
)
def dockerhub_publish(self, name: str, username: str, tag=None):
if tag is not None:
self.execution_api.run_handled(
self.execution_api.execute(
f"docker tag {name} {username}/{name}:{tag}"
)
self.execution_api.run_handled(
self.execution_api.execute(
f"docker push {username}/{name}:{tag}"
)
self.execution_api.run_handled(
self.execution_api.execute(
f"docker tag {name} {username}/{name}:latest"
)
self.execution_api.run_handled(
self.execution_api.execute(
f"docker push {username}/{name}:latest"
)
def test(self, name: str, path: Path):
self.execution_api.run_handled(
self.execution_api.execute(
f"docker build -t {name} -test --file {path}/test/Dockerfile {path}/test"
)
@ -111,18 +111,6 @@ class ExecutionApi:
process.stdout.close()
process.wait()
def run_handled(self, command: str, shell=True, check=True):
try:
run(
command,
shell=shell,
check=check,
capture_output=True,
text=True)
except CalledProcessError as exc:
print("Command failed with code: ", exc.returncode, " and message:", exc.stderr)
raise CalledProcessError
class EnvironmentApi:
def get(self, key):

Loading…
Cancel
Save