Skip to content

Commit

Permalink
Version 1.3.0 bump + changelog + maintainer update + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dirtycajunrice committed Feb 25, 2019
1 parent 0d54908 commit b970ead
Show file tree
Hide file tree
Showing 7 changed files with 435 additions and 70 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM amd64/python:3.7.2-alpine

LABEL maintainers="dirtycajunrice,circa10a,tkdeviant"
LABEL maintainers="dirtycajunrice,circa10a"

ENV TZ UTC

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM arm32v6/python:3.7.2-alpine

LABEL maintainers="dirtycajunrice,circa10a,tkdeviant"
LABEL maintainers="dirtycajunrice,circa10a"

ENV TZ UTC

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM arm64v8/python:3.7.2-alpine

LABEL maintainers="dirtycajunrice,circa10a,tkdeviant"
LABEL maintainers="dirtycajunrice,circa10a"

ENV TZ UTC

Expand Down
454 changes: 409 additions & 45 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyouroboros/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = "1.2.2"
BRANCH = "develop"
VERSION = "1.3.0"
BRANCH = "master"
26 changes: 6 additions & 20 deletions pyouroboros/dockerclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from os.path import isdir, isfile, join
from docker.errors import DockerException, APIError, NotFound

from pyouroboros.helpers import set_properties
from pyouroboros.helpers import set_properties, remove_sha_prefix, get_digest


class Docker(object):
Expand Down Expand Up @@ -66,8 +66,6 @@ def __init__(self, docker_client):
self.data_manager.total_updated[self.socket] = 0
self.notification_manager = self.docker.notification_manager

self.monitored = self.monitor_filter()

def _pull(self, tag):
"""Docker pull image tag"""
self.logger.debug('Checking tag: %s', tag)
Expand All @@ -77,7 +75,7 @@ def _pull(self, tag):
"username"), self.config.auth_json.get("password"))

if self.config.dry_run:
# The authentification doesn't work with this call
# The authentication doesn't work with this call
# See bugs https://github.com/docker/docker-py/issues/2225
return self.client.images.get_registry_data(tag)
else:
Expand Down Expand Up @@ -106,6 +104,7 @@ def _pull(self, tag):
class Container(BaseImageObject):
def __init__(self, docker_client):
super().__init__(docker_client)
self.monitored = self.monitor_filter()

# Container sub functions
def stop(self, container):
Expand Down Expand Up @@ -375,6 +374,7 @@ def update_self(self, count=None, old_container=None, me_list=None, new_image=No
class Service(BaseImageObject):
def __init__(self, docker_client):
super().__init__(docker_client)
self.monitored = self.monitor_filter()

def monitor_filter(self):
"""Return filtered service objects list"""
Expand All @@ -396,20 +396,6 @@ def pull(self, tag):
"""Docker pull image tag"""
return self._pull(tag)

def _remove_sha_prefix(self, digest):
if digest.startswith("sha256:"):
return digest[7:]
return digest

def _get_digest(self, image):
digest = image.attrs.get(
"Descriptor", {}
).get("digest") or image.attrs.get(
"RepoDigests"
)[0].split('@')[1] or image.id

return self._remove_sha_prefix(digest)

def update(self):
updated_service_tuples = []
self.monitored = self.monitor_filter()
Expand All @@ -421,7 +407,7 @@ def update(self):
image_string = service.attrs['Spec']['TaskTemplate']['ContainerSpec']['Image']
if '@' in image_string:
tag = image_string.split('@')[0]
sha256 = self._remove_sha_prefix(image_string.split('@')[1])
sha256 = remove_sha_prefix(image_string.split('@')[1])
else:
self.logger.error('No image SHA for %s. Skipping', image_string)
continue
Expand All @@ -431,7 +417,7 @@ def update(self):
except ConnectionError:
continue

latest_image_sha256 = self._get_digest(latest_image)
latest_image_sha256 = get_digest(latest_image)
self.logger.debug('Latest sha256 for %s is %s', tag, latest_image_sha256)

if sha256 != latest_image_sha256:
Expand Down
15 changes: 15 additions & 0 deletions pyouroboros/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ def set_properties(old, new, self_name=None):
}

return properties


def remove_sha_prefix(digest):
if digest.startswith("sha256:"):
return digest[7:]
return digest


def get_digest(image):
digest = image.attrs.get(
"Descriptor", {}
).get("digest") or image.attrs.get(
"RepoDigests"
)[0].split('@')[1] or image.id
return remove_sha_prefix(digest)

0 comments on commit b970ead

Please sign in to comment.