-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move the api_client out of cli * Remove the line that references global api_client * Remove commented line from main test
- Loading branch information
Showing
6 changed files
with
55 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
from os import environ | ||
import logging | ||
import cli | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def check_credentials(): | ||
"""Returns dict of credentials if environment variable 'REPO_USER' and 'REPO_PASS' are set""" | ||
if environ.get('REPO_USER') and environ.get('REPO_PASS'): | ||
return {'username': environ['REPO_USER'], 'password': environ['REPO_PASS']} | ||
return {'username': environ['REPO_USER'], | ||
'password': environ['REPO_PASS']} | ||
return {} | ||
|
||
def pull_latest(image): | ||
|
||
def pull_latest(image, api_client): | ||
"""Return tag of latest image pulled""" | ||
latest_image = image['RepoTags'][0].split(':')[0] + ':latest' | ||
log.debug(f'Pulling image: {latest_image}') | ||
cli.api_client.pull(latest_image, auth_config=check_credentials()) | ||
return cli.api_client.inspect_image(latest_image) | ||
api_client.pull(latest_image, auth_config=check_credentials()) | ||
return api_client.inspect_image(latest_image) | ||
|
||
|
||
def is_up_to_date(old_sha, new_sha): | ||
"""Returns boolean if old and new image digests match""" | ||
return old_sha == new_sha | ||
|
||
def remove(old_image): | ||
|
||
def remove(old_image, api_client): | ||
"""Deletes old image after container is updated""" | ||
log.info(f"Removing image: {old_image['RepoTags'][0]}") | ||
return cli.api_client.remove_image(old_image) | ||
return api_client.remove_image(old_image) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters