Class: Docker::Template::Repo
- Inherits:
-
Object
- Object
- Docker::Template::Repo
- Extended by:
- Forwardable::Extended
- Defined in:
- lib/docker/template/repo.rb
Instance Method Summary collapse
-
#aliased ⇒ Object
———————————————————————- 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. -
#buildable? ⇒ Boolean
———————————————————————- Determines whether or not we should (or you should) build the repo.
-
#builder ⇒ Object
———————————————————————- Initializes and returns the builder so that you can build the repo.
-
#cache_dir ⇒ Object
———————————————————————- The directory you wish to cache to (like
cache/) or other. -
#cacheable? ⇒ Boolean
———————————————————————- Determines whether or not we should (or you should) cache the repo.
-
#copy_dir(*path) ⇒ Object
———————————————————————- The directory you store your image data in (by default
copy/.) ———————————————————————-. -
#initialize(*hashes) ⇒ Repo
constructor
———————————————————————-.
-
#metadata ⇒ Object
———————————————————————-.
-
#pushable? ⇒ Boolean
———————————————————————- Determines whether or not we should (or you should) push the repo.
-
#tmpdir(*args, root: nil) ⇒ Object
———————————————————————-.
-
#tmpfile(*args, root: nil) ⇒ Object
———————————————————————-.
-
#to_env(tar_gz: nil, copy_dir: nil) ⇒ Object
———————————————————————-.
-
#to_repos ⇒ Object
———————————————————————- 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.
-
#to_rootfs_h ⇒ Object
———————————————————————-.
-
#to_s(rootfs: false) ⇒ Object
———————————————————————- 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.
-
#to_tag_h ⇒ Object
———————————————————————-.
Constructor Details
#initialize(*hashes) ⇒ Repo
14 15 16 17 |
# File 'lib/docker/template/repo.rb', line 14 def initialize(*hashes) @base_meta = hashes.compact.reduce(:deep_merge).freeze raise Error::RepoNotFound, name unless root.exist? end |
Instance Method Details
#aliased ⇒ Object
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.
54 55 56 57 58 59 60 |
# File 'lib/docker/template/repo.rb', line 54 def aliased if alias? self.class.new(to_h.merge({ "tag" => .aliased_tag })) end end |
#buildable? ⇒ Boolean
Determines whether or not we should (or you should) build the repo.
43 44 45 46 47 |
# File 'lib/docker/template/repo.rb', line 43 def buildable? !["push_only"] && !["cache_only"] && ![ "clean_only" ] end |
#builder ⇒ Object
Initializes and returns the builder so that you can build the repo.
66 67 68 69 70 71 72 |
# File 'lib/docker/template/repo.rb', line 66 def builder return @builder ||= begin Template.const_get(type.capitalize).new( self ) end end |
#cache_dir ⇒ Object
The directory you wish to cache to (like cache/) or other.
89 90 91 92 93 |
# File 'lib/docker/template/repo.rb', line 89 def cache_dir return root.join( ["cache_dir"], tag ) end |
#cacheable? ⇒ Boolean
Determines whether or not we should (or you should) cache the repo.
33 34 35 36 37 |
# File 'lib/docker/template/repo.rb', line 33 def cacheable? (["cache"] || ["cache_only"]) && ![ "push_only" ] end |
#copy_dir(*path) ⇒ Object
The directory you store your image data in (by default copy/.)
99 100 101 102 103 104 |
# File 'lib/docker/template/repo.rb', line 99 def copy_dir(*path) dir = ["copy_dir"] root.join(dir, *path ) end |
#metadata ⇒ Object
167 168 169 170 171 172 173 |
# File 'lib/docker/template/repo.rb', line 167 def return @metadata ||= begin Metadata.new( @base_meta ) end end |
#pushable? ⇒ Boolean
Determines whether or not we should (or you should) push the repo.
23 24 25 26 27 |
# File 'lib/docker/template/repo.rb', line 23 def pushable? (["push"] || ["push_only"]) && ![ "cache_only" ] end |
#tmpdir(*args, root: nil) ⇒ Object
128 129 130 131 132 133 |
# File 'lib/docker/template/repo.rb', line 128 def tmpdir(*args, root: nil) args.unshift(user, name, tag) Pathutil.tmpdir(args, nil, root ) end |
#tmpfile(*args, root: nil) ⇒ Object
137 138 139 140 141 142 |
# File 'lib/docker/template/repo.rb', line 137 def tmpfile(*args, root: nil) args.unshift(user, name, tag) Pathutil.tmpfile(args, nil, root ) end |
#to_env(tar_gz: nil, copy_dir: nil) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/docker/template/repo.rb', line 177 def to_env(tar_gz: nil, copy_dir: nil) hash = ["env"] || { "all" => {}} Metadata.new(hash, :root => ).merge({ "REPO" => name, "TAR_GZ" => tar_gz, "GROUP" => .group, "COPY_DIR" => copy_dir, "BUILD_TYPE" => type, "TAG" => tag }) end |
#to_repos ⇒ Object
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.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/docker/template/repo.rb', line 150 def to_repos set = Set.new if @base_meta.key?("tag") set << self else .each do |tag| hash = to_h.merge("tag" => tag) set << self.class.new( hash, @cli_opts ) end end set end |
#to_rootfs_h ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/docker/template/repo.rb', line 118 def to_rootfs_h { "tag" => name, "repo" => "#{["local_prefix"]}/rootfs", "force" => true } end |
#to_s(rootfs: false) ⇒ Object
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.
79 80 81 82 83 |
# File 'lib/docker/template/repo.rb', line 79 def to_s(rootfs: false) prefix = ["local_prefix"] return "#{user}/#{name}:#{tag}" unless rootfs "#{prefix}/rootfs:#{name}" end |
#to_tag_h ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/docker/template/repo.rb', line 108 def to_tag_h { "tag" => tag, "repo" => "#{user}/#{name}", "force" => true } end |