Beispiel #1
0
    def last_build_commit(self, namespace, repo, tag):
        def auth(_dxf, response):
            _dxf.authenticate(username=self.username, password=self.password, response=response, actions='*')

        try:
            dxf = DXF(host=self.registry, repo='{}/{}'.format(namespace, repo), auth=auth)
            r = dxf._request('get', 'manifests/' + tag,
                             headers={'Accept': 'application/vnd.docker.distribution.manifest.v1+json'})
            metadata = json.loads(r.content.decode('utf-8'))
            return json.loads(metadata['history'][0]['v1Compatibility'])['config']['Labels']['org.label-schema.vcs-ref']
        except Exception as e:
            print("last_build_commit failed: {}".format(e))
            return None
Beispiel #2
0
def last_build_commit(repo, tag):
    try:
        dxf = DXF(host=registry, repo='%s/%s' % (namespace, repo), auth=auth)
        r = dxf._request(
            'get',
            'manifests/' + tag,
            headers={
                'Accept':
                'application/vnd.docker.distribution.manifest.v1+json'
            })
        metadata = json.loads(r.content.decode('utf-8'))
        return json.loads(
            metadata['history'][0]
            ['v1Compatibility'])['config']['Labels'][last_commit_label]
    except:
        return None