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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99090a0ea219f65bfefe343d797e5569d01ed9e2
4
- data.tar.gz: 48f00da413d5e5923906bbcd4b04a3dd5350cd73
3
+ metadata.gz: 417f2a5ace199d80b2fd0184e296115d0433b28b
4
+ data.tar.gz: a48472fdc0dc01693c9011b05434eb8925d7b7c6
5
5
  SHA512:
6
- metadata.gz: 40abf6542d1aaed1cfb89246a87e909be330066fef1ee2ec04cb03d3626b5e914e1fa5c9b904a7a4c53c28277f117e4c96659a4ed5e40be26ab202f9e380cb0e
7
- data.tar.gz: 82a50760a0b290e2eed500d92480d0ae0c641a883735addccc2f973aa5228db76a02603d40ea4f67827940f6aad874522128a84aa44193de3a5661ed690b75a3
6
+ metadata.gz: c40fdee73ef2bde227405b0b0036278d3ededbb5fc6a2e6a998dd7c6ad5b6d3ddacd205c9ae44bb0e63b13a9edf80e187379112dc706dc4f4e53c7b9f45bb844
7
+ data.tar.gz: f29199721c935ec9c0566f7d54af0e3f7a8dcaae712a77097fc14b609933ee752557e5ebad7690cb6f5e9651bab82ff9d4e4a7aea76a9b6a66549346788bfa20
data/lib/phoebo/config.rb CHANGED
@@ -61,8 +61,8 @@ module Phoebo
61
61
  @request = request
62
62
  end
63
63
 
64
- def secrets
65
- @request ? @request.secrets : {}
64
+ def params
65
+ @request ? @request.params : {}
66
66
  end
67
67
 
68
68
  def image(name, options, &block)
@@ -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
- stdout.puts "Tagging image #{built_image.id.to_s.cyan} -> #{image.name.cyan}"
51
- built_image.tag('repo' => image.name, 'force' => true)
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."
@@ -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, :ssh_user, :ssh_private_file, :ssh_public_file
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
- # Secrets (default: empty hash)
40
- def secrets
41
- @secrets ||= {}
40
+ # Params (default: empty hash)
41
+ def params
42
+ @params ||= {}
42
43
  end
43
44
 
44
- # Secrets validation on set
45
- def secrets=(hash)
45
+ # Params validation on set
46
+ def params=(hash)
46
47
  hash.each do |key, value|
47
- raise InvalidRequestError, "Invalid format for request secret #{key.inspect}" \
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
- @secrets = hash
52
+ @params = hash
52
53
  end
53
54
 
54
55
  # Loads request with data from hash
@@ -1,3 +1,3 @@
1
1
  module Phoebo
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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
@@ -86,7 +86,7 @@ describe Phoebo::Request do
86
86
  <<-EOS
87
87
  {
88
88
  "repo_url": "ssh://somehost.tld/user/repo.git",
89
- "secrets": {
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.secrets[:dbpassword]).to eql('somesecretpassword')
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.0
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-08 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize