pgai 0.1.8 → 0.2.0

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
  SHA256:
3
- metadata.gz: 03fa1355e1b4ddb4b4377cc88c8a402085c525693719c36a92cc61b76b0c1738
4
- data.tar.gz: fcf92ab74e0a897fd8b0d59ef06cc71963946f648e33462b2f1835f1afd118a2
3
+ metadata.gz: fd5bb462021691510f2c194497d6fb87ef5e100a9c48d7ca1c9afab037774628
4
+ data.tar.gz: 636221fc95e3cc65f22267fe0d922129749104d9eaf9658e15e408cd8b2df1e0
5
5
  SHA512:
6
- metadata.gz: 406edf0028a55c3ee1f86bc4e8702bdac35af844fde8aa6401897ce9f5475296b80255a59f16c4fbf6ceb59d1fdcd0c3c361bb05ed5323bc762e61c94032965d
7
- data.tar.gz: 6d4cbaeecbdea0c3354dd83973192450cdca24e4b7ffa4a3b07d699efa2b8c9fd341c0c025eed1b689821c734b2cd85ba0f05f2aa2d40d9f28768afe8a2f2017
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=<domain> --exe=<optional /path/to/dblab>
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 user and identity file for the proxy domain must be done using the `~/.ssh/config` file. Example:
39
+ Configuring the proxy attributes must be done via the `~/.ssh/config` file. Example:
40
40
 
41
41
  ```
42
- Host <domain>
43
- IdentityFile ~/.ssh/id_ed25519
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
@@ -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(Pagi::CloneNotFount, "clone not tracked")
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
- @clone_user ||= SecureRandom.hex(16)
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
@@ -1,3 +1,3 @@
1
1
  module Pgai
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.8
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-04-27 00:00:00.000000000 Z
11
+ date: 2023-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor