Class: CM::Plugin::AuthDockerResource

Inherits:
Object
  • Object
show all
Defined in:
lib/core/plugin/auth_docker_resource.rb

Instance Method Summary collapse

Instance Method Details

#normalize(reload) ⇒ Object


Plugin interface



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/core/plugin/auth_docker_resource.rb', line 13

def normalize(reload)
  super

  if settings[:docker_username] && settings[:docker_password] && settings[:docker_email]
    begin
      Docker.authenticate!({
        'username' => settings[:docker_username],
        'password' => settings[:docker_password],
        'email' => settings[:docker_email]
      })
    rescue Docker::Error::AuthenticationError => error
      error('authentication_failed', { :error => error.message })
      raise error
    end
  else
    raise render_message('cm.resource.docker.info.no_credentials', {
      :username_option => 'docker_username',
      :password_option => 'docker_password',
      :email_option => 'docker_email'
    })
  end

  yield if block_given?
end