Class: Kubeclient::ExecCredentials
- Inherits:
-
Object
- Object
- Kubeclient::ExecCredentials
- Defined in:
- lib/kubeclient/exec_credentials.rb
Overview
An exec-based client auth provide kubernetes.io/docs/reference/access-authn-authz/authentication/#configuration Inspired by github.com/kubernetes/client-go/blob/master/plugin/pkg/client/auth/exec/exec.go
Class Method Summary collapse
Class Method Details
.run(opts) ⇒ Object
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 |