Class: Ufo::Docker::Variables

Inherits:
Object
  • Object
show all
Defined in:
lib/ufo/docker/variables.rb

Constant Summary collapse

@@variables_path =
"#{Ufo.root}/.ufo/settings/dockerfile_variables.yml"

Instance Method Summary collapse

Constructor Details

#initialize(full_image_name, options = {}) ⇒ Variables

Returns a new instance of Variables.



5
6
7
# File 'lib/ufo/docker/variables.rb', line 5

def initialize(full_image_name, options={})
  @full_image_name, @options = full_image_name, options
end

Instance Method Details

#current_dataObject



22
23
24
# File 'lib/ufo/docker/variables.rb', line 22

def current_data
  File.exist?(@@variables_path) ? YAML.load_file(@@variables_path) : {}
end

#updateObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ufo/docker/variables.rb', line 9

def update
  data = current_data
  data[Ufo.env] ||= {}
  data[Ufo.env]["base_image"] = @full_image_name
  pretty_path = @@variables_path.sub("#{Ufo.root}/", "")
  IO.write(@@variables_path, YAML.dump(data))

  unless @options[:mute]
    puts "The #{pretty_path} base_image has been updated with the latest base image:".color(:green)
    puts "  #{@full_image_name}".color(:green)
  end
end