Class: Keel::GCloud::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/keel/gcloud/auth.rb

Overview

This is a wrapper to call authentication related APIs with GCloud.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Auth

Returns a new instance of Auth.



8
9
10
11
# File 'lib/keel/gcloud/auth.rb', line 8

def initialize config:
  @config = config
  @cli    = Cli.new
end

Instance Attribute Details

#cliObject

Returns the value of attribute cli.



6
7
8
# File 'lib/keel/gcloud/auth.rb', line 6

def cli
  @cli
end

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/keel/gcloud/auth.rb', line 6

def config
  @config
end

Class Method Details

.authenticateBoolean

Calls the ‘login` API for GCLoud.

Returns:

  • (Boolean)

    whether the call succeeded or not



18
19
20
# File 'lib/keel/gcloud/auth.rb', line 18

def self.authenticate
  Cli.new.system_call 'gcloud auth login'
end

Instance Method Details

#authenticate_k8sBoolean

Calls the ‘get-credentials` API for GCLoud for a specific container/cluster.

Returns:

  • (Boolean)

    whether the call succeeded or not



28
29
30
# File 'lib/keel/gcloud/auth.rb', line 28

def authenticate_k8s
  @cli.system_call "gcloud container clusters get-credentials #{self.config.container_cluster}"
end