dg 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dg/docker.rb +25 -34
  3. data/lib/dg/version.rb +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ea454cd0784d6c489275883291af104a9ea7b1f
4
- data.tar.gz: 1ed46c4d42a64c437a8afbbadb68a961f6a9fc11
3
+ metadata.gz: 1f2697a1942c1cec67fa2f558092e415ab6f258e
4
+ data.tar.gz: d024cc464d6141114383cc7ecc26707d167bfc1b
5
5
  SHA512:
6
- metadata.gz: bd252529938d78224bffeaa4e024610c3000d899839572e2bbdd7671f0ee86c46acbedb4e0017b812e29e88cb4365984588726371c5a0386c2638001579161f2
7
- data.tar.gz: 20b50abd57ee7caccf42e2346734fdec9eaf8a4c3fb8b7fe81183095a1d485db2b14761c013c05c5ca8c982663aa8fa83e99185c6ef46d71a50128b8c3f7bb60
6
+ metadata.gz: b0f8de197ce927c3ed31cf783f4636b63e514d194133f4bbe0c2ad2382f8ecc7dc23ca51e7231a9e372d0538609fd110390d66419c71203e5e68d89d85872089
7
+ data.tar.gz: aee5dfefd7f72ad46b6a677a22329a3fe4af32c0593e01adbcfa3b5754373c8819977241489f4c7d1944b1456e54f08fb6fa05e1940ef90db1a7ab85e4a32140
data/lib/dg/docker.rb CHANGED
@@ -45,30 +45,13 @@ module DG
45
45
  end
46
46
 
47
47
  def deploy_stages
48
- candidates = Dir['deploy-to*']
49
- if candidates.size == 1
50
- script = candidates.first
51
- if File.executable?(script)
52
- branch = ENV['GIT_BRANCH'] ||
53
- `git symbolic-ref --short -q HEAD`.strip
54
- return `./#{script} #{branch}`.strip.split(',')
55
- else
56
- error!(
57
- RuntimeError.new(
58
- %(Deploy-to script: "#{script}" must be executable! (e.g. chmod +x #{script}))
59
- ),
60
- "determining stage to deploy to"
61
- )
62
- end
63
- else
64
- error!(
65
- RuntimeError.new(
66
- "There must be a deploy-to* script " +
67
- "(e.g. deploy-to.{rb|sh|js}): #{candidates.size} found"
68
- ),
69
- "determining stage to deploy to"
70
- )
71
- end
48
+ generate_fig_yaml
49
+ branch = ENV['GIT_BRANCH'] ||
50
+ `git symbolic-ref --short -q HEAD`.strip
51
+
52
+ run_with_output(
53
+ "fig -f #{FIG_GEN_PATH} run deployto", capture = true
54
+ ).strip.split(',')
72
55
  end
73
56
 
74
57
  def run
@@ -93,18 +76,26 @@ module DG
93
76
  exit 1
94
77
  end
95
78
 
96
- def run_with_output(command)
79
+ def run_with_output(command, capture = false)
97
80
  sudo_command = SUDO ? "sudo -E bash -c '#{command}'" : command
98
81
  puts "Running `#{sudo_command}` in #{Dir.pwd}"
99
- PTY.spawn(sudo_command) do |stdin, stdout, pid|
100
- stdin.each { |line| print line } rescue Errno::EIO
101
- Process.wait(pid)
82
+ if capture
83
+ return `#{command}`
84
+ else
85
+ begin
86
+ PTY.spawn(sudo_command) do |stdin, stdout, pid|
87
+ stdin.each { |line| print line } rescue Errno::EIO
88
+ Process.wait(pid)
89
+ end
90
+ status_code = $?.exitstatus
91
+
92
+ error!(RuntimeError.new("exit code was #{status_code}"), "executing #{command}") if status_code != 0
93
+
94
+ return status_code
95
+ rescue PTY::ChildExited
96
+ puts "The child process exited!"
97
+ end
102
98
  end
103
- status_code = $?.exitstatus
104
-
105
- error!(RuntimeError.new("exit code was #{status_code}"), "executing #{command}") if status_code != 0
106
- rescue PTY::ChildExited
107
- puts "The child process exited!"
108
99
  end
109
100
 
110
101
  def fig_yml
@@ -125,7 +116,7 @@ module DG
125
116
  # Add the git commit hash to the image name
126
117
  def git_image_name
127
118
  @@git_image_name ||=
128
- "#{image_name}:#{ENV['GO_REVISION_BITBUCKET'] ||
119
+ "#{image_name}:#{ENV['GO_REVISION_#{MATERIAL_NAME}'] ||
129
120
  `git rev-parse HEAD`.strip}"
130
121
  end
131
122
 
data/lib/dg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DG
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Malet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-03 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  DockerGo (DG)
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  version: '0'
57
57
  requirements: []
58
58
  rubyforge_project:
59
- rubygems_version: 2.2.2
59
+ rubygems_version: 2.4.3
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Provides integration between Docker and GoCD.