vagrant-proxyconf 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +0 -4
- data/CHANGELOG.md +19 -0
- data/Gemfile +3 -0
- data/README.md +30 -0
- data/development/Dockerfile +7 -2
- data/development/Vagrantfile.example +40 -11
- data/lib/vagrant-proxyconf/action/configure_docker_proxy.rb +37 -20
- data/lib/vagrant-proxyconf/action/is_enabled.rb +18 -1
- data/lib/vagrant-proxyconf/version.rb +1 -1
- data/spec/unit/vagrant-proxyconf/action/configure_docker_proxy_spec.rb +18 -16
- data/spec/unit/vagrant-proxyconf/action/is_enabled_spec.rb +162 -12
- data/test/issues/180/.rspec +2 -0
- data/test/issues/180/Dockerfile +47 -0
- data/test/issues/180/README.md +31 -0
- data/test/issues/180/Rakefile +27 -0
- data/test/issues/180/Vagrantfile +31 -0
- data/test/issues/180/entrypoint.sh +50 -0
- data/test/issues/180/spec/default/redhat_spec.rb +15 -0
- data/test/issues/180/spec/docker_host/redhat_spec.rb +165 -0
- data/test/issues/180/spec/spec_helper.rb +43 -0
- data/test/issues/180/tinyproxy.conf +333 -0
- metadata +22 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 89c3334da0f5ca851a92f23dc388327d47dee03a
         | 
| 4 | 
            +
              data.tar.gz: 743404cd2300188be2c8fccf0dda4894b2ba8523
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2298453a51c191d77e4b927ac5be44d4d15aff00fce6a14a4c532dfb85587f7686966ae374f538583fb3ece529724990e902be06af337979f54b0cf3af5c70af
         | 
| 7 | 
            +
              data.tar.gz: 375908939f9f242efcd9d4e3b41a610017be5b9e55680d4e09b71620561f55750d0de9508b257c7c8c271881835f28703d3ecfb6113bdbd9922ffd6f14bec728
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,22 @@ | |
| 1 | 
            +
            # 2.0.2 / _Not released yet_
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # 2.0.1 / 2019-03-31
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Improvements:
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              - Check for existence of HTTP_PROXY and HTTPS_PROXY environment variables.
         | 
| 8 | 
            +
                If neither are set this plugin is automatically disabled.
         | 
| 9 | 
            +
              - Correctly uses the Tempfile pattern now via commit. 8ee2a2bb146aeb9fb1b27c80814e9000eff34aa1
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Bug fixes:
         | 
| 12 | 
            +
              - Docker proxy conf not set the first time the provisioner is used (trusty64) - #155
         | 
| 13 | 
            +
              - Proxy doesn't work for Docker with systemd - #172
         | 
| 14 | 
            +
              - Provisioning of docker fails - #180
         | 
| 15 | 
            +
              - Docker provider: Guest-specific operations were attempted on a machine that is not ready for guest communication. - #181
         | 
| 16 | 
            +
              - Provisioning of docker fails issue 180. - #182
         | 
| 17 | 
            +
              - vagrant-proxyconf running on Win10 and provisioning with Docker. - #186
         | 
| 18 | 
            +
              - Cannot force to write but without configuration. - #188
         | 
| 19 | 
            +
             | 
| 1 20 | 
             
            # 2.0.0 / 2019-01-03
         | 
| 2 21 |  | 
| 3 22 | 
             
            Improvements:
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -267,6 +267,36 @@ VAGRANT_APT_HTTP_PROXY="http://proxy.example.com:8080" vagrant up | |
| 267 267 | 
             
              An excellent Vagrant plugin that shares various cache directories among similar VM instances. Should work fine together with vagrant-proxyconf.
         | 
| 268 268 |  | 
| 269 269 |  | 
| 270 | 
            +
            ## Installing a pre-release version
         | 
| 271 | 
            +
             | 
