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
–.
-
#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
–.
-
#clean_cache? ⇒ Boolean
–.
-
#copy_dir(*path) ⇒ Object
– The directory you store your image data in (by default ‘copy/`.) –.
-
#initialize(*hashes) ⇒ Repo
constructor
–.
-
#meta ⇒ Object
–.
-
#pushable? ⇒ Boolean
–.
-
#tmpdir(*args, root: Template.tmpdir) ⇒ Object
–.
-
#tmpfile(*args, root: Template.tmpdir) ⇒ 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
–
12 13 14 15 16 17 18 19 20 21 22 |
# 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 |
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`. –
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/docker/template/repo.rb', line 61 def aliased full = Parser.full_name?( .aliased_tag ) if alias? && full self.class.new(to_h.merge(Parser.to_repo_hash( .aliased_tag ))) elsif alias? self.class.new(to_h.merge({ "tag" => .aliased_tag })) end rescue Error::RepoNotFound => e unless full raise e end end |
#buildable? ⇒ Boolean
–
50 51 52 53 54 55 |
# File 'lib/docker/template/repo.rb', line 50 def buildable? .build? && !["push_only"] && !["cache_only"] && ![ "clean_only" ] end |
#builder ⇒ Object
– Initializes and returns the builder so that you can build the repo. –
86 87 88 89 90 91 92 |
# 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 ⇒ Object
– The directory you wish to cache to (like ‘cache/`) or other. –
107 108 109 110 111 |
# File 'lib/docker/template/repo.rb', line 107 def cache_dir return root.join( ["cache_dir"], tag ) end |
#cacheable? ⇒ Boolean
–
35 36 37 38 39 40 |
# File 'lib/docker/template/repo.rb', line 35 def cacheable? (["cache"] || ["cache_only"]) && ![ "push_only" ] end |
#clean_cache? ⇒ Boolean
–
44 45 46 |
# File 'lib/docker/template/repo.rb', line 44 def clean_cache? (["clean"] || ["clean_only"]) end |
#copy_dir(*path) ⇒ Object
– The directory you store your image data in (by default ‘copy/`.) –
116 117 118 119 120 121 |
# File 'lib/docker/template/repo.rb', line 116 def copy_dir(*path) dir = ["copy_dir"] root.join( dir, *path ) end |
#meta ⇒ Object
–
192 193 194 195 196 197 198 |
# File 'lib/docker/template/repo.rb', line 192 def return @meta ||= begin Meta.new( @base_meta ) end end |
#pushable? ⇒ Boolean
–
26 27 28 29 30 31 |
# File 'lib/docker/template/repo.rb', line 26 def pushable? (["push"] || ["push_only"]) && !["cache_only"] && ![ "clean_only" ] end |
#tmpdir(*args, root: Template.tmpdir) ⇒ Object
–
145 146 147 148 149 150 |
# File 'lib/docker/template/repo.rb', line 145 def tmpdir(*args, root: Template.tmpdir) args.unshift(user, name, tag) Pathutil.tmpdir( args, nil, root ) end |
#tmpfile(*args, root: Template.tmpdir) ⇒ Object
–
154 155 156 157 158 159 |
# File 'lib/docker/template/repo.rb', line 154 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) ⇒ Object
–
202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/docker/template/repo.rb', line 202 def to_env(tar_gz: nil, copy_dir: nil) hash = ["env"] || { "all" => {}} Meta.new(hash, :root => ).merge({ "REPO" => name, "TAR_GZ" => tar_gz, "GROUP" => .group, "DEBUG" => .debug?? "true" : "", "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. –
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/docker/template/repo.rb', line 166 def to_repos if Template.project? then Set.new([ self ]) else set = Set.new if @base_meta.key?("tag") set << self else .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 ⇒ Object
–
135 136 137 138 139 140 141 |
# File 'lib/docker/template/repo.rb', line 135 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. –
98 99 100 101 102 |
# File 'lib/docker/template/repo.rb', line 98 def to_s(rootfs: false) prefix = ["local_prefix"] return "#{user}/#{name}:#{tag}" unless rootfs "#{prefix}/rootfs:#{name}" end |
#to_tag_h ⇒ Object
–
125 126 127 128 129 130 131 |
# File 'lib/docker/template/repo.rb', line 125 def to_tag_h { "tag" => tag, "repo" => "#{user}/#{name}", "force" => true } end |