forked from puppetlabs/puppet-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
57 lines (44 loc) · 1.54 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
require 'json'
begin
require 'packaging'
Pkg::Util::RakeUtils.load_packaging_tasks
rescue LoadError => e
puts "Error loading packaging rake tasks: #{e}"
end
Dir.glob(File.join('tasks/**/*.rake')).each { |file| load file }
namespace :package do
task :bootstrap do
puts 'Bootstrap is no longer needed, using packaging-as-a-gem'
end
task :implode do
puts 'Implode is no longer needed, using packaging-as-a-gem'
end
end
namespace :component do
desc "Display currently promoted ref for component"
task :check, [:component] do |t,args|
abort 'USAGE: rake component:check[component]' unless args[:component]
config = get_component_config(args[:component])
puts config["ref"]
end
desc "Update component config to promote a new version"
task :promote, [:component, :version, :ref] do |t,args|
abort 'USAGE: rake component:promote[component,version,ref]' unless args[:component] && args[:version] && args[:ref]
config = get_component_config(args[:component])
config["version"] = args[:version]
config["ref"] = args[:ref]
File.open(component_config_file(args[:component]), 'w') do |f|
f.write(JSON.pretty_generate(config))
end
end
end
# Legacy task name.
task :promote_component, [:component, :version, :ref] => "component:promote"
def component_config_file(component)
"configs/components/#{component}.json"
end
def get_component_config(component)
conf = component_config_file(component)
abort "No component config file '#{conf}'" unless File.exist?(conf)
JSON.parse(File.read(conf))
end