docker_toolkit 0.1.12 → 0.1.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d16607a50a2e8821a42816dcf9793576c67858acc80dcd99ae45a5240a43c1e1
4
- data.tar.gz: 93efc51ea006962e6af5c9cc17f806b69b6e95a00c3c81907cc306db22558c3f
3
+ metadata.gz: 8d6d127fd4fbc93569238e201ee3400b5ce8949edc4d22e28fe9a4ff899c66ec
4
+ data.tar.gz: db197202c36f8a5afa0588818313288bcffbbbc2319c90be23922eacb3fb0e4d
5
5
  SHA512:
6
- metadata.gz: 3bd5eed066256cb59744381a5ddef6e0b4a6936561c7b2e91201abacb10865f92c06889de54e6d481b3b36c10e67ceb182da3aee777be3237f2b8d353168b95a
7
- data.tar.gz: f82e50fa54fa61268249f8c186984951a586bf57c35ce36ba0f314308075458dc18a82e9bc63c9b9fceb4cbfe3177273b76b800405aa2c6e9871d7d5f65010bf
6
+ metadata.gz: fb9cfb56bbdda94b81cdd5ba73d041a3bd12b411a2416869bf8a496848c26d13f9edfdbf9005a11e14a02211fbbeac24a3400b14d9e449840755efdd72800d13
7
+ data.tar.gz: 4fad8c01377d15968f83503210a17afb5ee39c34ab3b3ea684a9053cbcdf154e6463f37d647e7a23be38ba2c17591104e56d9762470304ac3ba733c1acb4928a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- docker_toolkit (0.1.12)
4
+ docker_toolkit (0.1.13)
5
5
  diplomat
6
6
  dotenv
7
7
  json
data/README.md CHANGED
@@ -2,3 +2,93 @@
2
2
  Helper tools for work with docker and consul
3
3
 
4
4
  [![Build Status](https://travis-ci.com/RnD-Soft/docker_toolkit.svg?branch=master)](https://travis-ci.com/RnD-Soft/docker_toolkit) [![Gem Version](https://badge.fury.io/rb/docker_toolkit.svg)](https://badge.fury.io/rb/docker_toolkit)
5
+
6
+ ## Scripts
7
+
8
+ Some useful scripts to run inside or outside container
9
+
10
+ ### waiter.rb
11
+
12
+ waiter.rb allows to wait many conditions:
13
+
14
+ * tcp port opening
15
+ * PostgreSQL database creation
16
+ * PostgreSQL table creation
17
+ * file creation
18
+ * healthy Consul service
19
+
20
+ ```
21
+ Usage: waiter.rb [options] -- exec
22
+ --tcp host:port Wait for tcp accepts on host:port
23
+ --db dbname Wait for PG database exists. Using --tcp to conenct PG
24
+ --tb tablename Wait for PG table exists. Using --tcp to conenct PG
25
+ -f, --file filename Wait for file exists.
26
+ --consul-addr addr=http://localhost:8500
27
+ HTTP addres to connect to consul
28
+ --consul Wait for local consul agent to be ready
29
+ --consul-service service Wait for service appear in consul
30
+ --user user username
31
+ --pass pass password
32
+ -t, --timeout secs=15 Total timeout
33
+ -i, --interval secs=2 Interval between attempts
34
+ -q, --quiet Do not output any status messages
35
+ ```
36
+
37
+
38
+ ### consul.rb
39
+
40
+ Helper to use Consul in 12Factor application. Inspired by https://github.com/hashicorp/envconsul:
41
+
42
+ * export Consul key/value as environment variables
43
+ * references in Consul key/value store
44
+ * read config file and store values in Consul
45
+ * read files and store it in Consul key/value store
46
+
47
+ ```
48
+ Usage: consul.rb [options] -- exec
49
+ --consul url Set up a custom Consul URL
50
+ --token token Connect into consul with custom access token (ACL)
51
+ --init [service] Initialize Consul services from config
52
+ --config file Read service configulation from file
53
+ --upload Upload files to variables
54
+ --show [service] Show service configulation from Consul
55
+ --override override existed keys
56
+ -d, --dereference dereference consul values in form of "consul://key/subkey"
57
+ --env prefix export KV values from prefix as env varaibles
58
+ --export add export to --env output
59
+ --pristine not include the parent processes' environment when exec child process
60
+ --put path:value put value to path
61
+ --get path get value from
62
+ ```
63
+
64
+ Example config.yml:
65
+ ```yaml
66
+ .dbconfig: &dbconfig
67
+ DATABASE_HOST:
68
+ value: db
69
+ DATABASE_NAME:
70
+ value: dbname
71
+
72
+ srv1: &srv1
73
+ <<: [*dbconfig]
74
+ LOG_LEVEL:
75
+ value: debug
76
+ CA_CERT:
77
+ file: /tmp/ca/cacert.pem
78
+ CLIENT_CERT:
79
+ value: consul://services/ca/private/cert.pem
80
+ CLIENT_KEY:
81
+ value: consul://services/ca/private/key.pem
82
+
83
+ srv2:
84
+ <<: *srv1
85
+ CA_CERT:
86
+ value: consul://services/env/srv1/ca_cert
87
+ ```
88
+
89
+ ### merger.rb
90
+
91
+ Merge docker-compose file of any version. Allow inheritance and extending services.
92
+ ```bash
93
+ COMPOSE_FILE=file1.yml:file2.yml merger.rb > /tmp/result.yml
94
+ ```
@@ -37,8 +37,8 @@ module DockerToolkit
37
37
  env[key]
38
38
  end
39
39
 
40
- def envsubst *paths
41
- paths = paths.flatten.map{|c| c.to_s.strip}.reject(&:empty?)
40
+ def envsubst(*paths)
41
+ paths = paths.flatten.map{|c| c.to_s.strip }.reject(&:empty?)
42
42
  paths.each do |path|
43
43
  Dir.glob("#{path}/**/*.in") do |templ|
44
44
  output = templ.sub(/\.in$/, '')
@@ -48,9 +48,9 @@ module DockerToolkit
48
48
  end
49
49
  end
50
50
 
51
- def envsubst_file templ, output = nil
51
+ def envsubst_file(templ, output = nil)
52
52
  output ||= templ.sub(/\.in$/, '')
53
- die("filename must ends with .in or output must be provided") if output.strip == templ.strip
53
+ die('filename must ends with .in or output must be provided') if output.strip == templ.strip
54
54
  cmd = "cat '#{templ}' | envsubst > '#{output}'"
55
55
  system(cmd) || die("envsubst failed: #{cmd}")
56
56
  end
@@ -1,5 +1,5 @@
1
1
  module DockerToolkit
2
2
 
3
- VERSION = '0.1.12'.freeze
3
+ VERSION = '0.1.13'.freeze
4
4
 
5
5
  end
@@ -75,7 +75,7 @@ module DockerToolkit
75
75
  end
76
76
 
77
77
  def add(*cmd)
78
- cmd = cmd.flatten.map{|c| c.to_s.strip}.reject(&:empty?)
78
+ cmd = cmd.flatten.map{|c| c.to_s.strip }.reject(&:empty?)
79
79
  process = ChildProcess.build(*cmd)
80
80
 
81
81
  rerr, werr = IO.pipe
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Godko Ivan
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  requirements: []
163
163
  rubyforge_project:
164
- rubygems_version: 2.7.3
164
+ rubygems_version: 2.7.7
165
165
  signing_key:
166
166
  specification_version: 4
167
167
  summary: Helper scripts for work with docker and consul