class Kontena::Cli::Master::InitCloudCommand

Public Instance Methods

already_cloud_enabled?() click to toggle source
# File lib/kontena/cli/master/init_cloud_command.rb, line 31
def already_cloud_enabled?
  !current_master_cloud_config.nil?
end
current_master_cloud_config() click to toggle source
# File lib/kontena/cli/master/init_cloud_command.rb, line 21
def current_master_cloud_config
  return @cloud_config if @cloud_config
  master_client_id = master_config['oauth2.client_id']
  @cloud_config = cloud_client.get('user/masters')['data'].find { |cm| cm['attributes']['client-id'] == master_client_id }
end
current_master_cloud_name() click to toggle source
# File lib/kontena/cli/master/init_cloud_command.rb, line 27
def current_master_cloud_name
  @cloud_name ||= current_master_cloud_config.nil? ? nil : current_master_cloud_config['attributes']['name']
end
execute() click to toggle source
# File lib/kontena/cli/master/init_cloud_command.rb, line 35
def execute
  exit_with_error "Current master is already registered to use Kontena Cloud as #{pastel.cyan(current_master_cloud_name)}" if already_cloud_enabled?
  args = ["--current"]
  args << "--force" if self.force?
  args += ["--cloud-master-id", self.cloud_master_id.shellescape] if self.cloud_master_id
  args += ["--provider", self.provider.shellescape] if self.provider
  args += ["--version", self.version.shellescape] if self.version
  Kontena.run!(['cloud', 'master', 'add'] + args)
end
master_config() click to toggle source
# File lib/kontena/cli/master/init_cloud_command.rb, line 17
def master_config
  @master_config ||= client.get('config')
end