TritonDataCenter / node-docker-registry-client

node.js client for the docker registry
Mozilla Public License 2.0
64 stars 33 forks source link

Error: invalid repository name, may only contain [a-z0-9_.-] characters #16

Closed masakura closed 7 years ago

masakura commented 7 years ago

"docker-registry-client" can not use other than "{namepace}/{name}" image name. But, GitLab.com acknowledges image names separated by many /.

"masakura/docker-registry-client-bug-sample" works normally.

// valid.js
const drc = require('docker-registry-client');

// Valid
drc.createClientV2({
  name: 'registry.gitlab.com/masakura/docker-registry-client-bug-sample'
})
  .listTags((err, tags) => console.log(tags));
$ node valid.js 
{ name: 'masakura/docker-registry-client-bug-sample',
  tags: [ 'hello-world' ] }

However, an error occurs in "masakura/docker-registry-client-bug-sample/image".

// bug.js

const drc = require('docker-registry-client');

// Error: invalid repository name, may only contain [a-z0-9_.-] characters: docker-registry-client-bug-sample/image
drc.createClientV2({
  name: 'registry.gitlab.com/masakura/docker-registry-client-bug-sample/image'
})
  .listTags((err, tags) => console.log(tags));
$ node bug.js 
/home/masakura/repos/masakura/docker-registry-client-bug-sample/node_modules/docker-registry-client/lib/common.js:225
        throw new Error('invalid repository name, may only contain ' +
        ^

Error: invalid repository name, may only contain [a-z0-9_.-] characters: docker-registry-client-bug-sample/image
    at Object.parseRepo (/home/masakura/repos/masakura/docker-registry-client-bug-sample/node_modules/docker-registry-client/lib/common.js:225:15)
    at new RegistryClientV2 (/home/masakura/repos/masakura/docker-registry-client-bug-sample/node_modules/docker-registry-client/lib/registry-client-v2.js:998:28)
    at Object.createClient [as createClientV2] (/home/masakura/repos/masakura/docker-registry-client-bug-sample/node_modules/docker-registry-client/lib/registry-client-v2.js:1593:12)
    at Object.<anonymous> (/home/masakura/repos/masakura/docker-registry-client-bug-sample/bug.js:15:5)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)

Would you be able to work even if "/" is included in the image name?

trentm commented 7 years ago

@masakura @psychoo118 Is registry.gitlab.com/masakura/docker-registry-client-bug-sample/image a repo that I can rely on staying around? I'd love to write a test case for this. If not this repo on gitlab.com, do you know of another one there that (a) has a slash in the repo name and (b) will stay around for future runs of the test suite?

trentm commented 7 years ago

Thanks for the patch! I add a test case (using the hopefully longish-lived repo above) and commited that. This repo uses Gerrit for code review instead of PRs (I need to update the README for that) -- which is why I didn't use the PR.

Published as docker-registry-client@3.2.7