Fix gpg key usage when uploading config to multiple deployers
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 40s
Webapp Test / Run webapp test suite (pull_request) Successful in 5m17s
Deploy Test / Run deploy test suite (pull_request) Successful in 6m10s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Successful in 8m35s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 9m47s
Smoke Test / Run basic test suite (pull_request) Successful in 4m14s

This commit is contained in:
Prathamesh Musale 2024-10-08 12:51:35 +05:30
parent 2bf1ed5653
commit 9810b46f7f

View File

@ -97,8 +97,6 @@ def command( # noqa: C901
if env_file and config_ref:
fatal("Cannot use --env-file and --config-ref at the same time.")
tempdir = tempfile.mkdtemp()
try:
laconic = LaconicRegistryClient(laconic_config)
app_record = laconic.get_record(app)
@ -147,6 +145,7 @@ def command( # noqa: C901
if len(r.names) > 0:
target_deployer_record = r
break
print("target_deployer_record", target_deployer_record)
deployer_records.append(target_deployer_record)
else:
deployer_record = laconic.get_record(deployer)
@ -158,8 +157,10 @@ def command( # noqa: C901
# Create and send request to each deployer
deployment_requests = []
for deployer_record in deployer_records:
# If env_file
# Upload config to deployers if env_file is passed
if env_file:
tempdir = tempfile.mkdtemp()
try:
gpg = gnupg.GPG(gnupghome=tempdir)
# Import the deployer's public key
@ -194,6 +195,8 @@ def command( # noqa: C901
response.raise_for_status()
config_ref = response.json()["id"]
finally:
shutil.rmtree(tempdir, ignore_errors=True)
target_deployer = deployer
if (not deployer) and len(deployer_record.names):
@ -248,5 +251,3 @@ def command( # noqa: C901
continue
laconic.publish(deployment_request)
finally:
shutil.rmtree(tempdir, ignore_errors=True)