Class: Kubeclient::GCPCommandCredentials

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

Overview

Generates a bearer token for Google Cloud Platform.

Class Method Summary collapse

Class Method Details

.token(config) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kubeclient/gcp_command_credentials.rb', line 7

def token(config)
  require 'open3'
  require 'shellwords'
  require 'json'
  require 'jsonpath'

  cmd = config['cmd-path']
  args = config['cmd-args']
  token_key = config['token-key']

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

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

  extract_token(out, token_key)
end