| 272 | 
            +
            * A [released](https://rubygems.org/gems/vagrant-proxyconf) pre-release version:
         | 
| 273 | 
            +
             | 
| 274 | 
            +
              ```
         | 
| 275 | 
            +
              vagrant plugin install --plugin-source https://rubygems.org/ --plugin-prerelease vagrant-proxyconf
         | 
| 276 | 
            +
              ```
         | 
| 277 | 
            +
             | 
| 278 | 
            +
            * Development version from git repository:
         | 
| 279 | 
            +
             | 
| 280 | 
            +
              ```
         | 
| 281 | 
            +
              git clone https://github.com/tmatilai/vagrant-proxyconf.git
         | 
| 282 | 
            +
              cd vagrant-proxyconf
         | 
| 283 | 
            +
             | 
| 284 | 
            +
              # Optionally check out other than the master branch
         | 
| 285 | 
            +
              git checkout <branch>
         | 
| 286 | 
            +
             | 
| 287 | 
            +
              # If you don't have Ruby installed, you can use <path/to/vagrant>/embedded/bin/gem>.
         | 
| 288 | 
            +
              # If you have Docker you can use the Ruby image:
         | 
| 289 | 
            +
              # docker run -it --rm -v ${PWD}:/usr/src/myapp -w /usr/src/myapp ruby:2.6 gem build vagrant-proxyconf.gemspec
         | 
| 290 | 
            +
              gem build vagrant-proxyconf.gemspec
         | 
| 291 | 
            +
             | 
| 292 | 
            +
              vagrant plugin install vagrant-proxyconf-*.gem
         | 
| 293 | 
            +
              ```
         | 
| 294 | 
            +
             | 
| 295 | 
            +
              Paths to Vagrant's embedded gem:
         | 
| 296 | 
            +
              * Linux: `/opt/vagrant/embedded/bin/gem`
         | 
| 297 | 
            +
              * OS X: `/Applications/Vagrant/embedded/bin/gem`
         | 
| 298 | 
            +
             | 
| 299 | 
            +
             | 
| 270 300 | 
             
            ## Development Known Issues
         | 
| 271 301 |  | 
| 272 302 |  | 
    
        data/development/Dockerfile
    CHANGED
    
    | @@ -9,13 +9,15 @@ RUN yum clean all && \ | |
| 9 9 | 
             
                  curl \
         | 
| 10 10 | 
             
                  device-mapper-persistent-data \
         | 
| 11 11 | 
             
                  git \
         | 
| 12 | 
            +
                  initscripts \
         | 
| 12 13 | 
             
                  lvm2 \
         | 
| 13 14 | 
             
                  openssh-clients \ 
         | 
| 14 15 | 
             
                  openssh-server \ 
         | 
| 15 16 | 
             
                  rsync \ 
         | 
| 16 17 | 
             
                  sudo \
         | 
| 17 18 | 
             
                  wget \
         | 
| 18 | 
            -
                  yum-utils  | 
| 19 | 
            +
                  yum-utils \ 
         | 
| 20 | 
            +
                  xfsprogs && \
         | 
| 19 21 | 
             
                yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo && \
         | 
| 20 22 | 
             
                yum clean expire-cache && \
         | 
| 21 23 | 
             
                yum install -y docker-ce && \
         | 
| @@ -31,10 +33,13 @@ RUN yum clean all && \ | |
| 31 33 | 
             
                mkdir -p /home/vagrant/.ssh && \
         | 
| 32 34 | 
             
                touch /home/vagrant/.ssh/authorized_keys
         | 
| 33 35 |  | 
| 36 | 
            +
            VOLUME [ "/sys/fs/cgroup" ]
         | 
| 37 | 
            +
             | 
| 34 38 | 
             
            RUN grep -q 'OHlnVYCzRdK8jlqm8tehUc9c9WhQ==' /home/vagrant/.ssh/authorized_keys || echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==" >> /home/vagrant/.ssh/authorized_keys && \
         | 
| 35 39 | 
             
                chmod 0600 /home/vagrant/.ssh/authorized_keys && \
         | 
| 36 40 | 
             
                chown vagrant:vagrant /home/vagrant/.ssh/authorized_keys
         | 
| 37 41 |  | 
| 38 42 | 
             
            # -e write logs to stderr
         | 
| 39 43 | 
             
            # -D run in foreground
         | 
| 40 | 
            -
            CMD ["/usr/sbin/sshd", "-e", "-D"]
         | 
| 44 | 
            +
            # CMD ["/usr/sbin/sshd", "-e", "-D"]
         | 
| 45 | 
            +
            CMD ["/usr/sbin/init"]
         | 
| @@ -133,9 +133,6 @@ Vagrant.configure('2') do |config| | |
| 133 133 | 
             
              config.vm.define "default" do |default|
         | 
| 134 134 | 
             
                # set this to true, if you want to use a global proxy
         | 
| 135 135 | 
             
                default.proxy.enabled = false if !GLOBAL_PROXY_HOST
         | 
| 136 | 
            -
                default.proxy.enabled = {
         | 
| 137 | 
            -
                  :apt => false
         | 
| 138 | 
            -
                }
         | 
| 139 136 |  | 
| 140 137 | 
             
                default.vm.box = BOX
         | 
| 141 138 |  | 
| @@ -143,6 +140,17 @@ Vagrant.configure('2') do |config| | |
| 143 140 | 
             
                default.vm.provision :shell, path: 'install-debian.sh'
         | 
| 144 141 |  | 
| 145 142 | 
             
                default.vm.network "private_network", ip: "70.70.70.10"
         | 
| 143 | 
            +
             | 
| 144 | 
            +
                default.vm.provider :virtualbox do |vb, override|
         | 
| 145 | 
            +
                  # override.proxy.enabled = ENABLE_PROXY
         | 
| 146 | 
            +
                  vb.cpus = 1
         | 
| 147 | 
            +
                  vb.memory = 1024
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                  vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ] if config.vm.box =~ /xenial|bionic/
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                  vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
         | 
