Skip to content

Commit

Permalink
fix: Use of a private registry is broken. (#20)
Browse files Browse the repository at this point in the history
* Use of a private registry is broken.
a reference of mydomain:port/myimage:tag was being changed to
mydomain:port/library/myimage:tag, which is not found in a private registry.
I removed library from the resulting image name.

* Update index.js

* cleanup
  • Loading branch information
lgfausak authored and tkyi committed Mar 9, 2018
1 parent d2c84eb commit a5c3afc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
28 changes: 24 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,32 @@ class DockerExecutor extends Executor {
* @param {String} config.token JWT for the Build
* @return {Promise}
*/

_start(config) {
const { fullname } = imageParser(config.container);
const containerNameParts = fullname.split(':');
const piecesParts = imageParser(config.container);
let buildTag = piecesParts.tag;
let buildImage = piecesParts.name;

/**
*
* the docker-parse-image returns a fullname that always contains
* a namespace, which defaults to 'library' if no namespace is specified.
* perhaps library is the historical place to put things? but,
* my private registry does not work with 'library' injected in to the
* docker image name. In other words, if I try to parse:
* 'myregistry.private.com/myimage'
* i end up with
* 'myregistry.private.com/library/myimage:latest'
* there is no library namespace in my private registry, so this fails.
*/
if (piecesParts.tag !== null && piecesParts.tag !== 'latest') {
const containerNameParts = piecesParts.name.split(':');

const buildTag = containerNameParts.pop();
const buildImage = containerNameParts.join(':');
containerNameParts.pop();
buildImage = containerNameParts.join(':');
} else {
buildTag = 'latest';
}

return Promise.all(
[
Expand Down
10 changes: 5 additions & 5 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('index', function () {

it('creates the required containers and starts them', () => {
const buildImageArgs = {
fromImage: 'library/node',
fromImage: 'node',
tag: '6'
};

Expand All @@ -207,7 +207,7 @@ describe('index', function () {
it('supports prefixed containers', () => {
const prefix = 'beta_';
const buildImageArgs = {
fromImage: 'library/node',
fromImage: 'node',
tag: '6'
};

Expand Down Expand Up @@ -292,7 +292,7 @@ describe('index', function () {

it('creates containers without specifying a tag', () => {
const buildImageArgs = {
fromImage: 'library/node',
fromImage: 'node',
tag: 'latest'
};

Expand Down Expand Up @@ -320,7 +320,7 @@ describe('index', function () {

it('creates containers from a private docker registry and starts them', () => {
const buildImageArgs = {
fromImage: 'docker-registry.foo.bar:1111/library/someImage',
fromImage: 'docker-registry.foo.bar:1111/someImage',
tag: 'latest'
};

Expand Down Expand Up @@ -348,7 +348,7 @@ describe('index', function () {

it('creates containers from a private docker registry without specifying a tag', () => {
const buildImageArgs = {
fromImage: 'docker-registry.foo.bar:1111/library/someImage',
fromImage: 'docker-registry.foo.bar:1111/someImage',
tag: 'latest'
};

Expand Down

0 comments on commit a5c3afc

Please sign in to comment.