Module: Docker::Template
- Defined in:
- lib/docker/template.rb,
lib/docker/template/ansi.rb,
lib/docker/template/auth.rb,
lib/docker/template/repo.rb,
lib/docker/template/util.rb,
lib/docker/template/alias.rb,
lib/docker/template/error.rb,
lib/docker/template/common.rb,
lib/docker/template/config.rb,
lib/docker/template/parser.rb,
lib/docker/template/rootfs.rb,
lib/docker/template/simple.rb,
lib/docker/template/stream.rb,
lib/docker/template/scratch.rb,
lib/docker/template/version.rb,
lib/docker/template/metadata.rb,
lib/docker/template/routable.rb,
lib/docker/template/interface.rb,
lib/docker/template/util/copy.rb,
lib/docker/template/util/data.rb,
lib/docker/template/error/bad_repo_name.rb,
lib/docker/template/error/repo_not_found.rb,
lib/docker/template/error/bad_exit_status.rb,
lib/docker/template/error/no_rootfs_mkimg.rb,
lib/docker/template/error/not_implemented.rb,
lib/docker/template/error/invalid_repo_type.rb,
lib/docker/template/error/invalid_targz_file.rb,
lib/docker/template/error/no_rootfs_copy_dir.rb,
lib/docker/template/error/no_setup_context_found.rb
Defined Under Namespace
Modules: Ansi, Auth, Error, Routable, Util
Classes: Alias, Common, Config, Interface, Metadata, Parser, Repo, Rootfs, Scratch, Simple, Stream
Constant Summary
collapse
- VERSION =
"0.2.0"
Class Method Summary
collapse
Class Method Details
40
41
42
43
44
|
# File 'lib/docker/template.rb', line 40
def config
@config ||= begin
Config.new
end
end
|
Provides the root to Docker template, wherever it is installed so that we can do things, mostly ignore files for the profiler. Otherwise it’s not really used, it’s just an encapsulator.
75
76
77
78
79
80
|
# File 'lib/docker/template.rb', line 75
def gem_root
@gem_root ||= begin
path = File.expand_path("../../", __dir__)
Pathname.new(path)
end
end
|
.get(name, data = {}) ⇒ Object
93
94
95
96
97
|
# File 'lib/docker/template.rb', line 93
def get(name, data = {})
data = Util::Data.new(data)
template = template_root.join("#{name}.erb").read
ERB.new(template).result(data._binding)
end
|
.repo_is_root? ⇒ Boolean
36
37
38
|
# File 'lib/docker/template.rb', line 36
def repo_is_root?
root.join("copy").exist? && !root.join("../..", config["repos_dir"]).exist?
end
|
.repo_root_for(name) ⇒ Object
67
68
69
|
# File 'lib/docker/template.rb', line 67
def repo_root_for(name)
repo_is_root?? root : repos_root.join(name)
end
|
.repos_root ⇒ Object
The location of the standard repos/ dir, you can change this by adding repos_dir into your configuration file. I’m not saying it has to be but it should probably be relative rather than absolute, ther are no guarantees that an absolute path will work.
59
60
61
62
63
|
# File 'lib/docker/template.rb', line 59
def repos_root
@repos_root ||= begin
root.join(config["repos_dir"])
end
end
|
48
49
50
51
52
|
# File 'lib/docker/template.rb', line 48
def root
@root ||= begin
Pathname.new(Dir.pwd)
end
end
|
.template_root ⇒ Object
Provides the templates directory so you can quickly pull a template from our templates and use it if you wish to.
85
86
87
88
89
|
# File 'lib/docker/template.rb', line 85
def template_root
@template_root ||= begin
gem_root.join("lib/docker/template/templates")
end
end
|