class Docker::Template::Repo
Public Class Methods
new(*hashes)
click to toggle source
–
# File lib/docker/template/repo.rb, line 12 def initialize(*hashes) @base_meta = hashes.compact @base_meta = @base_meta.reduce(:deep_merge) @base_meta.freeze unless root.exist? raise( Error::RepoNotFound, name ) end end
Public Instance Methods
aliased()
click to toggle source
– Pulls out the repo this repo is aliasing it, this happens when you when you set the tag in the “alias” section of your `opts.yml`. –
# File lib/docker/template/repo.rb, line 61 def aliased full = Parser.full_name?( meta.aliased_tag ) if alias? && full self.class.new(to_h.merge(Parser.to_repo_hash( meta.aliased_tag ))) elsif alias? self.class.new(to_h.merge({ "tag" => meta.aliased_tag })) end rescue Error::RepoNotFound => e unless full raise e end end
buildable?()
click to toggle source
–
# File lib/docker/template/repo.rb, line 50 def buildable? meta.build? && !meta["push_only"] && !meta["cache_only"] && !meta[ "clean_only" ] end
builder()
click to toggle source
– Initializes and returns the builder so that you can build the repo. –
# File lib/docker/template/repo.rb, line 86 def builder return @builder ||= begin Template::Builder.const_get(type.capitalize).new( self ) end end
cache_dir()
click to toggle source
– The directory you wish to cache to (like `cache/`) or other. –
# File lib/docker/template/repo.rb, line 107 def cache_dir return root.join( meta["cache_dir"], tag ) end
cacheable?()
click to toggle source
–
# File lib/docker/template/repo.rb, line 35 def cacheable? (meta["cache"] || meta["cache_only"]) && !meta[ "push_only" ] end
clean_cache?()
click to toggle source
–
# File lib/docker/template/repo.rb, line 44 def clean_cache? (meta["clean"] || meta["clean_only"]) end
copy_dir(*path)
click to toggle source
– The directory you store your image data in (by default `copy/`.) –
# File lib/docker/template/repo.rb, line 116 def copy_dir(*path) dir = meta["copy_dir"] root.join( dir, *path ) end
meta()
click to toggle source
–
# File lib/docker/template/repo.rb, line 191 def meta return @meta ||= begin Meta.new( @base_meta ) end end
pushable?()
click to toggle source
–
# File lib/docker/template/repo.rb, line 26 def pushable? (meta["push"] || meta["push_only"]) && !meta["cache_only"] && !meta[ "clean_only" ] end
tmpdir(*args, root: Template.tmpdir)
click to toggle source
–
# File lib/docker/template/repo.rb, line 145 def tmpdir(*args, root: Template.tmpdir) args.unshift(user.gsub(/[^A-Za-z0-9_\-]+/, "--"), name, tag) out = Pathutil.tmpdir(args, nil, root) out.realpath end
tmpfile(*args, root: Template.tmpdir)
click to toggle source
–
# File lib/docker/template/repo.rb, line 153 def tmpfile(*args, root: Template.tmpdir) args.unshift(user, name, tag) Pathutil.tmpfile( args, nil, root ) end
to_env(tar_gz: nil, copy_dir: nil)
click to toggle source
–
# File lib/docker/template/repo.rb, line 201 def to_env(tar_gz: nil, copy_dir: nil) hash = meta["env"] || { "all" => {}} Meta.new(hash, :root => meta).merge({ "REPO" => name, "TAR_GZ" => tar_gz, "GROUP" => meta.group, "DEBUG" => meta.debug?? "true" : "", "COPY_DIR" => copy_dir, "BUILD_TYPE" => type, "TAG" => tag }) end
to_repos()
click to toggle source
– If a tag was given then it returns [self] and if a tag was not sent it then goes on to detect the type and split itself accordingly returning multiple, AKA all repos that should be built. –
# File lib/docker/template/repo.rb, line 165 def to_repos if Template.project? then Set.new([ self ]) else set = Set.new if @base_meta.key?("tag") set << self else tags.each do |tag| hash = Parser.from_tag_to_repo_hash(tag) hash = to_h.merge(hash) set << self.class.new( hash, @cli_opts ) end end set end end
to_rootfs_h()
click to toggle source
–
# File lib/docker/template/repo.rb, line 135 def to_rootfs_h { "tag" => name, "repo" => "#{meta["local_prefix"]}/rootfs", "force" => true } end
to_s(rootfs: false)
click to toggle source
– Convert the repo into it's final image name, however if you tell, us this is a rootfs build we will convert it into the rootfs name. –
# File lib/docker/template/repo.rb, line 98 def to_s(rootfs: false) prefix = meta["local_prefix"] return "#{user}/#{name}:#{tag}" unless rootfs "#{prefix}/rootfs:#{name}" end
to_tag_h()
click to toggle source
–
# File lib/docker/template/repo.rb, line 125 def to_tag_h { "tag" => tag, "repo" => "#{user}/#{name}", "force" => true } end