docker-archive / migrator

Tool to migrate Docker images from Docker Hub or v1 registry to a v2 registry
Apache License 2.0
160 stars 82 forks source link

Refactor tag filtering #102

Closed dwlocks closed 7 years ago

dwlocks commented 7 years ago

Tag filtering was missing for private repositories. Break tag filtering out into a function and use it for both docker-hub and private repos.

mbentley commented 7 years ago

Thanks for the PR! There appears to be an issue with the tag filter though as the V1_TAG_FILTER value is excluding the specified text for the filter.

$ docker run -it --rm \
  -e V1_REGISTRY=docker.io \
  -e V2_REGISTRY=dtr.core.dckrindy.io \
  -e V1_USERNAME=migratortest \
  -e V1_PASSWORD=removed \
  -e V1_EMAIL=migrator@dckrindy.io \
  -e V2_USERNAME=demo \
  -e V2_PASSWORD=removed \
  -e V2_EMAIL=matt@docker.com \
  -e ERROR_ACTION=abort \
  -e USER_PROMPT=true \
  -e V1_REPO_FILTER=hello-world \
  -e V1_TAG_FILTER=latest \
  -v /var/run/docker.sock:/var/run/docker.sock \
  docker/migrator:test
WARNING: login credentials saved in /root/.dockercfg.
Login Succeeded

[INFO] Getting a list of images from docker.io
[INFO] Skipping migratortest/hello-world:latest
[OK] Successfully retrieved list of Docker images from docker.io

[INFO] Full list of images from docker.io to be migrated:
docker.io/migratortest/hello-world:2
[OK] End full list of images from docker.io

[!!] Press any key to begin migration process [ctrl+c to abort]

As you can see from the screen shot, there are two tags: 2 and latest. I would expect using V1_TAG_FILTER=latest would only include latest, not exclude it.

screenshot 2017-04-04 at 9 53 56 am

mbentley commented 7 years ago

The previous build from master as comparison:

$ docker run -it --rm \
  -e V1_REGISTRY=docker.io \
  -e V2_REGISTRY=dtr.core.dckrindy.io \
  -e V1_USERNAME=migratortest \
  -e V1_PASSWORD=removed \
  -e V1_EMAIL=migrator@dckrindy.io \
  -e V2_USERNAME=demo \
  -e V2_PASSWORD=removed \
  -e V2_EMAIL=matt@docker.com \
  -e ERROR_ACTION=abort \
  -e USER_PROMPT=true \
  -e V1_REPO_FILTER=hello-world \
  -e V1_TAG_FILTER=latest \
  -v /var/run/docker.sock:/var/run/docker.sock \
  docker/migrator:latest
WARNING: login credentials saved in /root/.dockercfg.
Login Succeeded

[INFO] Getting a list of images from docker.io
[OK] Successfully retrieved list of Docker images from docker.io

[INFO] Full list of images from docker.io to be migrated:
docker.io/migratortest/hello-world:latest
[OK] End full list of images from docker.io

[!!] Press any key to begin migration process [ctrl+c to abort]
dwlocks commented 7 years ago

Heh. I thought it was a "remove" filter, not an "include only" filter. I'll fix it. Would you prefer a new PR with a single commit, or a 2nd commit on this branch?

mbentley commented 7 years ago

Sorry, that wasn't very clear; feel free to add a 2nd commit to this branch; no worries there.

mbentley commented 7 years ago

Awesome, LGTM and thanks for the contribution.