class CronKubernetes::Context::Kubectl

Kubeclient Context from `kubectl` config file.

Public Instance Methods

applicable?() click to toggle source
# File lib/cron_kubernetes/context/kubectl.rb, line 7
def applicable?
  File.exist?(kubeconfig)
end
context() click to toggle source
# File lib/cron_kubernetes/context/kubectl.rb, line 11
def context
  config = Kubeclient::Config.read(kubeconfig)

  CronKubernetes::KubeclientContext::Context.new(
      config.context.api_endpoint,
      config.context.api_version,
      config.context.namespace,
      auth_options: auth_options(config),
      ssl_options:  config.context.ssl_options
  )
end

Private Instance Methods

auth_options(config) click to toggle source
# File lib/cron_kubernetes/context/kubectl.rb, line 29
def auth_options(config)
  options = config.context.auth_options
  return options unless options.empty?
  google_application_default_credentials
end
google_application_default_credentials() click to toggle source
# File lib/cron_kubernetes/context/kubectl.rb, line 35
def google_application_default_credentials
  return unless defined?(Google) && defined?(Google::Auth)
  {bearer_token: Kubeclient::GoogleApplicationDefaultCredentials.token}
end
kubeconfig() click to toggle source
# File lib/cron_kubernetes/context/kubectl.rb, line 25
def kubeconfig
  File.join(ENV["HOME"], ".kube", "config")
end