tasks/app.rb in gaptool-server-0.6.6 vs tasks/app.rb in gaptool-server-0.7.0
- old
+ new
@@ -1,16 +1,22 @@
namespace :app do
desc "Add an application"
- task :add, [:app, :role] do |t, args|
- abort("Missing parameters") if args[:app].nil? || args[:app].empty? || args[:role].nil? || args[:role].empty?
+ task :add, [:app, :role, :environment] do |t, args|
+ [:app, :role, :environment].each do |arg|
+ abort("Missing parameter #{arg}") if args[arg].nil? || args[arg].empty?
+ end
ex = DH.get_app_data(args[:app])
unless ex.nil?
- puts "Updating application #{args[:app]}" unless ex.nil?
+ puts "Updating application #{args[:app]} (#{args[:environment]}) to #{args[:role]}"
DH.remove_app(args[:app])
+ ex.delete(args[:environment])
end
- DH.add_app(args[:app], args[:role])
- puts "Added app #{args[:app]} in role #{args[:role]}"
+ DH.add_app(args[:app], args[:role], args[:environment])
+ ex.each do |env, role|
+ DH.add_app(args[:app], role, env)
+ end
+ puts "Added app #{args[:app]}, role #{args[:role]}, environment: #{args[:environment]}"
end
desc "Remove an application"
task :del, [:app] do |t, args|
unless args[:app].nil? || args[:app].empty?
@@ -23,19 +29,30 @@
task :info, [:app] do |t, args|
info = DH.get_app_data(args[:app])
if info.nil? || info.empty?
puts "No such app #{args[:app]}"
else
- puts " * #{args[:app]} => #{info["role"]}"
+ puts " * #{app} #{info.map {|k,v| "#{k}: #{v}"}.join(", ")}"
end
+ end
+ desc "Copy all apps for a role to a new env"
+ task :newenv, [:role, :oldenv, :newenv, :newrole] do |t, args|
+ [:role, :oldenv, :newenv].each do |k|
+ abort "Missing parameter #{k}" if args[k].nil?
+ end
+ newrole = args[:newrole] || args[:role]
+ DH.apps_in_role(args[:role], args[:oldenv]).each do |app|
+ puts " * app: #{app} to role #{newrole} (#{args[:newenv]})"
+ DH.add_app(app, newrole, args[:newenv])
+ end
end
end
desc "List apps"
task :app do
puts "Apps:"
DH.apps.each do |app|
info = DH.get_app_data(app)
- puts " * #{app} => #{info["role"]}"
+ puts " * #{app} #{info.map {|k,v| "#{k}: #{v}"}.join(", ")}"
end
end