Class: KubeWrap

Inherits:
Object
  • Object
show all
Defined in:
lib/objects/node/kube_wrap.rb

Overview

Kubectl command wrapper. This will integrate directly with bcome’s GCP authentication driver

Constant Summary collapse

KUBE_BIN =
'kubectl'

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ KubeWrap

Returns a new instance of KubeWrap.



7
8
9
# File 'lib/objects/node/kube_wrap.rb', line 7

def initialize(access_token)
  @access_token = access_token
end

Instance Method Details

#create_command_for(suffix) ⇒ Object



23
24
25
# File 'lib/objects/node/kube_wrap.rb', line 23

def create_command_for(suffix)
  "#{KUBE_BIN} --token #{@access_token} #{suffix}"
end

#run(command_suffix) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/objects/node/kube_wrap.rb', line 11

def run(command_suffix)
  full_command = create_command_for(command_suffix)
  result = ::Bcome::Command::Local.run(full_command)

  if result.failed?
    puts "\n" + result.stderr.error + "\n"
    raise
  end

  result
end