zalando-stups / pierone

STUPS' Docker registry with S3 backend, immutable tags and SCM source tracking
http://docs.stups.io/en/latest/components/pierone.html
Other
57 stars 7 forks source link

Gracefully handle URLs without scheme #63

Closed kanuku closed 8 years ago

kanuku commented 8 years ago

I can't list the artifacts in my teams namespace!

§ pierone artifacts cd

Traceback (most recent call last):
  File "/usr/local/bin/pierone", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/site-packages/pierone/cli.py", line 268, in main
    cli()
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/click/decorators.py", line 27, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/pierone/cli.py", line 145, in artifacts
    result = get_artifacts(config.get('url'), team, token)
  File "/usr/local/lib/python3.5/site-packages/pierone/cli.py", line 126, in get_artifacts
    r = request(url, '/teams/{}/artifacts'.format(team), access_token)
  File "/usr/local/lib/python3.5/site-packages/pierone/api.py", line 82, in request
    headers={'Authorization': 'Bearer {}'.format(access_token)}, timeout=10)
  File "/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 480, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 454, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 388, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.5/site-packages/requests/models.py", line 293, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.5/site-packages/requests/models.py", line 353, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'pierone.stups.zalan.do/teams/cd/artifacts': No schema supplied. Perhaps you meant http://[closed-pierone-registry]/teams/cd/artifacts?
hjacobs commented 8 years ago

Yes, this is bad behavior of our Pier One CLI, in this case, please do:

$ pierone login --url https://pierone.example.org
$ pierone artifacts myteam
hjacobs commented 8 years ago

@kanuku BTW your string replacement was only partially successful :smirk:

hjacobs commented 8 years ago

Fixed in https://github.com/zalando-stups/pierone-cli/releases/tag/1.0.14 (assuming "https" scheme if scheme is not given).