Sha256: 7a4667764cdc1d3163de8b2ea8f85ec5cbbe0b0a5d8a018e3aacbb86e8618c14

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 KB

Contents

require "log4r"

module VagrantPlugins
  module DockerProvider
    module Action
      class Login
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new("vagrant::docker::login")
        end

        def login(env, config, driver)
          # Login!
          env[:ui].output(I18n.t("docker_provider.logging_in"))
          driver.login(
            config.email, config.username,
            config.password, config.auth_server)

          # Continue, so that the auth is protected
          # from meddling.
          @app.call(env)

          # Log out
          driver.logout(config.auth_server)
        end

        def call(env)
          config = env[:machine].provider_config
          driver = env[:machine].provider.driver

          # If we don't have a password set, don't auth
          return @app.call(env) if config.password == ""

          if !env[:machine].provider.host_vm?
            # no host vm in use, using docker directly
            login(env, config, driver)
          else
            # Grab a host VM lock to do the login so that we only login
            # once per container for the rest of this process.
            env[:machine].provider.host_vm_lock do
              login(env, config, driver)
            end
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/providers/docker/action/login.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/providers/docker/action/login.rb
vagrant-unbundled-2.3.3.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.3.2.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.19.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.18.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.16.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.14.0 plugins/providers/docker/action/login.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.10.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.9.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.8.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.7.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.6.2 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.6.1 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.6.0 plugins/providers/docker/action/login.rb