Module: Cutlass
- Defined in:
- lib/cutlass.rb,
lib/cutlass/app.rb,
lib/cutlass/version.rb,
lib/cutlass/env_diff.rb,
lib/cutlass/pack_build.rb,
lib/cutlass/bash_result.rb,
lib/cutlass/docker_diff.rb,
lib/cutlass/clean_test_env.rb,
lib/cutlass/container_boot.rb,
lib/cutlass/function_query.rb,
lib/cutlass/local_buildpack.rb,
lib/cutlass/container_control.rb
Overview
Defined Under Namespace
Classes: App, BashResult, CleanTestEnv, ContainerBoot, ContainerControl, DockerDiff, EnvDiff, Error, FunctionQuery, LocalBuildpack, PackBuild
Constant Summary
collapse
- VERSION =
"0.3.0"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.default_builder ⇒ Object
23
24
25
|
# File 'lib/cutlass.rb', line 23
def default_builder
@default_builder
end
|
Class Method Details
.config {|_self| ... } ⇒ Object
17
18
19
|
# File 'lib/cutlass.rb', line 17
def self.config
yield self
end
|
.debug? ⇒ Boolean
66
67
68
|
# File 'lib/cutlass.rb', line 66
def self.debug?
ENV["CUTLASS_DEBUG"] || ENV["DEBUG"]
end
|
.default_buildpack_paths ⇒ Object
32
33
34
35
36
|
# File 'lib/cutlass.rb', line 32
def self.default_buildpack_paths
raise "Must set Cutlass.default_buildpack_paths to a non-empty value" if @default_buildpack_paths.empty? || @default_buildpack_paths.nil?
@default_buildpack_paths
end
|
.default_buildpack_paths=(paths) ⇒ Object
26
27
28
29
30
|
# File 'lib/cutlass.rb', line 26
def self.default_buildpack_paths=(paths)
paths = Array(paths).map { |path| path.respond_to?(:exist?) ? path : Pathname(path) }
@default_buildpack_paths = paths
end
|
.default_image_name ⇒ Object
70
71
72
|
# File 'lib/cutlass.rb', line 70
def self.default_image_name
"cutlass_image_#{SecureRandom.hex(10)}"
end
|
.default_repo_dirs ⇒ Object
44
45
46
|
# File 'lib/cutlass.rb', line 44
def self.default_repo_dirs
@default_repo_dirs
end
|
.default_repo_dirs=(dirs) ⇒ Object
40
41
42
|
# File 'lib/cutlass.rb', line 40
def self.default_repo_dirs=(dirs)
@default_repo_dirs = Array(dirs).map { |dir| Pathname(dir) }
end
|
.in_fork ⇒ Object
Runs the block in a process fork to isolate memory or environment changes such as ENV var modifications
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/cutlass.rb', line 76
def self.in_fork
Tempfile.create("stdout") do |tmp_file|
pid = fork do
$stdout.reopen(tmp_file, "a")
$stderr.reopen(tmp_file, "a")
$stdout.sync = true
$stderr.sync = true
yield
Kernel.exit!(0)
end
Process.waitpid(pid)
if $?.success?
print File.read(tmp_file)
else
raise File.read(tmp_file)
end
end
end
|
.resolve_path(path) ⇒ Object
Given a full path that exists it will return the same path. Given the name of a directory within the default repo dirs, it will match and return a full path
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/cutlass.rb', line 51
def self.resolve_path(path)
return Pathname(path) if Dir.exist?(path)
children = @default_repo_dirs.map(&:children).flatten
resolved = children.detect { |p| p.basename.to_s == path }
return resolved if resolved
raise(" No such directory name: \#{path.inspect}\n\n \#{children.map(&:basename).join($/)}\n EOM\nend\n")
|