Skip to content

Update github.com/docker/cli dependency

Steve Xuereb requested to merge update-docker-cli-lib into master

What does this MR do?

What: Update to the latest version of github.com/docker/cli. The only usage that we have for github.com/docker/cli is for helpers/docker/auth.

Changes: We are using it for github.com/docker/cli/cli/config/configfile which the struct hasn't changed much (check the diff in the vendor directory) and github.com/docker/cli/cli/config/credentials which also didn't change.

The biggest change is that github.com/docker/cli start using its own AuthConfig struct instead of the one from github.com/moby/moby and they are identical structs. This requires us to change the import type from github.com/docker/docker/api/types to github.com/docker/cli/cli/config/types. This was done by Docker in https://github.com/docker/cli/commit/27b2797f7deb3ca5b7f80371d825113deb1faca1 to remove the dependecy from github.com/moby/moby.

Why was this MR needed?

This is part of the ongoing effort to support GPUs in GitLab Docker executor which requires us to parse the gpu string, and we need to update this library so we get access to opts/gpus

What's the best way to test this MR?

  1. Set up a private project on GitLab.com

  2. Push the alpine image to that private project

    docker push image to private registry
    $ docker login registry.gitlab.com
    
    $ docker pull alpine:3.12
    3.12: Pulling from library/alpine
    801bfaa63ef2: Pull complete
    Digest: sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436
    Status: Downloaded newer image for alpine:3.12
    docker.io/library/alpine:3.12
    
    $ docker tag alpine:3.12 registry.gitlab.com/steveazz/playground-private
    
    $ docker push registry.gitlab.com/steveazz/playground-private
    Using default tag: latest
    The push refers to repository [registry.gitlab.com/steveazz/playground-private]
    777b2c648970: Pushed
    latest: digest: sha256:074d3636ebda6dd446d0d00304c4454f468237fdacf08fb0eeac90bdbfa1bac7 size: 528
    $ docker rmi registry.gitlab.com/steveazz/playground-private

Docker executor using auth config from docker client file

  1. Start a gitlab-runner whilst still being logged in to registry.gitlab.com with the following config.toml.

    config.toml
    [[runners]]
      name = "docker"
      url = ""
      token = ""
      executor = "docker"
      environment = ["FF_NETWORK_PER_BUILD=true"]
      [runners.docker]
        tls_verify = false
        image = "alpine:3.12"
        privileged = true
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache"]
        shm_size = 0
  2. Run the following job using the private image you just pushed Screenshot_2021-01-27_at_13.54.36

  3. Run docker logout registry.gitlab.com

  4. Run the same job as before but this time it should fail. Screenshot_2021-01-27_at_14.00.11

Kubernetes executor using

  1. Start minikube minikube start

  2. SSH inside of minikube minikube ssh

  3. Loging inside of the registry docker login registry.gitlab.com

  4. Start gitlab-runner with kubernetes executor registered

  5. Run a job with the private image

    .gitlab-ci.yml
    job:
      image: registry.gitlab.com/steveazz/playground-private
      script:
      - echo "hello"
  6. You should get a successful job Screenshot_2021-01-27_at_14.42.03

  7. log out inside of the minikube container

    docker logout
    $ minikube ssh
    Last login: Wed Jan 27 13:37:38 2021 from 192.168.49.1
    docker@minikube:~$ docker logout registry.gitlab.com
    Removing login credentials for registry.gitlab.com
  8. Job should fail Screenshot_2021-01-27_at_14.45.31

Using DOCKER_AUTH_CONFIG

  1. Set up the DOCKER_AUTH_CONFIG following https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#determining-your-docker_auth_config-data

  2. Run job with the following .gitlab-ci.yml (remember to update to your own private image)

    .gitlab-ci.yml
    job:
      image: registry.gitlab.com/steveazz/playground-private
      script:
      - echo "hello"
  3. Run job Screenshot_2021-01-27_at_14.56.10

What are the relevant issue numbers?

!1955 (comment 495010465)

Edited by Steve Xuereb

Merge request reports