Module: InspecPlugins::Compliance::API::Login

Included in:
InspecPlugins::Compliance::API
Defined in:
lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb

Defined Under Namespace

Modules: Automate2Server, AutomateServer, ComplianceServer Classes: CannotDetermineServerType

Instance Method Summary collapse

Instance Method Details

#login(options) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb', line 9

def (options)
  raise ArgumentError, 'Please specify a server using `inspec compliance login https://SERVER`' unless options['server']

  options['server'] = URI("https://#{options['server']}").to_s if URI(options['server']).scheme.nil?

  options['server_type'] = InspecPlugins::Compliance::API.determine_server_type(options['server'], options['insecure'])

  case options['server_type']
  when :automate2
    Login::Automate2Server.(options)
  when :automate
    Login::AutomateServer.(options)
  when :compliance
    Login::ComplianceServer.(options)
  else
    raise CannotDetermineServerType, "Unable to determine if #{options['server']} is a Chef Automate or Chef Compliance server"
  end
end