Class: VagrantPlugins::DockerLoginProvisioner::DockerLogin

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-docker-login/docker_login.rb

Instance Method Summary collapse

Constructor Details

#initialize(machine, config) ⇒ DockerLogin

Returns a new instance of DockerLogin.



6
7
8
9
# File 'lib/vagrant-docker-login/docker_login.rb', line 6

def initialize(machine, config)
  @machine = machine
  @config = config
end

Instance Method Details

#loginObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant-docker-login/docker_login.rb', line 11

def 
  @machine.ui.detail(I18n.t(:docker_login_logging_in, server: @config.server))
  @machine.communicate.tap do |comm|
    components = []
    components << "docker login"
    components << "--username=\"#{@config.username}\"" if @config.username
    components << "--email=\"#{@config.email}\"" if @config.email
    components << "--password=\"#{@config.password}\"" if @config.password
    components << "#{@config.server}" if @config.server
    command = components.join(" ")
    comm.sudo(command) do |type, data|
      handle_comm(type, data)
    end
  end
end