Fix gpg key usage when uploading config to multiple deployers

This commit is contained in:
Prathamesh Musale 2024-10-08 12:51:35 +05:30
parent 49a730707e
commit f8fde0f3a3

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)