Added mapping auto_update to set the label for watchtower or pyouroboros or whatever.
This commit is contained in:
parent
1eb3a8ded7
commit
18eb80ebf6
26
dup.rb
26
dup.rb
@ -31,7 +31,7 @@ MAPPINGS = [
|
||||
['working_dir', '--workdir', lambda{|c,i| (wd=c.Config.WorkingDir) == i.Config.WorkingDir ? nil : wd}],
|
||||
['init', '--init', lambda{|c,i| c.Config.Init}, {:type=>:switch}],
|
||||
['image', nil, lambda{|c,i| c.Config.Image}],
|
||||
['command', nil, lambda{|c,i| (cmd=c.Config.Cmd.join(" ") rescue nil) == (i.Config.Cmd.join(" ") rescue nil)? nil : cmd}, {:escape=>false}]
|
||||
['auto_update', nil, nil, {type: :hidden}]
|
||||
]
|
||||
|
||||
|
||||
@ -225,22 +225,30 @@ class Container
|
||||
|
||||
def filename; "%s/%s.yml" % [$base_dir, @name]; end
|
||||
|
||||
def add_label(key, value)
|
||||
if @data["labels"].is_a? Array
|
||||
@data["labels"] << "#{key}=#{value}"
|
||||
elsif @data["labels"].is_a? Hash
|
||||
@data["labels"][key] = value
|
||||
else
|
||||
raise "data['labels'] is of an unexpected type: #{@data["labels"].class}"
|
||||
end
|
||||
end
|
||||
|
||||
def build_run_command
|
||||
$net_host = true if @data["net"]=="host"
|
||||
cmd = ["docker", "create"]
|
||||
cmd << "--net" << @data["networks"][0] if @data["networks"] && @data["networks"].count>0 && !$net_host
|
||||
cmd << "--net" << "host" if $net_host
|
||||
|
||||
@data["labels"] ||= []
|
||||
|
||||
if !@data["test"]
|
||||
if @data["labels"]==nil
|
||||
@data["labels"] = ["de.fabianonline.dup=true"]
|
||||
elsif @data["labels"].is_a? Array
|
||||
@data["labels"] << "de.fabianonline.dup=true"
|
||||
elsif @data["labels"].is_a? Hash
|
||||
@data["labels"]["de.fabianonline.dup"] = "true"
|
||||
else
|
||||
raise "data['labels'] is of an unexpected type: #{@data["labels"].class}"
|
||||
add_label("de.fabianonline.dup", "true")
|
||||
end
|
||||
|
||||
if @data["auto_update"]
|
||||
add_label("com.centurylinklabs.watchtower.enable", "true")
|
||||
end
|
||||
|
||||
MAPPINGS.each do |mapping|
|
||||
|
Loading…
Reference in New Issue
Block a user