[libvirt] [PATCH sandbox] docker: don't assume X-Docker-Token is set

Daniel P. Berrange berrange at redhat.com
Tue Sep 22 09:36:28 UTC 2015


On Tue, Sep 22, 2015 at 09:10:48AM +0200, Cedric Bosdonnat wrote:
> On Mon, 2015-09-21 at 22:12 +0200, Cedric Bosdonnat wrote:
> > On Mon, 2015-09-21 at 15:12 +0100, Daniel P. Berrange wrote:
> > > The Red Hat docker registry (registry.access.redhat.com) does
> > > not set any X-Docker-Token HTTP header in its responses. Change
> > > the code so it only passes around this header if it is actually
> > > present.
> > > 
> > > Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> > > ---
> > >  libvirt-sandbox/image/sources/DockerSource.py | 12 ++++++++----
> > >  1 file changed, 8 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/libvirt-sandbox/image/sources/DockerSource.py b/libvirt-sandbox/image/sources/DockerSource.py
> > > index f367c8f..78b2a53 100644
> > > --- a/libvirt-sandbox/image/sources/DockerSource.py
> > > +++ b/libvirt-sandbox/image/sources/DockerSource.py
> > > @@ -83,10 +83,14 @@ class DockerSource(Source):
> > >          checksums = {}
> > >          for layer in data:
> > >              pass
> > > +
> > > +        headers = {}
> > > +        if token is not None:
> > > +            headers["Authorization"] = "Token" + token

I accidentally lost the trailing space after the word "Token"

> > >          (data, res) = self._get_json(template,
> > >                                       registryendpoint,
> > >                                       "/v1/repositories" + template.path + "/tags",
> > > -                                     { "Authorization": "Token " + token })
> > > +                                     headers)

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list