seira 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5be00c536176932142946b6895318dc29d53f76
4
- data.tar.gz: 2a902ea955ee77f72c174de8672d15def2eef544
3
+ metadata.gz: 669843ecfb6cfb054f7be793690a37584566cc73
4
+ data.tar.gz: 9889f757784af3d0ad4634ffd4c211c5abb9799f
5
5
  SHA512:
6
- metadata.gz: fb4e57972ea5e115b7daa89105662789e74aa9c80bd51a36cd5454331bc88d873610fb532a3e1a528dc2bc7577ad5b47b95b0969006459b06145aa89e480e475
7
- data.tar.gz: ecaa4df24618206589985f0e06641243173d0ccef6b11934651f928f10f686b0a3fa8ffad35dd42ff71f6d946c73fea07057c0c861b541b6e77586f4d665e31e
6
+ metadata.gz: 0ef7516626cf358152b97b9eece4dbd5e1466ad773ff6ee21960cab59fc9bba3be27bbe5b23ba4f7d7d8524e2aa009e633e0069aaf21ff90db106617c4e2e9de
7
+ data.tar.gz: 2fb02399b82c25635a4d969306ec50ab1aeb3b514aa029d7e9a1bf4dbe60b510eeead7008b83a7a83eb35d58a8a3be50d29b63caca3b4629b850bdb8bcffd372
data/lib/seira.rb CHANGED
@@ -42,7 +42,9 @@ module Seira
42
42
 
43
43
  # The cluster and proxy command are not specific to any app, so that
44
44
  # arg is not in the ARGV array and should be skipped over
45
- if ARGV[1] == 'cluster'
45
+ if ARGV[0] == 'help'
46
+ @category = reversed_args.pop
47
+ elsif ARGV[1] == 'cluster'
46
48
  cluster = reversed_args.pop
47
49
  @category = reversed_args.pop
48
50
  @action = reversed_args.pop
@@ -65,7 +67,10 @@ module Seira
65
67
  end
66
68
 
67
69
  def run
68
- if category == 'setup'
70
+ if category == 'help'
71
+ run_base_help
72
+ exit(0)
73
+ elsif category == 'setup'
69
74
  Seira::Setup.new(arg: cluster, settings: settings).run
70
75
  exit(0)
71
76
  end
@@ -123,5 +128,16 @@ module Seira
123
128
  def simple_cluster_change?
124
129
  app.nil? && category.nil? # Special case where user is simply changing environments
125
130
  end
131
+
132
+ def run_base_help
133
+ puts 'Seira is a library for managing Kubernetes as a PaaS.'
134
+ puts 'All commands take the following form: `seira <cluster-name> <app-name> <category> <action> <args...>`'
135
+ puts 'For example, `seira staging foo-app secrets list`'
136
+ puts "Possible categories: \n\n"
137
+ CATEGORIES.each do |key, klass|
138
+ puts "#{key}: #{klass::SUMMARY}"
139
+ end
140
+ puts "\nTo get more help for a specific category, run `seira <cluster-name> <app-name> <category> help` command"
141
+ end
126
142
  end
127
143
  end
data/lib/seira/app.rb CHANGED
@@ -6,7 +6,8 @@ require 'fileutils'
6
6
  # seira staging specs app bootstrap
7
7
  module Seira
8
8
  class App
9
- VALID_ACTIONS = %w[bootstrap apply upgrade restart scale].freeze
9
+ VALID_ACTIONS = %w[help bootstrap apply restart scale].freeze
10
+ SUMMARY = "Bootstrap, scale, configure, restart, your apps.".freeze
10
11
 
11
12
  attr_reader :app, :action, :args, :context
12
13
 
@@ -19,12 +20,12 @@ module Seira
19
20
 
20
21
  def run
21
22
  case action
23
+ when 'help'
24
+ run_help
22
25
  when 'bootstrap'
23
26
  run_bootstrap
24
27
  when 'apply'
25
28
  run_apply
26
- when 'upgrade'
27
- run_upgrade
28
29
  when 'restart'
29
30
  run_restart
30
31
  when 'scale'
@@ -34,6 +35,16 @@ module Seira
34
35
  end
35
36
  end
36
37
 
38
+ def run_help
39
+ puts SUMMARY
40
+ puts "\n\n"
41
+ puts "Possible actions:\n\n"
42
+ puts "bootstrap: Create new app with main secret, cloudsql secret, and gcr secret in the new namespace."
43
+ puts "apply: Apply the configuration in kubernetes/<cluster-name>/<app-name> using REVISION environment variable to find/replace REVISION in the YAML."
44
+ puts "restart: TODO."
45
+ puts "scale: Scales the given tier deployment to the specified number of instances."
46
+ end
47
+
37
48
  def run_restart
