Class: FPM::Package::Docker
- Inherits:
-
FPM::Package
- Object
- FPM::Package
- FPM::Package::Docker
- Defined in:
- lib/fpm/package/docker.rb
Overview
An FPM::Package that loads files from a docker container diff.
Defined Under Namespace
Classes: Node
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#keep_modified_files ⇒ Object
readonly
Returns the value of attribute keep_modified_files.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Docker
constructor
A new instance of Docker.
-
#input(name) ⇒ Object
Loads all files from a docker container with the given name to the staging path.
-
#split(name, map) ⇒ Object
Loads all files from a docker container into multiple paths defined by map param.
Constructor Details
#initialize(options = {}) ⇒ Docker
Returns a new instance of Docker.
15 16 17 18 19 20 21 |
# File 'lib/fpm/package/docker.rb', line 15 def initialize( = {} ) super() @logger = [:logger] || Cabin::Channel.get @client = [:client] || FPM::Fry::Client.new(logger: @logger) @keep_modified_files = [:keep_modified_files] @verbose = [:verbose] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/fpm/package/docker.rb', line 10 def client @client end |
#keep_modified_files ⇒ Object (readonly)
Returns the value of attribute keep_modified_files.
10 11 12 |
# File 'lib/fpm/package/docker.rb', line 10 def keep_modified_files @keep_modified_files end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
10 11 12 |
# File 'lib/fpm/package/docker.rb', line 10 def logger @logger end |
Instance Method Details
#input(name) ⇒ Object
Loads all files from a docker container with the given name to the staging path.
27 28 29 |
# File 'lib/fpm/package/docker.rb', line 27 def input(name) split( name, '**' => staging_path) end |
#split(name, map) ⇒ Object
Loads all files from a docker container into multiple paths defined by map param.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fpm/package/docker.rb', line 36 def split( name, map ) changes = changes(name) changes.remove_modified_leaves!(changes_to_remove) do | kind, ml | if kind == DELETED logger.warn("Found a deleted file. You can't delete files as part of a package.", name: ml) elsif !keep_modified_files logger.warn("Found a modified file. You can't modify files in a package.", name: ml) end end fmap = {} changes.leaves.each do | change | map.each do | match, to | if File.fnmatch?(match, change) fmap[change] = File.join(to, change) break end end end directories = changes.smallest_superset directories.each do |chg| client.copy(name, chg, fmap, chown: false) end return nil end |