Sha256: 86ce05b7ee17e6e7f25013ecc4fca052e794dc227819791f0edf269d53780e60

Contents?: true

Size: 1.08 KB

Versions: 46

Compression:

Stored size: 1.08 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 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 == ""

          # 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[:ui].output(I18n.t("docker_provider.logging_in"))
            driver.login(
              config.email, config.username,
              config.password, config.auth_server)

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

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

Version data entries

46 entries across 39 versions & 6 rubygems

Version Path
vagrant-unbundled-2.2.5.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.4.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.3.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.2.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.2.0.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.1.4.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.1.2.0 plugins/providers/docker/action/login.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/plugins/providers/docker/action/login.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/plugins/providers/docker/action/login.rb
vagrant-packet-0.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/plugins/providers/docker/action/login.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/bundler/gems/vagrant-04f7215b5e3f/plugins/providers/docker/action/login.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/bundler/gems/vagrant-04f7215b5e3f/plugins/providers/docker/action/login.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-04f7215b5e3f/plugins/providers/docker/action/login.rb
vagrant-unbundled-2.1.1.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.0.4.0 plugins/providers/docker/action/login.rb
vagrant-unbundled-2.0.3.0 plugins/providers/docker/action/login.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/plugins/providers/docker/action/login.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/plugins/providers/docker/action/login.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/plugins/providers/docker/action/login.rb
vagrant-unbundled-2.0.2.0 plugins/providers/docker/action/login.rb