22
23
24
25
26
27
28
29
30
31
32
33
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
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/kdep/commands/push.rb', line 22
def execute
deploy_name = @args[0]
env = @args[1]
discovery = Kdep::Discovery.new
kdep_dir = discovery.find_kdep_dir
unless kdep_dir
@ui.error("No kdep/ directory found")
exit 1
end
deploy_dir = resolve_deploy_dir(kdep_dir, deploy_name, discovery)
unless deploy_dir
exit 1
end
config = Kdep::Config.new(deploy_dir, env).load
if config["build"] == false
@ui.error("#{deploy_dir} declares `build: false` — its image lives in an upstream registry, so there is nothing to push.")
exit 1
end
tag = Kdep::State.tag(deploy_dir)
unless tag
@ui.error("No tag in state.yml for #{deploy_dir}. Run `kdep bump` first.")
exit 1
end
image = config["image"] || config["name"]
registry = config["registry"]
if registry && !registry.to_s.empty?
full_tag = "#{registry}/#{image}:#{tag}"
else
full_tag = "#{image}:#{tag}"
end
begin
Kdep::Docker.push(full_tag)
@ui.info("Pushed: #{full_tag}")
rescue Kdep::Docker::Error => e
@ui.error(e.message)
exit 1
end
end
|