seira 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/seira/db.rb +12 -7
  3. data/lib/seira/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6679bfcc4bb8d3716343f223bc2e656b51c1399a3bef35eb1e6977ff8221e201
4
- data.tar.gz: 4628b1b0172a88f6df751119c50d962b2eb2d9798af42083c2bec7b78d3b47d2
3
+ metadata.gz: ed12fc57ff19d790cf26102987d8c48792fabe688cb7c1d517caf62b8073f210
4
+ data.tar.gz: 4d296bb7e6bb748b706c2cbb093d89626fe160d3d41000a272c6a394ff5ba441
5
5
  SHA512:
6
- metadata.gz: 75becd757e1043988df19006bf593b5e04f296e03a305124f39bcfdabbc816ed182d6a2cca817d3498ac48fd54d0242674928de71db34fe241629ebdc4b6bdfa
7
- data.tar.gz: 6d843da0af0658de1b4ac31b169f1b6dd25ae5c61f380cebb2537b0b2bac37b9d0d6c720aeea97d11d75b8fcce6a6b17070bf1f4ec196c5daf1808fbe8dfcbc2
6
+ metadata.gz: 1c48eea1958850e0b70397ee952ce8bcf61013aa18b36d190d87e63c4f934493c2957d2c5389237da07a2fc90765948913a7bed0c16262d66cdd5c8d41bc1fb9
7
+ data.tar.gz: e0b3d410c3bcbc91f843aca207e229f049917d21ce9346130f11606991c886e3c635fc1dc19861a9f807379b48f5883d3f4018736dbb7c32c23665d3c1ffeb6e
data/lib/seira/db.rb CHANGED
@@ -238,11 +238,16 @@ module Seira
238
238
  # Example: seira staging app-name db create-readonly-user --username=readonlyuser
239
239
  def run_create_readonly_user
240
240
  instance_name = primary_instance # Always make user changes to primary instance, and they will propogate to replicas
241
+ pgbouncer_tier = nil
241
242
  user_name = nil
242
243
 
243
244
  args.each do |arg|
244
245
  if arg.start_with? '--username='
245
246
  user_name = arg.split('=')[1]
247
+ elsif arg.start_with? '--instance='
248
+ instance_name = arg.split('=')[1]
249
+ elsif arg.start_with? '--pgbouncer-tier='
250
+ pgbouncer_tier = arg.split('=')[1]
246
251
  else
247
252
  puts "Warning: Unrecognized argument '#{arg}'"
248
253
  end
@@ -259,7 +264,7 @@ module Seira
259
264
  exit(1)
260
265
  end
261
266
 
262
- valid_instance_names = existing_instances(remove_app_prefix: false).join(', ')
267
+ valid_instance_names = existing_instances(remove_app_prefix: false)
263
268
  if instance_name.nil? || instance_name.strip.chomp == '' || !valid_instance_names.include?(instance_name)
264
269
  puts "Could not find a valid instance name - does the DATABASE_URL have a value? Must be one of: #{valid_instance_names}"
265
270
  exit(1)
@@ -287,8 +292,8 @@ module Seira
287
292
  SQL
288
293
 
289
294
  puts "Connecting"
290
- execute_db_command(admin_commands, as_admin: true)
291
- execute_db_command(database_commands)
295
+ execute_db_command(admin_commands, instance_name: instance_name, pgbouncer_tier: pgbouncer_tier, as_admin: true)
296
+ execute_db_command(database_commands, instance_name: instance_name, pgbouncer_tier: pgbouncer_tier)
292
297
  end
293
298
 
294
299
  def run_psql
@@ -432,12 +437,12 @@ module Seira
432
437
  end
433
438
  end
434
439
 
435
- def execute_db_command(sql_command, as_admin: false, interactive: false, print: true)
440
+ def execute_db_command(sql_command, instance_name: nil, pgbouncer_tier: nil, as_admin: false, interactive: false, print: true)
436
441
  # TODO(josh): move pgbouncer naming logic here and in Create to a common location
437
- instance_name = primary_instance
442
+ instance_name ||= primary_instance
438
443
  private_ip = Helpers.sql_ips(instance_name, context: context)[:private]
439
- tier = instance_name.gsub("#{app}-", '')
440
- matching_pods = Helpers.fetch_pods(context: context, filters: { tier: tier })
444
+ pgbouncer_tier ||= instance_name.gsub("#{app}-", '')
445
+ matching_pods = Helpers.fetch_pods(context: context, filters: { tier: pgbouncer_tier })
441
446
  if matching_pods.empty?
442
447
  puts 'Could not find pgbouncer pod to connect to'
443
448
  exit 1
data/lib/seira/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Seira
2
- VERSION = "0.6.4".freeze
2
+ VERSION = "0.6.5".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Ringwelski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-23 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline