forked from Tendrl/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
43 lines (41 loc) · 1.02 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
require './lib/tendrl'
require 'etcd'
require 'yaml'
require 'json'
require 'securerandom'
namespace :etcd do
desc 'Load default Tendrl admin in etcd'
task :load_admin do
p 'Generating default Tendrl admin'
etcd_config = Tendrl.etcd_config(ENV['RACK_ENV'])
password = SecureRandom.hex(4)
Tendrl.etcd = Etcd.client(
host: etcd_config[:host],
port: etcd_config[:port],
user_name: etcd_config[:user_name],
password: etcd_config[:password]
)
user = Tendrl::User.find 'admin'
if user
p 'User named admin already exists.'
else
Tendrl::User.save({
name: 'Admin',
username: 'admin',
email: '',
role: 'admin',
password: password
})
p 'Generated default admin'
p 'Username: admin'
p "Password: #{password}"
end
end
end
if ENV['RACK_ENV'] != 'production'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new :specs do |task|
task.pattern = Dir['spec/**/*_spec.rb']
end
task :default => ['specs']
end