38
49
  # TODO
39
50
  end
data/lib/seira/cluster.rb CHANGED
@@ -5,7 +5,8 @@ require 'fileutils'
5
5
  # Example usages:
6
6
  module Seira
7
7
  class Cluster
8
- VALID_ACTIONS = %w[bootstrap].freeze
8
+ VALID_ACTIONS = %w[help bootstrap].freeze
9
+ SUMMARY = "For managing whole clusters.".freeze
9
10
 
10
11
  attr_reader :action, :args, :context, :settings
11
12
 
@@ -18,6 +19,8 @@ module Seira
18
19
 
19
20
  def run
20
21
  case action
22
+ when 'help'
23
+ run_help
21
24
  when 'bootstrap'
22
25
  run_bootstrap
23
26
  else
data/lib/seira/db.rb CHANGED
@@ -2,7 +2,8 @@ require 'securerandom'
2
2
 
3
3
  module Seira
4
4
  class Db
5
- VALID_ACTIONS = %w[create delete list].freeze
5
+ VALID_ACTIONS = %w[help create delete list].freeze
6
+ SUMMARY = "Manage your Cloud SQL Postgres databases.".freeze
6
7
 
7
8
  attr_reader :app, :action, :args, :context
8
9
 
@@ -15,6 +16,8 @@ module Seira
15
16
 
16
17
  def run
17
18
  case action
19
+ when 'help'
20
+ run_help
18
21
  when 'create'
19
22
  run_create
20
23
  when 'delete'
@@ -28,6 +31,12 @@ module Seira
28
31
 
29
32
  private
30
33
 
34
+ def run_help
35
+ puts SUMMARY
36
+ puts "\n\n"
37
+ puts "TODO"
38
+ end
39
+
31
40
  def run_create
32
41
  # We allow overriding the version, so you could specify a mysql version but much of the
33
42
  # below assumes postgres for now
@@ -3,7 +3,8 @@ require 'base64'
3
3
 
4
4
  module Seira
5
5
  class Memcached
6
- VALID_ACTIONS = %w[list status credentials create delete].freeze
6
+ VALID_ACTIONS = %w[help list status credentials create delete].freeze
7
+ SUMMARY = "Manage your Helm Memcached instances.".freeze
7
8
 
8
9
  attr_reader :app, :action, :args, :context
9
10
 
@@ -17,6 +18,8 @@ module Seira
17
18
  # TODO: logs, upgrades?, backups, restores, CLI connection
18
19
  def run
19
20
  case action
21
+ when 'help'
22
+ run_help
20
23
  when 'list'
21
24
  run_list
22
25
  when 'status'
@@ -34,6 +37,12 @@ module Seira
34
37
 
35
38
  private
36
39
 
40
+ def run_help
41
+ puts SUMMARY
42
+ puts "\n\n"
43
+ puts "TODO"
44
+ end
45
+
37
46
  def run_list
38
47
  puts existing_instances
39
48
  end
data/lib/seira/pods.rb CHANGED
@@ -2,7 +2,8 @@ require 'json'
2
2
 
3
3
  module Seira
4
4
  class Pods
5
- VALID_ACTIONS = %w[list delete logs top run connect].freeze
5
+ VALID_ACTIONS = %w[help list delete logs top run connect].freeze
6
+ SUMMARY = "Manage your application's pods.".freeze
6
7
 
7
8
  attr_reader :app, :action, :args, :pod_name, :context
8
9
 
@@ -16,6 +17,8 @@ module Seira
16
17
 
17
18
  def run
18
19
  case action
20
+ when 'help'
21
+ run_help
19
22
  when 'list'
20
23
  run_list
21
24
  when 'delete'
@@ -35,6 +38,12 @@ module Seira
35
38
 
36
39
  private
37
40
 
41
+ def run_help
42
+ puts SUMMARY
43
+ puts "\n\n"
44
+ puts "TODO"
45
+ end
46
+
38
47
  def run_list
39
48
  puts `kubectl get pods --namespace=#{app} -o wide`
40
49
  end
data/lib/seira/proxy.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Seira
2
2
  class Proxy
3
+ SUMMARY = "Open up the proxy UI for a given cluster.".freeze
4
+
3
5
  def initialize
