Method: KubernetesCLI#version

Defined in:
lib/kubernetes-cli.rb

#versionObject

T::Sig::WithoutRuntime.sig { returns(T::Hash[T.untyped, T.untyped]) }


104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/kubernetes-cli.rb', line 104

def version
  cmd = [executable, '--kubeconfig', kubeconfig_path, 'version', '-o', 'json']
  result = backticks(cmd)

  on_last_status_failure do |last_status|
    raise GetVersionError, "couldn't get version info: "\
      "kubectl exited with status code #{last_status.exitstatus}"
  end

  begin
    JSON.parse(result)
  rescue JSON::ParserError
    raise GetVersionError, "json parsing error"
  end
end