Class: Ufo::Docker::State
Instance Method Summary
collapse
#pretty_home, #pretty_path, #pretty_time
#logger
Constructor Details
#initialize(docker_image, options = {}) ⇒ State
Returns a new instance of State.
6
7
8
|
# File 'lib/ufo/docker/state.rb', line 6
def initialize(docker_image, options={})
@docker_image, @options = docker_image, options
end
|
Instance Method Details
#current_data ⇒ Object
22
23
24
|
# File 'lib/ufo/docker/state.rb', line 22
def current_data
File.exist?(state_path) ? YAML.load_file(state_path) : {}
end
|
#reminder_message ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/ufo/docker/state.rb', line 34
def reminder_message
return unless Ufo.config.state.reminder
repo = ENV['UFO_CENTRAL_REPO']
return unless repo
logger.info "It looks like you're using a central deployer pattern".color(:yellow)
logger.info <<~EOL
Remember to commit the state file:
state file: #{pretty_path(state_path)}
repo: #{repo}
EOL
unless ENV['UFO_APP']
logger.info "WARN: It also doesnt look like UFO_ENV is set".color(:yellow)
logger.info "UFO_ENV should be set when you're using ufo in a central manner"
end
logger.info <<~EOL
You can disable these reminder messages with:
.ufo/config.rb
Ufo.configure do |config|
config.state.reminder = false
end
EOL
end
|
#state_path ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/ufo/docker/state.rb', line 26
def state_path
path = "#{Ufo.root}/.ufo/state"
if ENV['UFO_APP'] path = "#{Ufo.root}/.ufo/state/#{Ufo.app}"
end
"#{path}/data.yml"
end
|
#update ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/ufo/docker/state.rb', line 10
def update
data = current_data
data[Ufo.env] ||= {}
data[Ufo.env]["base_image"] = @docker_image
pretty_path = state_path.sub("#{Ufo.root}/", "")
FileUtils.mkdir_p(File.dirname(state_path))
IO.write(state_path, YAML.dump(data))
logger.info "The #{pretty_path} base_image has been updated with the latest base image:".color(:green)
logger.info " #{@docker_image}".color(:green)
reminder_message
end
|