Class: Kubeclient::ExecCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/kubeclient/exec_credentials.rb

Overview

Class Method Summary collapse

Class Method Details

.run(opts) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kubeclient/exec_credentials.rb', line 9

def run(opts)
  require 'open3'
  require 'json'

  raise ArgumentError, 'exec options are required' if opts.nil?

  cmd = opts['command']
  args = opts['args']
  env = map_env(opts['env'])

  # Validate exec options
  validate_opts(opts)

  out, err, st = Open3.capture3(env, cmd, *args)

  raise "exec command failed: #{err}" unless st.success?

  creds = JSON.parse(out)
  validate_credentials(opts, creds)
  creds['status']
end