percheron 0.7.1 → 0.7.2
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/.travis.yml +1 -2
- data/README.md +25 -9
- data/lib/percheron/actions/shell.rb +4 -2
- data/lib/percheron/commands/shell.rb +2 -0
- data/lib/percheron/errors.rb +1 -0
- data/lib/percheron/validators/config.rb +9 -13
- data/lib/percheron/validators/container.rb +6 -11
- data/lib/percheron/validators/docker_client.rb +56 -0
- data/lib/percheron/validators/stack.rb +7 -7
- data/lib/percheron/validators.rb +1 -0
- data/lib/percheron/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15de7f98c12439599c7f39ba23c9667d3114d493
|
4
|
+
data.tar.gz: e5efd6cf80b855d2bc6a477db9406165708f0b9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad718e1b22ec751f618b29d0bd37e716fea413291152738d692746dbd9fec849190f78e324de88608271c138455c682d02ef15b3cdcbb23b70593b9b7cc6878b
|
7
|
+
data.tar.gz: 77b283bb036e996e2847ebfb5fe6c77ce11351fd6061ae1352e319d9fd464cef506dbfd30c8cccdbe395bfc44d199d2ed007be08f9dd9402355704ef71ba7a51
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -8,6 +8,21 @@
|
|
8
8
|
|
9
9
|
Organise your Docker containers with muscle and intelligence.
|
10
10
|
|
11
|
+
## Features
|
12
|
+
|
13
|
+
* Single, easy to write `.percheron.yml` controls everything
|
14
|
+
* Supports building, creating and starting of containers and their dependancies
|
15
|
+
* Supports building using a Dockerfile or pulling a Docker image from Docker Hub
|
16
|
+
* Build 'base' images as a dependancy and then build from there
|
17
|
+
* Support for pre-build and post-start scripts when generating images and starting containers
|
18
|
+
* Version control of building images and containers
|
19
|
+
* Written in Ruby :)
|
20
|
+
|
21
|
+
## Supported platforms
|
22
|
+
|
23
|
+
* Linux
|
24
|
+
* MacOS 10.9+
|
25
|
+
|
11
26
|
## Installation
|
12
27
|
|
13
28
|
Add this line to your application's Gemfile:
|
@@ -31,7 +46,8 @@ $ gem install percheron
|
|
31
46
|
## Requirements
|
32
47
|
|
33
48
|
* Ruby 2.x
|
34
|
-
* Docker 1.6.x
|
49
|
+
* [Docker 1.6.x](https://docs.docker.com/installation/) / [Boot2Docker v1.6.x+](https://docs.docker.com/installation)
|
50
|
+
* [Docker client](https://docs.docker.com/installation) (nice to have)
|
35
51
|
|
36
52
|
## Usage
|
37
53
|
|
@@ -39,29 +55,29 @@ TODO
|
|
39
55
|
|
40
56
|
## Examples
|
41
57
|
|
42
|
-
* Rails
|
43
|
-
* Torrent
|
44
|
-
* SaltStack
|
58
|
+
* [Rails](https://github.com/ashmckenzie/percheron-rails#quickstart) - Rails 4.2, PostgreSQL, redis, HAProxy and postfix
|
59
|
+
* [Torrent](https://github.com/ashmckenzie/percheron-torrent#quickstart) - Tracker (chihaya), seeder (aria2) and three peers (aria2)
|
60
|
+
* [SaltStack](https://github.com/ashmckenzie/percheron-saltstack#quickstart) - SaltStack v2015.2.0rc2 with master and minion
|
45
61
|
|
46
62
|
## Testing
|
47
63
|
|
48
64
|
All (cane, RuboCop, unit and integration):
|
49
65
|
|
50
66
|
```shell
|
51
|
-
bundle exec test
|
67
|
+
bundle exec rake test
|
52
68
|
```
|
53
69
|
|
54
70
|
Style (cane and RuboCop):
|
55
71
|
|
56
72
|
```shell
|
57
|
-
bundle exec test:style
|
73
|
+
bundle exec rake test:style
|
58
74
|
```
|
59
75
|
|
60
|
-
|
61
76
|
## Contributing
|
62
77
|
|
63
78
|
1. Fork it ( https://github.com/ashmckenzie/percheron/fork )
|
64
79
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
80
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
-
4.
|
67
|
-
5.
|
81
|
+
4. Run `bundle exec rake test`
|
82
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
83
|
+
6. Create a new Pull Request
|
@@ -4,6 +4,7 @@ module Percheron
|
|
4
4
|
include Base
|
5
5
|
|
6
6
|
DEFAULT_SHELL = '/bin/sh'
|
7
|
+
DOCKER_CLIENT = 'docker'
|
7
8
|
|
8
9
|
def initialize(container, shell: DEFAULT_SHELL)
|
9
10
|
@container = container
|
@@ -11,7 +12,8 @@ module Percheron
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def execute!
|
14
|
-
|
15
|
+
Validators::DockerClient.new.validate_docker_client_available!
|
16
|
+
$logger.debug "Executing #{shell} on '#{container.name}' container"
|
15
17
|
exec!
|
16
18
|
end
|
17
19
|
|
@@ -20,7 +22,7 @@ module Percheron
|
|
20
22
|
attr_reader :container, :shell
|
21
23
|
|
22
24
|
def exec!
|
23
|
-
system('
|
25
|
+
system('%s exec -ti %s %s' % [ DOCKER_CLIENT, container.full_name, shell ])
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/percheron/errors.rb
CHANGED
@@ -8,18 +8,17 @@ module Percheron
|
|
8
8
|
|
9
9
|
def valid?
|
10
10
|
message = rules.return { |rule| send(rule) }
|
11
|
-
|
12
|
-
if message
|
13
|
-
fail Errors::ConfigFileInvalid, message
|
14
|
-
else
|
15
|
-
true
|
16
|
-
end
|
11
|
+
message ? fail(Errors::ConfigFileInvalid, formatted_message(message)) : true
|
17
12
|
end
|
18
13
|
|
19
14
|
private
|
20
15
|
|
21
16
|
attr_reader :config_file
|
22
17
|
|
18
|
+
def formatted_message(message)
|
19
|
+
"Config is invalid: #{message}"
|
20
|
+
end
|
21
|
+
|
23
22
|
def rules
|
24
23
|
[
|
25
24
|
:validate_config_file_defined,
|
@@ -34,24 +33,21 @@ module Percheron
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def validate_config_file_defined
|
37
|
-
'
|
36
|
+
'Is not defined' if config_file.nil?
|
38
37
|
end
|
39
38
|
|
40
39
|
def validate_config_file_existence
|
41
|
-
|
40
|
+
'Does not exist' unless config_file.exist?
|
42
41
|
end
|
43
42
|
|
44
43
|
def validate_config_file_not_empty
|
45
|
-
|
44
|
+
'Is empty' if config_file_contents.empty?
|
46
45
|
end
|
47
46
|
|
48
47
|
def validate_config_file_contents
|
49
|
-
|
48
|
+
'Is invalid' unless config_file_contents.docker
|
50
49
|
end
|
51
50
|
|
52
|
-
def base_message
|
53
|
-
"Config file '#{config_file}'"
|
54
|
-
end
|
55
51
|
end
|
56
52
|
end
|
57
53
|
end
|
@@ -8,12 +8,7 @@ module Percheron
|
|
8
8
|
|
9
9
|
def valid?
|
10
10
|
message = rules.return { |rule| send(rule) }
|
11
|
-
|
12
|
-
if message
|
13
|
-
fail Errors::ContainerInvalid, formatted_message(message)
|
14
|
-
else
|
15
|
-
true
|
16
|
-
end
|
11
|
+
message ? fail(Errors::ContainerInvalid, formatted_message(message)) : true
|
17
12
|
end
|
18
13
|
|
19
14
|
private
|
@@ -41,25 +36,25 @@ module Percheron
|
|
41
36
|
# rubocop:disable Style/GuardClause
|
42
37
|
def validate_name
|
43
38
|
if container.name.nil? || !container.name.to_s.match(/[\w]{3,}/)
|
44
|
-
'
|
39
|
+
'Name is invalid'
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
48
43
|
def validate_dockerfile_and_image_name
|
49
44
|
if container.dockerfile.nil? && container.docker_image.nil?
|
50
|
-
'
|
45
|
+
'Dockerfile OR image name not provided'
|
51
46
|
end
|
52
47
|
end
|
53
48
|
|
54
49
|
def validate_dockerfile
|
55
50
|
if !container.dockerfile.nil? && !File.exist?(container.dockerfile)
|
56
|
-
'
|
51
|
+
'Dockerfile is invalid'
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
60
55
|
def validate_image
|
61
56
|
if !container.docker_image.nil? && !container.docker_image.match(/^.+:.+$/)
|
62
|
-
'
|
57
|
+
'Docker image is invalid'
|
63
58
|
end
|
64
59
|
end
|
65
60
|
# rubocop:enable Style/GuardClause
|
@@ -67,7 +62,7 @@ module Percheron
|
|
67
62
|
def validate_version
|
68
63
|
container.version ? nil : fail(ArgumentError)
|
69
64
|
rescue ArgumentError
|
70
|
-
'
|
65
|
+
'Version is invalid'
|
71
66
|
end
|
72
67
|
|
73
68
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Percheron
|
2
|
+
module Validators
|
3
|
+
class DockerClient
|
4
|
+
|
5
|
+
def valid?
|
6
|
+
message = rules.return { |rule| send(rule) }
|
7
|
+
message ? fail(Errors::DockerClientInvalid, formatted_message(message)) : true
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def formatted_message(message)
|
13
|
+
"Docker client is invalid: #{message}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def rules
|
17
|
+
[
|
18
|
+
:validate_existence,
|
19
|
+
:validate_version
|
20
|
+
]
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate_existence
|
24
|
+
return nil if docker_client_exists?
|
25
|
+
'Is not in your PATH'
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate_version
|
29
|
+
return nil if docker_client_exists? &&
|
30
|
+
Semantic::Version.new(current_version) >= minimum_version
|
31
|
+
"Version is insufficient, need #{minimum_version}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def paths
|
35
|
+
ENV['PATH'].split(File::PATH_SEPARATOR)
|
36
|
+
end
|
37
|
+
|
38
|
+
def docker_client_exists?
|
39
|
+
paths.each do |path|
|
40
|
+
exe = File.join(path, Actions::Shell::DOCKER_CLIENT)
|
41
|
+
return true if File.executable?(exe) && !File.directory?(exe)
|
42
|
+
end
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
def minimum_version
|
47
|
+
@minimum_version ||= Semantic::Version.new('1.6.0')
|
48
|
+
end
|
49
|
+
|
50
|
+
def current_version
|
51
|
+
`#{Actions::Shell::DOCKER_CLIENT} --version`.chomp.match(/version (.+),/)[1]
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -8,24 +8,24 @@ module Percheron
|
|
8
8
|
|
9
9
|
def valid?
|
10
10
|
message = rules.return { |rule| send(rule) }
|
11
|
-
|
12
|
-
if message
|
13
|
-
fail Errors::StackInvalid, message
|
14
|
-
else
|
15
|
-
true
|
16
|
-
end
|
11
|
+
message ? fail(Errors::StackInvalid, formatted_message(message)) : true
|
17
12
|
end
|
18
13
|
|
19
14
|
private
|
20
15
|
|
21
16
|
attr_reader :stack
|
22
17
|
|
18
|
+
def formatted_message(message)
|
19
|
+
"Stack is invalid: #{message}"
|
20
|
+
end
|
21
|
+
|
23
22
|
def rules
|
24
23
|
[ :validate_name ]
|
25
24
|
end
|
26
25
|
|
27
26
|
def validate_name
|
28
|
-
|
27
|
+
return nil if !stack.name.nil? && stack.name.to_s.match(/\w{3,}/)
|
28
|
+
'Name is invalid'
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
data/lib/percheron/validators.rb
CHANGED
data/lib/percheron/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percheron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ash McKenzie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -314,6 +314,7 @@ files:
|
|
314
314
|
- lib/percheron/validators.rb
|
315
315
|
- lib/percheron/validators/config.rb
|
316
316
|
- lib/percheron/validators/container.rb
|
317
|
+
- lib/percheron/validators/docker_client.rb
|
317
318
|
- lib/percheron/validators/stack.rb
|
318
319
|
- lib/percheron/version.rb
|
319
320
|
- percheron.gemspec
|