seira 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/helpers.rb +4 -2
- data/lib/seira/db.rb +24 -1
- data/lib/seira/db/create.rb +22 -11
- data/lib/seira/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c722513894391b3837c18f6a434d3f101b3093ecf82e55ed0604d6d566340753
|
4
|
+
data.tar.gz: fff690cfc3fef81d40d4d2247804055df50cde174d0408b7f17245402efc43a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5e225e2ec2d383997139a8f2aa13fb35ab6039e56ca3dcb9bf2ed68bd67a580c4f581ec9236eb7f62fb8584a9e2b3bf4051d045c809d263b3da1a934817af1e
|
7
|
+
data.tar.gz: c027903654bea1c9e42e83c8adf599a2f71f334081f74e32f658ad6ef67993110056120ea9531233c7631d157387ff2674c3d3699775e05e8cd99315be9de106
|
data/lib/helpers.rb
CHANGED
@@ -4,10 +4,12 @@ module Seira
|
|
4
4
|
|
5
5
|
class << self
|
6
6
|
def rails_env(context:)
|
7
|
-
|
7
|
+
parsed_env = context[:settings].settings['seira']['clusters'][context[:cluster]]['environment']
|
8
|
+
parsed_env = context[:cluster] if parsed_env.nil?
|
9
|
+
if parsed_env == 'internal'
|
8
10
|
'production'
|
9
11
|
else
|
10
|
-
|
12
|
+
parsed_env
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
data/lib/seira/db.rb
CHANGED
@@ -14,7 +14,7 @@ module Seira
|
|
14
14
|
analyze create-readonly-user psql table-sizes
|
15
15
|
index-sizes vacuum unused-indexes unused-indices
|
16
16
|
user-connections info alter-proxyuser-roles add
|
17
|
-
write-pgbouncer-yaml
|
17
|
+
configure write-pgbouncer-yaml
|
18
18
|
].freeze
|
19
19
|
SUMMARY = "Manage your Cloud SQL Postgres databases.".freeze
|
20
20
|
|
@@ -35,6 +35,8 @@ module Seira
|
|
35
35
|
run_create
|
36
36
|
when 'add'
|
37
37
|
run_add
|
38
|
+
when 'configure'
|
39
|
+
run_configure
|
38
40
|
when 'delete'
|
39
41
|
run_delete
|
40
42
|
when 'list'
|
@@ -95,6 +97,7 @@ module Seira
|
|
95
97
|
analyze: Display database performance information
|
96
98
|
connect: Open a psql command prompt via gcloud connect. You will be shown the password needed before the prompt opens.
|
97
99
|
create: Create a new postgres instance in cloud sql. Supports creating replicas and other numerous flags.
|
100
|
+
configure: Configure users and related secrets for existing db instance --instance= with optional --master= for read replica.
|
98
101
|
add: Adds a new database to the given project. Requires --prefix=my-prefix to prefix the random name
|
99
102
|
create-readonly-user: Create a database user named by --username=<name> with only SELECT access privileges
|
100
103
|
delete: Delete a postgres instance from cloud sql. Use with caution, and remove all kubernetes configs first.
|
@@ -122,6 +125,26 @@ module Seira
|
|
122
125
|
Seira::Db::Create.new(app: app, action: action, args: args, context: context).add(existing_instances)
|
123
126
|
end
|
124
127
|
|
128
|
+
def run_configure
|
129
|
+
instance_name = nil
|
130
|
+
master_name = nil
|
131
|
+
args.each do |arg|
|
132
|
+
if arg.start_with? '--instance='
|
133
|
+
instance_name = arg.split('=')[1]
|
134
|
+
elsif arg.start_with? '--master='
|
135
|
+
master_name = arg.split('=')[1]
|
136
|
+
else
|
137
|
+
puts "Warning: Unrecognized argument '#{arg}'"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
if instance_name.nil? || instance_name.strip.chomp == ''
|
142
|
+
puts "Please specify the db instance name, like --instance=name"
|
143
|
+
exit(1)
|
144
|
+
end
|
145
|
+
Seira::Db::Create.new(app: app, action: action, args: args, context: context).configure(instance_name, master_name)
|
146
|
+
end
|
147
|
+
|
125
148
|
def run_alter_proxyuser_roles
|
126
149
|
Seira::Db::AlterProxyuserRoles.new(app: app, action: action, args: args, context: context).run
|
127
150
|
end
|
data/lib/seira/db/create.rb
CHANGED
@@ -33,17 +33,7 @@ module Seira
|
|
33
33
|
|
34
34
|
run_create_command
|
35
35
|
|
36
|
-
|
37
|
-
update_root_password
|
38
|
-
create_proxy_user
|
39
|
-
end
|
40
|
-
|
41
|
-
set_secrets
|
42
|
-
|
43
|
-
alter_proxy_user_roles if replica_for.nil?
|
44
|
-
|
45
|
-
puts "To use this database, use write-pgbouncer-yaml command and deploy the pgbouncer config file that was created and use the ENV that was set."
|
46
|
-
puts "To make this database the primary, promote it using the CLI and update the DATABASE_URL."
|
36
|
+
configure_created_db
|
47
37
|
end
|
48
38
|
|
49
39
|
def add(existing_instances)
|
@@ -71,8 +61,29 @@ module Seira
|
|
71
61
|
puts "Credentials were saved in #{secrets_name}"
|
72
62
|
end
|
73
63
|
|
64
|
+
def configure(instance_name, master_name)
|
65
|
+
@name = instance_name
|
66
|
+
@replica_for = master_name
|
67
|
+
|
68
|
+
configure_created_db
|
69
|
+
end
|
70
|
+
|
74
71
|
private
|
75
72
|
|
73
|
+
def configure_created_db
|
74
|
+
if replica_for.nil?
|
75
|
+
update_root_password
|
76
|
+
create_proxy_user
|
77
|
+
end
|
78
|
+
|
79
|
+
set_secrets
|
80
|
+
|
81
|
+
alter_proxy_user_roles if replica_for.nil?
|
82
|
+
|
83
|
+
puts "To use this database, use write-pgbouncer-yaml command and deploy the pgbouncer config file that was created and use the ENV that was set."
|
84
|
+
puts "To make this database the primary, promote it using the CLI and update the DATABASE_URL."
|
85
|
+
end
|
86
|
+
|
76
87
|
def run_create_command
|
77
88
|
# The 'beta' is needed for HA and other beta features
|
78
89
|
create_command = "beta sql instances create #{name}"
|
data/lib/seira/version.rb
CHANGED
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
|
+
version: 0.6.6
|
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-11-
|
11
|
+
date: 2019-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|