| 152 | 
            +
                  vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
         | 
| 153 | 
            +
                end
         | 
| 146 154 | 
             
              end
         | 
| 147 155 |  | 
| 148 156 | 
             
              config.vm.define "centos7-client" do |centos7|
         | 
| @@ -152,16 +160,37 @@ Vagrant.configure('2') do |config| | |
| 152 160 | 
             
                centos7.vm.network "private_network", ip: "70.70.70.20"
         | 
| 153 161 |  | 
| 154 162 | 
             
                centos7.vm.provision :shell, path: 'install-c7.sh'
         | 
| 155 | 
            -
              end
         | 
| 156 163 |  | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 159 | 
            -
             | 
| 160 | 
            -
             | 
| 164 | 
            +
                config.vm.provider :virtualbox do |vb, override|
         | 
| 165 | 
            +
                  # override.proxy.enabled = ENABLE_PROXY
         | 
| 166 | 
            +
                  vb.cpus = 1
         | 
| 167 | 
            +
                  vb.memory = 1024
         | 
| 161 168 |  | 
| 162 | 
            -
             | 
| 169 | 
            +
                  vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ] if config.vm.box =~ /xenial|bionic/
         | 
| 163 170 |  | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 171 | 
            +
                  vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
         | 
| 172 | 
            +
                  vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
         | 
| 173 | 
            +
                end
         | 
| 166 174 | 
             
              end
         | 
| 175 | 
            +
             | 
| 176 | 
            +
              # config.vm.define "centos7-client" do |centos7|
         | 
| 177 | 
            +
              #   centos7.proxy.enabled = config.proxy.enabled
         | 
| 178 | 
            +
              #
         | 
| 179 | 
            +
              #   centos7.vm.provider :docker do |d|
         | 
| 180 | 
            +
              #     d.build_dir = '.'
         | 
| 181 | 
            +
              #     d.dockerfile = 'Dockerfile'
         | 
| 182 | 
            +
              #     d.has_ssh = true
         | 
| 183 | 
            +
              #     # d.pull = true
         | 
| 184 | 
            +
              #
         | 
| 185 | 
            +
              #     if SUPPORTS_DOCKER_IN_DOCKER
         | 
| 186 | 
            +
              #       d.volumes = [
         | 
