phoebo 0.3.0 → 0.3.1
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/lib/phoebo/config.rb +2 -2
- data/lib/phoebo/docker/image_builder.rb +5 -3
- data/lib/phoebo/git.rb +13 -1
- data/lib/phoebo/request.rb +9 -8
- data/lib/phoebo/version.rb +1 -1
- data/lib/phoebo/worker.rb +1 -1
- data/spec/phoebo/request_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 417f2a5ace199d80b2fd0184e296115d0433b28b
|
4
|
+
data.tar.gz: a48472fdc0dc01693c9011b05434eb8925d7b7c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c40fdee73ef2bde227405b0b0036278d3ededbb5fc6a2e6a998dd7c6ad5b6d3ddacd205c9ae44bb0e63b13a9edf80e187379112dc706dc4f4e53c7b9f45bb844
|
7
|
+
data.tar.gz: f29199721c935ec9c0566f7d54af0e3f7a8dcaae712a77097fc14b609933ee752557e5ebad7690cb6f5e9651bab82ff9d4e4a7aea76a9b6a66549346788bfa20
|
data/lib/phoebo/config.rb
CHANGED
@@ -7,8 +7,9 @@ module Phoebo
|
|
7
7
|
class ImageBuilder
|
8
8
|
include Console
|
9
9
|
|
10
|
-
def initialize(base_path)
|
10
|
+
def initialize(base_path, request)
|
11
11
|
@base_path = Pathname.new(base_path)
|
12
|
+
@request = request
|
12
13
|
end
|
13
14
|
|
14
15
|
def build(image)
|
@@ -47,8 +48,9 @@ module Phoebo
|
|
47
48
|
stdout.print " virtual size: " + ('%.2f MB' % (built_image.json['VirtualSize'].to_f / 1000 / 1000)).cyan
|
48
49
|
stdout.puts
|
49
50
|
|
50
|
-
|
51
|
-
built_image.
|
51
|
+
tag = @request.ref ? @request.ref[0...8] : 'latest'
|
52
|
+
stdout.puts "Tagging image #{built_image.id.to_s.cyan} -> #{image.name.cyan}#{':'.cyan}#{tag.cyan}"
|
53
|
+
built_image.tag('repo' => image.name, 'tag' => tag, 'force' => true)
|
52
54
|
|
53
55
|
# Return image ID
|
54
56
|
built_image.id
|
data/lib/phoebo/git.rb
CHANGED
@@ -16,9 +16,21 @@ module Phoebo
|
|
16
16
|
|
17
17
|
# Clone remote repository
|
18
18
|
begin
|
19
|
-
Rugged::Repository.clone_at request.repo_url,
|
19
|
+
repo = Rugged::Repository.clone_at request.repo_url,
|
20
20
|
clone_path, credentials: cred
|
21
21
|
|
22
|
+
if request.ref
|
23
|
+
if request.ref =~ /^[0-9a-f]+$/i
|
24
|
+
if repo.exists?(request.ref.downcase)
|
25
|
+
repo.checkout(request.ref.downcase, strategy: :force)
|
26
|
+
else
|
27
|
+
raise IOError, "Unable to find commit #{request.ref}. Git checkout failed."
|
28
|
+
end
|
29
|
+
else
|
30
|
+
raise IOError, "Invalid commit reference #{request.ref}. Git checkout failed."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
22
34
|
rescue Rugged::SshError => e
|
23
35
|
raise unless e.message.include?('auth')
|
24
36
|
raise IOError, "Unable to clone remote repository. SSH authentication failed."
|
data/lib/phoebo/request.rb
CHANGED
@@ -8,7 +8,8 @@ module Phoebo
|
|
8
8
|
# input from multiple sources (HTTP request, CLI options) and provides data
|
9
9
|
# validation with human-readable error messages.
|
10
10
|
class Request
|
11
|
-
attr_accessor :repo_url, :
|
11
|
+
attr_accessor :repo_url, :ref
|
12
|
+
attr_accessor :ssh_user, :ssh_private_file, :ssh_public_file
|
12
13
|
attr_accessor :docker_user, :docker_password, :docker_email
|
13
14
|
attr_accessor :id, :ping_url
|
14
15
|
attr_writer :temp_file_manager
|
@@ -36,19 +37,19 @@ module Phoebo
|
|
36
37
|
IO.write(@ssh_public_file, key_content)
|
37
38
|
end
|
38
39
|
|
39
|
-
#
|
40
|
-
def
|
41
|
-
@
|
40
|
+
# Params (default: empty hash)
|
41
|
+
def params
|
42
|
+
@params ||= {}
|
42
43
|
end
|
43
44
|
|
44
|
-
#
|
45
|
-
def
|
45
|
+
# Params validation on set
|
46
|
+
def params=(hash)
|
46
47
|
hash.each do |key, value|
|
47
|
-
raise InvalidRequestError, "Invalid format for request
|
48
|
+
raise InvalidRequestError, "Invalid format for request parameter #{key.inspect}" \
|
48
49
|
unless value.is_a? String or value.is_a? Numeric
|
49
50
|
end
|
50
51
|
|
51
|
-
@
|
52
|
+
@params = hash
|
52
53
|
end
|
53
54
|
|
54
55
|
# Loads request with data from hash
|
data/lib/phoebo/version.rb
CHANGED
data/lib/phoebo/worker.rb
CHANGED
@@ -23,7 +23,7 @@ module Phoebo
|
|
23
23
|
config = Config.new_from_file(config_path, @request)
|
24
24
|
|
25
25
|
# Build & push image
|
26
|
-
builder = Docker::ImageBuilder.new(path)
|
26
|
+
builder = Docker::ImageBuilder.new(path, @request)
|
27
27
|
config.images.each do |image|
|
28
28
|
image_id = builder.build(image)
|
29
29
|
pusher.push(image_id) if @request.docker_user
|
data/spec/phoebo/request_spec.rb
CHANGED
@@ -86,7 +86,7 @@ describe Phoebo::Request do
|
|
86
86
|
<<-EOS
|
87
87
|
{
|
88
88
|
"repo_url": "ssh://somehost.tld/user/repo.git",
|
89
|
-
"
|
89
|
+
"params": {
|
90
90
|
"dbpassword": "somesecretpassword"
|
91
91
|
}
|
92
92
|
}
|
@@ -109,7 +109,7 @@ describe Phoebo::Request do
|
|
109
109
|
it 'applies arguments' do
|
110
110
|
subject.load_from_json!(json)
|
111
111
|
expect(subject.repo_url).to eql('ssh://somehost.tld/user/repo.git')
|
112
|
-
expect(subject.
|
112
|
+
expect(subject.params[:dbpassword]).to eql('somesecretpassword')
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phoebo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Staněk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|