Class: K8y::REST::Auth::Providers::GCP::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/k8y/rest/auth/providers/gcp/factory.rb

Instance Method Summary collapse

Instance Method Details

#from_auth_provider(provider) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/k8y/rest/auth/providers/gcp/factory.rb', line 14

def from_auth_provider(provider)
  config = provider.config
  # see https://github.com/kubernetes/client-go/blob/master/plugin/pkg/client/auth/gcp/gcp.go#L58
  if config&.public_send(:"cmd-path")
    CommandProvider.new(
      access_token: config.public_send(:"access-token"),
      cmd_args: config.public_send(:"cmd-args"),
      cmd_path: config.public_send(:"cmd-path"),
      expiry: config.expiry,
      expiry_key: config.public_send(:"expiry-key"),
      token_key: config.public_send(:"token-key"),
    )
  else
    ApplicationDefaultProvider.new
  end
end