Class: Seira::Db::Create
- Inherits:
-
Object
- Object
- Seira::Db::Create
- Includes:
- Commands
- Defined in:
- lib/seira/db/create.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#cpu ⇒ Object
readonly
Returns the value of attribute cpu.
-
#make_highly_available ⇒ Object
readonly
Returns the value of attribute make_highly_available.
-
#memory ⇒ Object
readonly
Returns the value of attribute memory.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#proxyuser_password ⇒ Object
readonly
Returns the value of attribute proxyuser_password.
-
#replica_for ⇒ Object
readonly
Returns the value of attribute replica_for.
-
#root_password ⇒ Object
readonly
Returns the value of attribute root_password.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #add(existing_instances) ⇒ Object
- #configure(instance_name, master_name) ⇒ Object
-
#initialize(app:, action:, args:, context:) ⇒ Create
constructor
A new instance of Create.
- #run(existing_instances) ⇒ Object
Methods included from Commands
#gcloud, gcloud, kubectl, #kubectl, #tsh, tsh
Constructor Details
#initialize(app:, action:, args:, context:) ⇒ Create
Returns a new instance of Create.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/seira/db/create.rb', line 12 def initialize(app:, action:, args:, context:) @app = app @action = action @args = args @context = context # We allow overriding the version, so you could specify a mysql version but much of the # below assumes postgres for now @version = 'POSTGRES_9_6' @cpu = 1 # Number of CPUs @memory = 4 # GB @storage = 10 # GB @replica_for = nil @make_highly_available = false @root_password = nil @proxyuser_password = nil end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
6 7 8 |
# File 'lib/seira/db/create.rb', line 6 def action @action end |
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/seira/db/create.rb', line 6 def app @app end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
6 7 8 |
# File 'lib/seira/db/create.rb', line 6 def args @args end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/seira/db/create.rb', line 6 def context @context end |
#cpu ⇒ Object (readonly)
Returns the value of attribute cpu.
8 9 10 |
# File 'lib/seira/db/create.rb', line 8 def cpu @cpu end |
#make_highly_available ⇒ Object (readonly)
Returns the value of attribute make_highly_available.
8 9 10 |
# File 'lib/seira/db/create.rb', line 8 def make_highly_available @make_highly_available end |
#memory ⇒ Object (readonly)
Returns the value of attribute memory.
8 9 10 |
# File 'lib/seira/db/create.rb', line 8 def memory @memory end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/seira/db/create.rb', line 8 def name @name end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
10 11 12 |
# File 'lib/seira/db/create.rb', line 10 def prefix @prefix end |
#proxyuser_password ⇒ Object (readonly)
Returns the value of attribute proxyuser_password.
9 10 11 |
# File 'lib/seira/db/create.rb', line 9 def proxyuser_password @proxyuser_password end |
#replica_for ⇒ Object (readonly)
Returns the value of attribute replica_for.
8 9 10 |
# File 'lib/seira/db/create.rb', line 8 def replica_for @replica_for end |
#root_password ⇒ Object (readonly)
Returns the value of attribute root_password.
9 10 11 |
# File 'lib/seira/db/create.rb', line 9 def root_password @root_password end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
8 9 10 |
# File 'lib/seira/db/create.rb', line 8 def storage @storage end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/seira/db/create.rb', line 8 def version @version end |
Instance Method Details
#add(existing_instances) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/seira/db/create.rb', line 39 def add(existing_instances) if !args.empty? && (args[0].start_with? '--prefix=') @prefix = args[0].split('=')[1] end if prefix.nil? puts "missing --prefix= for add command. Must be the first argument." exit(1) end # remove prefix from the head of the list since we don't want to pass it to gcloud args.pop @name = "#{app}-#{prefix}-#{Seira::Random.unique_name(existing_instances)}" puts "Attempting to create #{name}" run_create_command update_root_password create_proxy_user secrets_name = "#{name}-credentials" kubectl("create secret generic #{secrets_name} --from-literal=ROOT_PASSWORD=#{root_password} --from-literal=PROXYUSER_PASSWORD=#{proxyuser_password}", context: context) puts "Credentials were saved in #{secrets_name}" end |
#configure(instance_name, master_name) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/seira/db/create.rb', line 64 def configure(instance_name, master_name) @name = instance_name @replica_for = master_name configure_created_db end |
#run(existing_instances) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/seira/db/create.rb', line 31 def run(existing_instances) @name = "#{app}-#{Seira::Random.unique_name(existing_instances)}" run_create_command configure_created_db end |