| 187 | 
            +
              #         "#{DOCKER_SOCKET}:#{DOCKER_SOCKET}",
         | 
| 188 | 
            +
              #       ]
         | 
| 189 | 
            +
              #       d.create_args = [
         | 
| 190 | 
            +
              #         '--privileged',
         | 
| 191 | 
            +
              #       ]
         | 
| 192 | 
            +
              #     end
         | 
| 193 | 
            +
              #   end
         | 
| 194 | 
            +
              # end
         | 
| 195 | 
            +
             | 
| 167 196 | 
             
            end
         | 
| @@ -41,17 +41,18 @@ module VagrantPlugins | |
| 41 41 | 
             
                      return @docker_client_config_path if @docker_client_config_path
         | 
| 42 42 | 
             
                      return if !supports_config_json?
         | 
| 43 43 |  | 
| 44 | 
            -
                      @docker_client_config_path =  | 
| 44 | 
            +
                      @docker_client_config_path = tempfile(Hash.new)
         | 
| 45 45 |  | 
| 46 46 | 
             
                      @machine.communicate.tap do |comm|
         | 
| 47 47 | 
             
                        if comm.test("[ -f /etc/docker/config.json ]")
         | 
| 48 | 
            -
                           | 
| 49 | 
            -
             | 
| 50 | 
            -
                           | 
| 48 | 
            +
                          logger.info('Downloading file /etc/docker/config.json')
         | 
| 49 | 
            +
                          comm.sudo("chmod 0644 /etc/docker/config.json")
         | 
| 50 | 
            +
                          comm.download("/etc/docker/config.json", @docker_client_config_path.path)
         | 
| 51 | 
            +
                          logger.info("Downloaded /etc/docker/config.json to #{@docker_client_config_path.path}")
         | 
| 51 52 | 
             
                        end
         | 
| 52 53 | 
             
                      end
         | 
| 53 54 |  | 
| 54 | 
            -
                      @docker_client_config_path
         | 
| 55 | 
            +
                      @docker_client_config_path = @docker_client_config_path.path
         | 
| 55 56 | 
             
                    end
         | 
| 56 57 |  | 
| 57 58 | 
             
                    def update_docker_client_config
         | 
| @@ -65,24 +66,39 @@ module VagrantPlugins | |
| 65 66 | 
             
                          'default' => {}
         | 
| 66 67 | 
             
                        }
         | 
| 67 68 | 
             
                      else
         | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            -
                         | 
| 69 | 
            +
             | 
| 70 | 
            +
                        data['proxies'] = {} unless data.key?('proxies')
         | 
| 71 | 
            +
                        data['proxies']['default'] = {} unless data['proxies'].key?('default')
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                        data['proxies']['default'].delete('httpProxy')
         | 
| 74 | 
            +
                        data['proxies']['default'].delete('httpsProxy')
         | 
| 75 | 
            +
                        data['proxies']['default'].delete('noProxy')
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                        unless config.http == false || config.http == "" || config.http.nil?
         | 
| 78 | 
            +
                          data['proxies']['default']['httpProxy'] = config.http
         | 
| 79 | 
            +
                        end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                        unless config.https == false || config.https == "" || config.https.nil?
         | 
| 82 | 
            +
                          data['proxies']['default']['httpsProxy'] = config.https
         | 
| 83 | 
            +
                        end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                        unless config.no_proxy == false || config.no_proxy == "" || config.no_proxy.nil?
         | 
| 86 | 
            +
                          data['proxies']['default']['noProxy'] = config.no_proxy
         | 
| 87 | 
            +
                        end
         | 
| 88 | 
            +
             | 
| 75 89 | 
             
                      end
         | 
| 76 90 |  | 
| 77 91 | 
             
                      config_json = JSON.pretty_generate(data)
         | 
| 78 92 |  | 
| 79 | 
            -
                       | 
| 93 | 
            +
                      @docker_client_config_path = tempfile(config_json)
         | 
| 80 94 |  | 
| 81 95 | 
             
                      @machine.communicate.tap do |comm|
         | 
