Skip to content

Commit

Permalink
log in only if we need to
Browse files Browse the repository at this point in the history
  • Loading branch information
zagy committed May 3, 2024
1 parent 7c8fe84 commit cfc5058
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/batou_ext/oci.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,6 @@ def verify(self):
self.assert_no_changes()
self.envfile.assert_no_changes()

if self.registry_address:
logintxt, _ = self.cmd(
self.expand(
dedent(
"""\
docker login \\
{%- if component.registry_user and component.registry_password %}
-u {{component.registry_user}} \\
-p {{component.registry_password}} \\
{%- endif %}
{{component.registry_address}}
"""
)
)
)

local_digest, stderr = self.cmd(
dedent(
"""\
Expand All @@ -169,6 +153,22 @@ def verify(self):
try:
valid = self._remote_manifest_cache[image_ident]
except KeyError:
if self.registry_address:
logintxt, _ = self.cmd(
self.expand(
dedent(
"""\
docker login \\
{%- if component.registry_user and component.registry_password %}
-u {{component.registry_user}} \\
-p {{component.registry_password}} \\
{%- endif %}
{{component.registry_address}}
"""
)
)
)

try:
stdout, stderr = self.cmd(
f"docker manifest inspect {image_ident}"
Expand Down

0 comments on commit cfc5058

Please sign in to comment.