pgai 0.1.8 → 0.2.0
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.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/pgai/cli/main.rb +8 -0
- data/lib/pgai/clone_manager.rb +19 -3
- data/lib/pgai/config.rb +1 -1
- data/lib/pgai/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: fd5bb462021691510f2c194497d6fb87ef5e100a9c48d7ca1c9afab037774628
|
4
|
+
data.tar.gz: 636221fc95e3cc65f22267fe0d922129749104d9eaf9658e15e408cd8b2df1e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3cdda7843c5752d3fcfd0bcae46b4184c2104800d9c071eb056b2f719be7f905f2c88ac92ba2bac9af825afdf446e2f8e674b34d2d39476024ebd1f89fc6e7b
|
7
|
+
data.tar.gz: 39b881e6da03d37b8950bedad53e1d2093260f85bb1ee8a4640ad1e1f2d90d931d2a4eef11de89b5173fa9ae644277f52f22309b334789ad1257043cde5d993e
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ An access token will be required and it can be obtained from: https://console.po
|
|
25
25
|
Example:
|
26
26
|
|
27
27
|
```shell
|
28
|
-
pgai config --dbname=gitlabhq_dblab --prefix=<gitlab handle> --proxy=<
|
28
|
+
pgai config --dbname=gitlabhq_dblab --prefix=<gitlab handle> --proxy=<alias> --exe=<optional /path/to/dblab>
|
29
29
|
```
|
30
30
|
|
31
31
|
To configure environments:
|
@@ -36,12 +36,13 @@ pgai env add --alias ci --id ci-database --port 12345
|
|
36
36
|
|
37
37
|
The environment id, port, and proxy domain can be found by clicking on the `Connect` button on a database instance page.
|
38
38
|
|
39
|
-
Configuring the
|
39
|
+
Configuring the proxy attributes must be done via the `~/.ssh/config` file. Example:
|
40
40
|
|
41
41
|
```
|
42
|
-
Host <
|
43
|
-
|
42
|
+
Host <alias>
|
43
|
+
HostName <domain.postgres.ai>
|
44
44
|
User <username>
|
45
|
+
IdentityFile ~/.ssh/id_ed25519
|
45
46
|
```
|
46
47
|
|
47
48
|
## dblab binary file
|
data/lib/pgai/cli/main.rb
CHANGED
@@ -25,6 +25,14 @@ module Pgai::Cli
|
|
25
25
|
Pgai::CloneManager.new(env, config: configuration).cleanup
|
26
26
|
end
|
27
27
|
|
28
|
+
desc "info database-name", "Show clone details"
|
29
|
+
def info(name)
|
30
|
+
env = configuration.enviroments.fetch(name)
|
31
|
+
|
32
|
+
data = Pgai::CloneManager.new(env, config: configuration).info
|
33
|
+
print_table data
|
34
|
+
end
|
35
|
+
|
28
36
|
desc "env", "Manage environments"
|
29
37
|
subcommand "env", Pgai::Cli::Env
|
30
38
|
end
|
data/lib/pgai/clone_manager.rb
CHANGED
@@ -28,6 +28,19 @@ module Pgai
|
|
28
28
|
port_forward.stop
|
29
29
|
end
|
30
30
|
|
31
|
+
def info
|
32
|
+
configure_enviroment
|
33
|
+
|
34
|
+
clone = find_clone
|
35
|
+
return {} unless clone
|
36
|
+
|
37
|
+
{
|
38
|
+
connection_string: clone.connection_string,
|
39
|
+
created_at: clone.created_at,
|
40
|
+
data_state_at: clone.data_state_at
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
31
44
|
private
|
32
45
|
|
33
46
|
attr_reader :environment, :config, :port_forward, :dblab
|
@@ -45,7 +58,7 @@ module Pgai
|
|
45
58
|
raw_clone = find_raw_clone
|
46
59
|
|
47
60
|
if raw_clone
|
48
|
-
config.find_clone(clone_id) || raise(
|
61
|
+
config.find_clone(clone_id) || raise(Pgai::CloneNotFount, "clone not tracked")
|
49
62
|
else
|
50
63
|
config.remove_clone(clone_id) && nil
|
51
64
|
end
|
@@ -63,13 +76,16 @@ module Pgai
|
|
63
76
|
password: clone_password,
|
64
77
|
user: clone_user,
|
65
78
|
host: HOSTNAME,
|
66
|
-
dbname: config.dbname
|
79
|
+
dbname: config.dbname,
|
80
|
+
created_at: raw_clone["createdAt"],
|
81
|
+
data_state_at: raw_clone.dig("snapshot", "dataStateAt")
|
67
82
|
}
|
68
83
|
|
69
84
|
config.persist_clone(clone_id, attributes)
|
70
85
|
end
|
71
86
|
|
72
87
|
def psql(clone)
|
88
|
+
puts "Data state at: #{clone.data_state_at}"
|
73
89
|
port_forward.start(clone.port)
|
74
90
|
|
75
91
|
psql_pid = fork do
|
@@ -101,7 +117,7 @@ module Pgai
|
|
101
117
|
end
|
102
118
|
|
103
119
|
def clone_password
|
104
|
-
@
|
120
|
+
@clone_password ||= SecureRandom.hex(16)
|
105
121
|
end
|
106
122
|
|
107
123
|
def start_caffeinate(pid)
|
data/lib/pgai/config.rb
CHANGED
@@ -6,7 +6,7 @@ require "fileutils"
|
|
6
6
|
|
7
7
|
module Pgai
|
8
8
|
class Config
|
9
|
-
Clone = Struct.new(:host, :port, :password, :user, :dbname, keyword_init: true) do
|
9
|
+
Clone = Struct.new(:host, :port, :password, :user, :dbname, :created_at, :data_state_at, keyword_init: true) do
|
10
10
|
def connection_string
|
11
11
|
"'host=#{host} port=#{port} user=#{user} dbname=#{dbname} password=#{password}'"
|
12
12
|
end
|
data/lib/pgai/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marius Bobin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|