| 82 | 
            -
                        comm.upload(@docker_client_config_path,  | 
| 83 | 
            -
                        comm.sudo(" | 
| 96 | 
            +
                        comm.upload(@docker_client_config_path.path, "/tmp/vagrant-proxyconf-docker-config.json")
         | 
| 97 | 
            +
                        comm.sudo("mkdir -p /etc/docker")
         | 
| 98 | 
            +
                        comm.sudo("chown root:root /etc/docker")
         | 
| 99 | 
            +
                        comm.sudo("mv /tmp/vagrant-proxyconf-docker-config.json /etc/docker/config.json")
         | 
| 84 100 | 
             
                        comm.sudo("chown root:root /etc/docker/config.json")
         | 
| 85 | 
            -
                        comm.sudo("rm -f  | 
| 101 | 
            +
                        comm.sudo("rm -f /tmp/vagrant-proxyconf-docker-config.json")
         | 
| 86 102 |  | 
| 87 103 | 
             
                        comm.sudo("sed -i.bak -e '/^DOCKER_CONFIG/d' /etc/environment")
         | 
| 88 104 | 
             
                        if !disabled?
         | 
| @@ -90,8 +106,6 @@ module VagrantPlugins | |
| 90 106 | 
             
                        end
         | 
| 91 107 | 
             
                      end
         | 
| 92 108 |  | 
| 93 | 
            -
                      File.unlink(@docker_client_config_path) if File.exists?(@docker_client_config_path)
         | 
| 94 | 
            -
             | 
| 95 109 | 
             
                      config_json
         | 
| 96 110 | 
             
                    end
         | 
| 97 111 |  | 
| @@ -164,9 +178,12 @@ module VagrantPlugins | |
| 164 178 | 
             
                    end
         | 
| 165 179 |  | 
| 166 180 | 
             
                    def service_restart_command
         | 
| 167 | 
            -
                      [ | 
| 181 | 
            +
                      [
         | 
| 182 | 
            +
                        "kill -HUP `pgrep -f '#{docker}'`",
         | 
| 183 | 
            +
                        "systemctl restart #{docker}",
         | 
| 168 184 | 
             
                        "service #{docker} restart",
         | 
| 169 | 
            -
                        "/etc/init.d/#{docker} restart" | 
| 185 | 
            +
                        "/etc/init.d/#{docker} restart",
         | 
| 186 | 
            +
                      ].join(' || ')
         | 
| 170 187 | 
             
                    end
         | 
| 171 188 |  | 
| 172 189 | 
             
                    def docker_sed_script
         | 
| @@ -15,8 +15,25 @@ module VagrantPlugins | |
| 15 15 |  | 
| 16 16 | 
             
                    private
         | 
| 17 17 |  | 
| 18 | 
            +
                    def has_proxy_env_var?(var='HTTP_PROXY')
         | 
| 19 | 
            +
                      var_not_in_env = ENV[var].nil? || ENV[var] == ''
         | 
| 20 | 
            +
                      return false if var_not_in_env
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                      true
         | 
| 23 | 
            +
                    end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    def plugin_disabled?(config)
         | 
| 26 | 
            +
                      config.enabled == false || config.enabled == '' || config.enabled.nil? || config.enabled == {}
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
             | 
| 18 29 | 
             
                    def plugin_enabled?(config)
         | 
| 19 | 
            -
                       | 
| 30 | 
            +
                      return false if plugin_disabled?(config)
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                      # check for existence of HTTP_PROXY and HTTPS_PROXY environment variables
         | 
| 33 | 
            +
                      has_proxy_var = has_proxy_env_var?('HTTP_PROXY') || has_proxy_env_var?('HTTPS_PROXY')
         | 
| 34 | 
            +
                      return false if has_proxy_var == false
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                      true
         | 
| 20 37 | 
             
                    end
         | 
| 21 38 | 
             
                  end
         | 
| 22 39 | 
             
                end
         | 
| @@ -12,17 +12,19 @@ def mock_write_docker_config(machine) | |
| 12 12 | 
             
              allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /etc/default/docker.new")
         | 
| 13 13 | 
             
              allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:root /etc/default/docker.new")
         | 
| 14 14 | 
             
              allow(machine).to receive_message_chain(:communicate, :sudo).with("mv -f /etc/default/docker.new /etc/default/docker")
         | 
| 15 | 
            -
              allow(machine).to receive_message_chain(:communicate, :sudo).with("systemctl restart docker || service docker restart || /etc/init.d/docker restart")
         | 
| 15 | 
            +
              allow(machine).to receive_message_chain(:communicate, :sudo).with("kill -HUP `pgrep -f 'docker'` || systemctl restart docker || service docker restart || /etc/init.d/docker restart")
         | 
| 16 16 | 
             
              allow(machine).to receive_message_chain(:communicate, :sudo).with("rm -f /tmp/vagrant-proxyconf /etc/default/docker.new")
         | 
| 17 17 | 
             
            end
         | 
| 18 18 |  | 
| 19 | 
            -
            def mock_update_docker_client_config(machine | 
| 20 | 
            -
              allow(machine).to receive_message_chain(:communicate, :upload) | 
| 21 | 
            -
              allow(machine).to receive_message_chain(:communicate, :sudo).with("mv  | 
| 19 | 
            +
            def mock_update_docker_client_config(machine)
         | 
| 20 | 
            +
              allow(machine).to receive_message_chain(:communicate, :upload)
         | 
| 21 | 
            +
              allow(machine).to receive_message_chain(:communicate, :sudo).with("mv /tmp/vagrant-proxyconf-docker-config.json /etc/docker/config.json")
         | 
| 22 22 | 
             
              allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:root /etc/docker/config.json")
         | 
| 23 | 
            -
              allow(machine).to receive_message_chain(:communicate, :sudo).with("rm -f  | 
| 23 | 
            +
              allow(machine).to receive_message_chain(:communicate, :sudo).with("rm -f /tmp/vagrant-proxyconf-docker-config.json")
         | 
| 24 24 | 
             
              allow(machine).to receive_message_chain(:communicate, :sudo).with("sed -i.bak -e '/^DOCKER_CONFIG/d' /etc/environment")
         | 
| 25 25 | 
             
              allow(machine).to receive_message_chain(:communicate, :sudo).with("echo DOCKER_CONFIG=/etc/docker >> /etc/environment")
         | 
| 26 | 
            +
              allow(machine).to receive_message_chain(:communicate, :sudo).with("mkdir -p /etc/docker")
         | 
| 27 | 
            +
              allow(machine).to receive_message_chain(:communicate, :sudo).with("chown root:root /etc/docker")
         | 
| 26 28 | 
             
            end
         | 
| 27 29 |  | 
| 28 30 |  | 
| @@ -87,7 +89,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do | |
| 87 89 | 
             
                    allow(machine).to receive_message_chain(:config, :public_send).with(:docker_proxy).and_return(config)
         | 
| 88 90 |  | 
| 89 91 | 
             
                    mock_write_docker_config(machine)
         | 
| 90 | 
            -
                    mock_update_docker_client_config(machine | 
| 92 | 
            +
                    mock_update_docker_client_config(machine)
         | 
| 91 93 |  | 
| 92 94 | 
             
                    # update_docker_client_config mock
         | 
| 93 95 | 
             
                    allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
         | 
| @@ -95,7 +97,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do | |
| 95 97 | 
             
                    @docker_proxy = docker_proxy
         | 
| 96 98 | 
             
                  end
         | 
| 97 99 |  | 
| 98 | 
            -
                  context 'when /etc/docker/config.json has proxy configuration' do
         | 
| 100 | 
            +
                  context 'and when /etc/docker/config.json has proxy configuration' do
         | 
| 99 101 | 
             
                    before :each do
         | 
| 100 102 | 
             
                      fixture = fixture_file("docker_client_config_json_enabled_proxy")
         | 
| 101 103 | 
             
                      configure_docker_proxy(fixture)
         | 
| @@ -140,12 +142,13 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do | |
| 140 142 | 
             
                      allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
         | 
| 141 143 |  | 
| 142 144 | 
             
                      allow(machine).to receive_message_chain(:communicate, :test).with("[ -f /etc/docker/config.json ]").and_return(true)
         | 
| 143 | 
            -
                      allow(machine).to receive_message_chain(:communicate, : | 
| 145 | 
            +
                      allow(machine).to receive_message_chain(:communicate, :sudo).with("chmod 0644 /etc/docker/config.json")
         | 
| 146 | 
            +
                      allow(machine).to receive_message_chain(:communicate, :download)
         | 
| 144 147 |  | 
| 145 148 | 
             
                      docker_proxy.send(:docker_client_config_path)
         | 
| 146 149 | 
             
                    end
         | 
| 147 150 |  | 
| 148 | 
            -
                    it {  | 
| 151 | 
            +
                    it { expect(File.exists?(subject)).to eq true }
         | 
| 149 152 | 
             
                  end
         | 
| 150 153 |  | 
| 151 154 | 
             
                  context "when /etc/docker/config.json does not exist" do
         | 
| @@ -161,10 +164,9 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do | |
| 161 164 | 
             
                      docker_proxy.send(:docker_client_config_path)
         | 
| 162 165 | 
             
                    end
         | 
| 163 166 |  | 
| 164 | 
            -
                    it { is_expected.to eq "/tmp/vagrant-proxyconf-docker-config.json" }
         | 
| 165 167 | 
             
                    it do
         | 
| 166 | 
            -
                      expect(File.exists?( | 
| 167 | 
            -
                      expect(File.read( | 
| 168 | 
            +
                      expect(File.exists?(subject)).to eq true
         | 
| 169 | 
            +
                      expect(File.read(subject)).to eq "{}"
         | 
| 168 170 | 
             
                    end
         | 
| 169 171 | 
             
                  end
         | 
| 170 172 | 
             
                end
         | 
| @@ -226,7 +228,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do | |
| 226 228 | 
             
                      allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
         | 
| 227 229 | 
             
                      allow(docker_proxy).to receive(:disabled?).and_return(true)
         | 
| 228 230 |  | 
| 229 | 
            -
                      mock_update_docker_client_config(machine | 
| 231 | 
            +
                      mock_update_docker_client_config(machine)
         | 
| 230 232 |  | 
| 231 233 | 
             
                      expected = JSON.pretty_generate(
         | 
| 232 234 | 
             
                        {
         | 
| @@ -265,7 +267,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do | |
| 265 267 | 
             
                      allow(docker_proxy).to receive(:supports_config_json?).and_return(true)
         | 
| 266 268 | 
             
                      allow(docker_proxy).to receive(:disabled?).and_return(false)
         | 
| 267 269 |  | 
| 268 | 
            -
                      mock_update_docker_client_config(machine | 
| 270 | 
            +
                      mock_update_docker_client_config(machine)
         | 
| 269 271 | 
             
                      expected = JSON.pretty_generate(
         | 
| 270 272 | 
             
                        {
         | 
| 271 273 | 
             
                          "proxies" => {
         | 
| @@ -339,7 +341,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do | |
| 339 341 | 
             
                      mock_write_docker_config(machine)
         | 
| 340 342 |  | 
| 341 343 | 
             
                      # mock update_docker_client_config
         | 
| 342 | 
            -
                      mock_update_docker_client_config(machine | 
| 344 | 
            +
                      mock_update_docker_client_config(machine)
         | 
| 343 345 |  | 
| 344 346 | 
             
                      docker_proxy.send(:unconfigure_machine)
         | 
| 345 347 | 
             
                    end
         | 
| @@ -380,7 +382,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do | |
| 380 382 | 
             
                      allow(docker_proxy).to receive(:disabled?).and_return(true)
         | 
| 381 383 |  | 
| 382 384 | 
             
                      mock_write_docker_config(machine)
         | 
| 383 | 
            -
                      mock_update_docker_client_config(machine | 
| 385 | 
            +
                      mock_update_docker_client_config(machine)
         | 
| 384 386 |  | 
| 385 387 | 
             
                      docker_proxy.send(:unconfigure_machine)
         | 
| 386 388 | 
             
                    end
         |