train-pgsql 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -10
- data/lib/train-pgsql/transport.rb +9 -9
- data/lib/train-pgsql/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: bf9046c760c47e717c33a05f1044d3142036509cc0fa883ab7ddc6b9664dc8e0
|
4
|
+
data.tar.gz: 901fc8f8862e6eb8ae21d9c8340927653d875d476d55db2accbdff90688a4b5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b34564dc3c47a2be228d7ee67e833d490e533b683775aaac3050dbc17d490509f5935046ecef1b71bef4dcb2af1a5dd0120aa74fd897040fb554889a1135756f
|
7
|
+
data.tar.gz: bba454681a04de826b47e109927189a030b9718d17b2c4351b2e293ae73679e594dd746a3e3e22794f238fc757b064dba53c060d7c1d3b81157d65a42749273b
|
data/README.md
CHANGED
@@ -19,17 +19,37 @@ inspec plugin install train-pgsql
|
|
19
19
|
|
20
20
|
## Transport parameters
|
21
21
|
|
22
|
-
| Option | Explanation | Default |
|
23
|
-
| ---------- | ------------------- | ---------- |
|
24
|
-
| `host` | Hostname | (required) |
|
25
|
-
| `user` | Username to connect | (required) |
|
26
|
-
| `password` | Password to connect | (required) |
|
27
|
-
| `database` | Database to connect | `postgres` |
|
28
|
-
| `port` | Remote port | `5432` |
|
22
|
+
| Option | Explanation | Default | ENV VAR |
|
23
|
+
| ---------- | ------------------- | ---------- | ------------ |
|
24
|
+
| `host` | Hostname | (required) | `PGHOST` |
|
25
|
+
| `user` | Username to connect | (required) | `PGUSER` |
|
26
|
+
| `password` | Password to connect | (required) | `PGPASSWORD` |
|
27
|
+
| `database` | Database to connect | `postgres` | `PGDATABASE` |
|
28
|
+
| `port` | Remote port | `5432` | `PGPORT` |
|
29
|
+
|
30
|
+
|
31
|
+
## Example use in inspec
|
32
|
+
Connect to the postgresql target as such:
|
33
|
+
```bash
|
34
|
+
inspec shell -t pgsql://db.host.name --user 'username' --password 'supersecret' --insecure boolean
|
35
|
+
```
|
36
|
+
or
|
37
|
+
```bash
|
38
|
+
inspec exec -t pgsql://db.host.name --user 'username' --password 'supersecret' --insecure boolean
|
39
|
+
```
|
29
40
|
|
30
|
-
|
41
|
+
Alternatively you can set all these as environment variables using the following variables and authenticate without the parameters in in the inspec command or the target
|
42
|
+
```bash
|
43
|
+
export PGHOST='db.host.name'
|
44
|
+
export PGUSER='username'
|
45
|
+
export PGPASSWORD='supersecret'
|
46
|
+
export PGDATABASE='somedatabase'
|
47
|
+
inspec exec -t pgsql://
|
48
|
+
```
|
31
49
|
|
32
|
-
|
50
|
+
## Example use from Ruby
|
51
|
+
|
52
|
+
This will work if you have postgresql running on `localhost`:
|
33
53
|
```ruby
|
34
54
|
require "train"
|
35
55
|
train = Train.create("pgsql", {
|
@@ -41,7 +61,6 @@ conn = train.connection
|
|
41
61
|
result = conn.run_command("show version\n")
|
42
62
|
conn.close
|
43
63
|
```
|
44
|
-
|
45
64
|
## Local development
|
46
65
|
If you are building this on a Mac you may run into an issue trying to install this locally due to the `PG` gem not installing due to code signing issues.
|
47
66
|
You can build it and run it in a docker container.
|
@@ -1,22 +1,22 @@
|
|
1
|
-
require
|
1
|
+
require 'train-pgsql/connection'
|
2
2
|
|
3
3
|
module TrainPlugins
|
4
4
|
module Pgsql
|
5
5
|
class Transport < Train.plugin(1)
|
6
|
-
name
|
6
|
+
name 'pgsql'
|
7
7
|
|
8
|
-
option :host, required: true
|
9
|
-
option :user, required: true
|
10
|
-
option :password, required: true
|
11
|
-
option :database, default:
|
12
|
-
option :port, default: 5432
|
8
|
+
option :host, required: true, default: ENV['PGHOST']
|
9
|
+
option :user, required: true, default: ENV['PGUSER']
|
10
|
+
option :password, required: true, default: ENV['PGPASSWORD']
|
11
|
+
option :database, required: false, default: ENV['PGDATABASE'] || 'postgres'
|
12
|
+
option :port, required: false, default: ENV['PGPORT'] || 5432
|
13
13
|
|
14
14
|
# Non documented options for development
|
15
|
-
option :debug_pgsql,
|
15
|
+
option :debug_pgsql, default: false
|
16
16
|
|
17
17
|
def connection(_instance_opts = nil)
|
18
18
|
@connection ||= TrainPlugins::Pgsql::Connection.new(@options)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
data/lib/train-pgsql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: train-pgsql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cris Barbero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: train
|