docker-rainbow 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -6
- data/docker-rainbow.gemspec +1 -1
- data/lib/docker/rainbow.rb +13 -7
- data/lib/docker/rainbow/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 730c043f484f68f40d55db9b10a193f345e0b29e
|
4
|
+
data.tar.gz: 4aff75bd0074a35c1e99d7c95277c811b8e8a007
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 885ac7ae6efadb0d61907f6f78ffdc40e4f74091c2d70dfabfffb1c4968a78686cb39d7d80bb8f13f4b7f79159b74a8c24984c2184fc171321c1fb4a46f3cc73
|
7
|
+
data.tar.gz: 97897f515b6ed46e9d7a57f3ec8993c1e57f7f12fc4b8a0ddcaa905ce8f29f65ff7cf8051330ffbf7cf5a14174a5f91666f6100999cd91d690669aa585474b22
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ names = rainbow.name_containers('spotify/cassandra:latest', count:3)
|
|
45
45
|
|
46
46
|
|
47
47
|
names.each do |name|
|
48
|
-
system("docker run
|
48
|
+
system("docker run --name #{name} spotify/cassandra:latest")
|
49
49
|
end
|
50
50
|
```
|
51
51
|
|
@@ -73,7 +73,12 @@ box. (How often would you have six different revisions of software running
|
|
73
73
|
on one box at once time?)
|
74
74
|
|
75
75
|
If you will handle naming conflicts yourself, you can ask the rainbow to ignore
|
76
|
-
them
|
76
|
+
them with `reuse:true`; rather than raising an exception for in-use names, it
|
77
|
+
will simply return the existing names.
|
78
|
+
|
79
|
+
If you use this option, then you almost certainly also want to use `gc:false`
|
80
|
+
to prevent the rainbow from garbage-collecting dead containers whose names it
|
81
|
+
will reuse.
|
77
82
|
|
78
83
|
```ruby
|
79
84
|
rainbow.name_containers('spotify/cassandra:latest', reuse:true, gc:false)
|
@@ -104,9 +109,9 @@ might find it super interesting that you invoked busybox as `/bin/sh -c ls foo`,
|
|
104
109
|
but the people who look at `docker ps` output probably don't care to see a
|
105
110
|
container named `busybox_bin-sh-c-ls-foo`!
|
106
111
|
|
107
|
-
|
108
|
-
|
109
|
-
|
112
|
+
Although we encourage you to choose terse names, Rainbow will helpfully modify
|
113
|
+
any value you provide with underscores in place of any non alpha-numeric value.
|
114
|
+
If this is an issue, refer to "Customizing Container Names", below.
|
110
115
|
|
111
116
|
### Multi-tenancy
|
112
117
|
|
@@ -152,5 +157,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
152
157
|
|
153
158
|
## Contributing
|
154
159
|
|
155
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
160
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/xeger/docker-rainbow. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
156
161
|
|
data/docker-rainbow.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["tony@rightscale.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{An Ops-friendly container naming scheme for Docker.}
|
13
|
-
spec.description = %q{
|
13
|
+
spec.description = %q{Generates terse, meaningful, unique names for your Docker containers.}
|
14
14
|
spec.homepage = "https://github.com/xeger/docker-rainbow"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
data/lib/docker/rainbow.rb
CHANGED
@@ -26,6 +26,9 @@ module Docker
|
|
26
26
|
# of the world. (That's what `docker logs` is for...)
|
27
27
|
PALETTE = ['blue', 'green', 'orange', 'red', 'yellow', 'violet'].freeze
|
28
28
|
|
29
|
+
# Pattern that matches any container name allowed by Docker.
|
30
|
+
VALID_NAME = /^[a-zA-Z0-9][a-zA-Z0-9_.-]+$/.freeze
|
31
|
+
|
29
32
|
# Execute a shell command and return its output. If the command fails,
|
30
33
|
# raise RuntimeError with details of the command that failed.
|
31
34
|
# TODO use a pretty gem to do this, and/or a Ruby docker CLI wrapper
|
@@ -128,14 +131,17 @@ module Docker
|
|
128
131
|
base
|
129
132
|
end
|
130
133
|
|
131
|
-
# Transform a cmd into a valid container name fragment
|
132
|
-
#
|
133
|
-
# This assumes that the first word of the command is sufficient to
|
134
|
-
# uniquely identify the container's role, and that any remaining words are
|
135
|
-
# noise.
|
134
|
+
# Transform a cmd into a valid container name fragment, or use it verbatim
|
135
|
+
# if it is already valid.
|
136
136
|
private def cmd_suffix(cmd)
|
137
|
-
|
138
|
-
|
137
|
+
if cmd =~ VALID_NAME
|
138
|
+
cmd
|
139
|
+
else
|
140
|
+
mod = cmd.gsub(/\W+/,'_')
|
141
|
+
mod.gsub!(/^_+/, '')
|
142
|
+
mod.gsub!(/_+$/, '')
|
143
|
+
mod
|
144
|
+
end
|
139
145
|
end
|
140
146
|
|
141
147
|
def remove_dead(containers)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-rainbow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Spataro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,8 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
56
|
-
image, existing containers, and other factors.
|
55
|
+
description: Generates terse, meaningful, unique names for your Docker containers.
|
57
56
|
email:
|
58
57
|
- tony@rightscale.com
|
59
58
|
executables: []
|