4
6
  end
5
7
 
data/lib/seira/redis.rb CHANGED
@@ -3,7 +3,8 @@ require 'base64'
3
3
 
4
4
  module Seira
5
5
  class Redis
6
- VALID_ACTIONS = %w[list status credentials create delete].freeze
6
+ VALID_ACTIONS = %w[help list status credentials create delete].freeze
7
+ SUMMARY = "Manage your Helm Redis instances.".freeze
7
8
 
8
9
  attr_reader :app, :action, :args, :context
9
10
 
@@ -17,6 +18,8 @@ module Seira
17
18
  # TODO: logs, upgrades?, backups, restores, CLI connection
18
19
  def run
19
20
  case action
21
+ when 'help'
22
+ run_help
20
23
  when 'list'
21
24
  run_list
22
25
  when 'status'
@@ -34,6 +37,12 @@ module Seira
34
37
 
35
38
  private
36
39
 
40
+ def run_help
41
+ puts SUMMARY
42
+ puts "\n\n"
43
+ puts "TODO"
44
+ end
45
+
37
46
  def run_list
38
47
  puts existing_instances
39
48
  end
@@ -115,7 +124,7 @@ module Seira
115
124
 
116
125
  file_name = write_config(values)
117
126
  unique_name = Seira::Random.unique_name(existing_instances)
118
- name = "#{app}-#{unique_name}"
127
+ name = "#{app}-redis-#{unique_name}"
119
128
  puts `helm install --namespace #{app} --name #{name} --wait -f #{file_name} stable/redis`
120
129
 
121
130
  File.delete(file_name)
@@ -126,7 +135,7 @@ module Seira
126
135
  end
127
136
 
128
137
  def run_delete
129
- to_delete = "#{app}-#{args[0]}"
138
+ to_delete = "#{app}-redis-#{args[0]}"
130
139
 
131
140
  exit(1) unless HighLine.agree("Are you sure you want to delete #{to_delete}? If any apps are using this redis instance, they will break.")
132
141
 
data/lib/seira/secrets.rb CHANGED
@@ -8,8 +8,9 @@ require 'base64'
8
8
  # TODO: Can we avoid writing to disk completely and instead pipe in raw json?
9
9
  module Seira
10
10
  class Secrets
11
- VALID_ACTIONS = %w[get set unset list list-decoded create-pgbouncer-secret].freeze
11
+ VALID_ACTIONS = %w[help get set unset list list-decoded create-pgbouncer-secret].freeze
12
12
  PGBOUNCER_SECRETS_NAME = 'pgbouncer-secrets'.freeze
13
+ SUMMARY = "Manage your application's secrets and environment variables.".freeze
13
14
 
14
15
  attr_reader :app, :action, :args, :context
15
16
 
@@ -22,6 +23,8 @@ module Seira
22
23
 
23
24
  def run
24
25
  case action
26
+ when 'help'
27
+ run_help
25
28
  when 'get'
26
29
  validate_single_key
27
30
  run_get
@@ -64,6 +67,12 @@ module Seira
64
67
 
65
68
  private
66
69
 
70
+ def run_help
71
+ puts SUMMARY
72
+ puts "\n\n"
73
+ puts "TODO"
74
+ end
75
+
67
76
  def validate_single_key
68
77
  if key.nil? || key.strip == ""
69
78
  puts "Please specify a key in all caps and with underscores"
@@ -114,7 +123,7 @@ module Seira
114
123
  def run_create_pgbouncer_secret
115
124
  db_user = args[0]
116
125
  db_password = args[1]
117
- write_secrets(secrets: { DB_USER: db_user, DB_PASSWORD: db_password }, secret_name: PGBOUNCER_SECRETS_NAME)
126
+ puts `kubectl create secret generic #{PGBOUNCER_SECRETS_NAME} --namespace #{app} --from-literal=DB_USER=#{db_user} --from-literal=DB_PASSWORD=#{db_password}`
118
127
  end
119
128
 
120
129
  # In the normal case the secret we are updating is just main_secret_name,
data/lib/seira/setup.rb CHANGED
@@ -3,6 +3,8 @@ require 'json'
3
3
 
4
4
  module Seira
5
5
  class Setup
6
+ SUMMARY = "Set up your local CLI with the right project and cluster configuration.".freeze
7
+
6
8
  attr_reader :arg, :settings
7
9
 
8
10
  def initialize(arg:, settings:)
data/lib/seira/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Seira
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Ringwelski