From ec0d0063b7811b2df64e75c12da36dcf4687bd8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Sabat=C3=A9=20Sol=C3=A0?= Date: Wed, 31 Aug 2016 15:31:54 +0200 Subject: [PATCH] lib/tasks: added the portus:create_registry task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moreover, the portus:create_user taks has now a check preventing to create users if there is no registry. Fixes #1036 Signed-off-by: Miquel Sabaté Solà --- lib/tasks/portus.rake | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/lib/tasks/portus.rake b/lib/tasks/portus.rake index ad991d605..7005d223e 100644 --- a/lib/tasks/portus.rake +++ b/lib/tasks/portus.rake @@ -31,8 +31,46 @@ namespace :portus do ) end + desc "Create a registry" + task :create_registry, [:name, :hostname, :use_ssl, :external] => :environment do |_, args| + if args.count != 3 && args.count != 4 + puts "There are 3 required arguments and an optional one" + exit(-1) + end + + args.each do |k, v| + if v.empty? && k != :external + puts "You have to provide a value for `#{k}'" + exit(-1) + end + end + + if Registry.count > 0 + puts "There is already a registry configured!" + exit(-1) + end + + registry = Registry.new( + name: args[:name], + hostname: args[:hostname], + use_ssl: args[:use_ssl], + external_hostname: args[:external] + ) + msg = registry.reachable? + unless msg.empty? + puts "\nRegistry not reachable:\n#{registry.inspect}\n#{msg}\n" + exit(-1) + end + registry.save + end + desc "Create a user" task :create_user, [:username, :email, :password, :admin] => :environment do |_, args| + if args.count != 4 + puts "There are 4 required arguments" + exit(-1) + end + args.each do |k, v| if v.empty? puts "You have to provide a value for `#{k}'" @@ -40,6 +78,16 @@ namespace :portus do end end + unless Registry.any? + puts <