cutlass 0.1.2 → 0.1.7

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
  SHA256:
3
- metadata.gz: 961e907148a5b772e1b645f2d7e85d6740cd65f7cb30d6e349f06c4fb4b02d93
4
- data.tar.gz: f9d03dbdcbd11888f27ebbf8ce31f476a6bf6d0255ad8f6104aa582cf7d7a9f1
3
+ metadata.gz: a26c39e3aed992a3bce384c77603c159473bdb1a0f39bd86e996806ce26c6c3e
4
+ data.tar.gz: d829ea4b01eef4b6ac709510cafcac39768b2470852a4db12f8b04fa26231a34
5
5
  SHA512:
6
- metadata.gz: 296d6173de09abeb96b1db5c2a6aa7bf76b6e8f0b989ca56209fca31fd7316b1a6286f4f4fa7b4cd803c91d588fa239402bc1b2590212322849eaf6390d7167f
7
- data.tar.gz: a9b811887444f5ac573df9b456119d834fff5ad86b36f3f6809e0ef4590f788ed43bfe6095371563fc548058c9d030e5ccfb92e697841123eeb6e1d9382c08ed
6
+ metadata.gz: 39ceffa9e16f1b0c76e3894bdca69d6bd6a83a19ec90d4f34a593e7361935672800befb0761339571a2cb3dcf4434d8e21f5e96550160038adf9e4d4dc2789a1
7
+ data.tar.gz: f59429e16a53e8085dbf57fe86ef132e365df58bb014f13d2588814c0617235c9f3f6de389a302243f2cdfa6f6d28ea0f500e0f72e094837666825451fdfff37
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  ## [Unreleased]
2
2
 
3
+ - Lock LocalBuildpack when generating images to prevent process race conditions https://github.com/heroku/cutlass/pull/9
4
+
5
+ ## 0.1.6
6
+
7
+ - Remove premature error checking from Cutlass.default_buildpack_paths https://github.com/heroku/cutlass/pull/8
8
+
9
+ ## 0.1.5
10
+
11
+ - Expect build.sh scripts to produce a directory named "target" https://github.com/heroku/cutlass/pull/7
12
+
13
+ ## 0.1.4
14
+
15
+ - Cutlass.default_buildpack_paths= now accepts a LocalBuildpack https://github.com/heroku/cutlass/pull/6
16
+
17
+ ## 0.1.3
18
+
19
+ - Do not connect to docker if it's not needed https://github.com/heroku/cutlass/pull/5
20
+
3
21
  ## 0.1.2
4
22
 
5
23
  - App.new accepts a buildpack array with the `:default` symbol which acts as a shortcut for `Cutlass.default_buildpack_paths` https://github.com/heroku/cutlass/pull/4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cutlass (0.1.2)
4
+ cutlass (0.1.7)
5
5
  docker-api (>= 2.0)
6
6
 
7
7
  GEM
data/lib/cutlass.rb CHANGED
@@ -24,11 +24,7 @@ module Cutlass
24
24
  end
25
25
 
26
26
  def self.default_buildpack_paths=(paths)
27
- paths = Array(paths).map { |path| Pathname(path) }
28
-
29
- paths.each do |path|
30
- raise "Path must exist on disk #{path}" unless path.exist?
31
- end
27
+ paths = Array(paths).map { |path| path.respond_to?(:exist?) ? path : Pathname(path) }
32
28
 
33
29
  @default_buildpack_paths = paths
34
30
  end
@@ -35,9 +35,9 @@ module Cutlass
35
35
  @skip_keys << key
36
36
  end
37
37
 
38
- def self.record
38
+ def self.record(docker: ENV["CUTLASS_CHECK_DOCKER"])
39
39
  @env_diff = EnvDiff.new(skip_keys: @skip_keys)
40
- @docker_diff = DockerDiff.new
40
+ @docker_diff = DockerDiff.new if docker
41
41
  end
42
42
 
43
43
  def self.check(docker: ENV["CUTLASS_CHECK_DOCKER"])
@@ -29,8 +29,9 @@ module Cutlass
29
29
 
30
30
  def bash_exec(cmd, exception_on_failure: true)
31
31
  stdout_ish, stderr, status = @container.exec(["bash", "-c", cmd])
32
+ stdout = stdout_ish.first
32
33
 
33
- result = BashResult.new(stdout: stdout_ish.first, stderr: stderr, status: status)
34
+ result = BashResult.new(stdout: stdout, stderr: stderr, status: status)
34
35
 
35
36
  return result if result.success?
36
37
  return result unless exception_on_failure
@@ -29,6 +29,20 @@ module Cutlass
29
29
  @built = false
30
30
  @directory = Pathname(directory)
31
31
  @image_name = "cutlass_local_buildpack_#{SecureRandom.hex(10)}"
32
+
33
+ @mutex_file = Tempfile.new
34
+ end
35
+
36
+ def file_lock
37
+ file = File.open(@mutex_file.path, File::CREAT)
38
+ file.flock(File::LOCK_EX)
39
+ yield
40
+ ensure
41
+ file.close
42
+ end
43
+
44
+ def exist?
45
+ @directory.exist?
32
46
  end
33
47
 
34
48
  def teardown
@@ -44,13 +58,14 @@ module Cutlass
44
58
  end
45
59
 
46
60
  def call
47
- return if built?
48
- raise "must be directory: #{@directory}" unless @directory.directory?
49
-
50
- @built = true
61
+ file_lock do
62
+ return if built?
63
+ raise "must be directory: #{@directory}" unless @directory.directory?
64
+ @built = true
51
65
 
52
- call_build_sh
53
- call_pack_buildpack_package
66
+ call_build_sh
67
+ call_pack_buildpack_package
68
+ end
54
69
 
55
70
  self
56
71
  end
@@ -86,7 +101,11 @@ module Cutlass
86
101
  puts result.stdout if Cutlass.debug?
87
102
  puts result.stderr if Cutlass.debug?
88
103
 
89
- return if result.success?
104
+ if result.success?
105
+ @directory = @directory.join("target")
106
+ raise "Expected #{build_sh} to produce a directory #{@directory} but it did not" unless @directory.exist?
107
+ return
108
+ end
90
109
 
91
110
  raise <<~EOM
92
111
  Buildpack build step failed!
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Cutlass
4
4
  # Version
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.7"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cutlass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - schneems
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2021-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api