Class: Seira::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/seira/setup.rb

Constant Summary collapse

SUMMARY =
"Set up your local CLI with the right project and cluster configuration.".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg:, settings:) ⇒ Setup

Returns a new instance of Setup.



10
11
12
13
# File 'lib/seira/setup.rb', line 10

def initialize(arg:, settings:)
  @arg = arg
  @settings = settings
end

Instance Attribute Details

#argObject (readonly)

Returns the value of attribute arg.



8
9
10
# File 'lib/seira/setup.rb', line 8

def arg
  @arg
end

#settingsObject (readonly)

Returns the value of attribute settings.



8
9
10
# File 'lib/seira/setup.rb', line 8

def settings
  @settings
end

Instance Method Details

#runObject

This script should be all that’s needed to fully set up gcloud and kubectl cli, fully configured, on a development machine.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/seira/setup.rb', line 17

def run
  ensure_software_installed

  if arg == 'all'
    puts "We will now set up gcloud and kubectl for each project. We use a distinct GCP Project for each environment: #{ENVIRONMENTS.join(', ')}"
    settings.valid_cluster_names.each do |cluster|
      setup_cluster(cluster)
    end
  elsif settings.valid_cluster_names.include?(arg)
    puts "We will now set up gcloud and kubectl for #{arg}"
    setup_cluster(arg)
  else
    puts "Please specify a valid cluster name or 'all'."
    exit(1)
  end

  puts "You have now configured all of your configurations. Please note that 'gcloud' and 'kubectl' are two separate command line tools."
  puts "gcloud: For manipulating GCP entities such as sql databases and kubernetes clusters themselves"
  puts "kubectl: For working within a kubernetes cluster, such as listing pods and deployment statuses"
  puts "Always remember to update both by using 'seira <cluster>', such as 'seira staging'."
  puts "Except for special circumstances, you should be able to always use 'seira' tool and avoid `gcloud` and `kubectl` directly."
  puts "All set!"
end