puppet-herald 0.2.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +3 -0
- data/.jshintrc +19 -0
- data/Gemfile +25 -12
- data/Gemfile.local.example +3 -0
- data/Guardfile +57 -0
- data/README.md +1 -1
- data/Rakefile +100 -20
- data/db/migrate/20141218200108_remove_no_of_reports_from_nodes.rb +7 -0
- data/lib/puppet-herald.rb +95 -65
- data/lib/puppet-herald/app/api.rb +79 -12
- data/lib/puppet-herald/app/configuration.rb +47 -15
- data/lib/puppet-herald/app/frontend.rb +6 -6
- data/lib/puppet-herald/app/views/app.erb +14 -20
- data/lib/puppet-herald/app/views/err500.erb +8 -5
- data/lib/puppet-herald/application.rb +9 -1
- data/lib/puppet-herald/cli.rb +5 -11
- data/lib/puppet-herald/database.rb +1 -7
- data/lib/puppet-herald/javascript.rb +16 -10
- data/lib/puppet-herald/models.rb +47 -0
- data/lib/puppet-herald/models/log-entry.rb +2 -0
- data/lib/puppet-herald/models/node.rb +49 -2
- data/lib/puppet-herald/models/report.rb +33 -9
- data/lib/puppet-herald/project.js +46 -0
- data/lib/puppet-herald/public/app.js +11 -9
- data/lib/puppet-herald/public/bower.json +10 -3
- data/lib/puppet-herald/public/components/artifact/artifact-directive.js +4 -0
- data/lib/puppet-herald/public/components/artifact/artifact.js +1 -3
- data/lib/puppet-herald/public/components/directives/directives.js +5 -1
- data/lib/puppet-herald/public/components/directives/status-button.html +1 -1
- data/lib/puppet-herald/public/components/directives/status-button.js +11 -11
- data/lib/puppet-herald/public/components/filters/filters.js +6 -2
- data/lib/puppet-herald/public/components/page.js +2 -2
- data/lib/puppet-herald/public/components/pagination.js +142 -0
- data/lib/puppet-herald/public/components/settings.js +25 -0
- data/lib/puppet-herald/public/css/herald.css +100 -3
- data/lib/puppet-herald/public/general/app.html +73 -0
- data/lib/puppet-herald/public/img/shield97-white.svg +53 -0
- data/lib/puppet-herald/public/img/shield97.png +0 -0
- data/lib/puppet-herald/public/node/node.html +27 -9
- data/lib/puppet-herald/public/node/node.js +43 -15
- data/lib/puppet-herald/public/nodes/nodes.html +25 -7
- data/lib/puppet-herald/public/nodes/nodes.js +29 -14
- data/lib/puppet-herald/public/report/report.html +60 -13
- data/lib/puppet-herald/public/report/report.js +21 -14
- data/lib/puppet-herald/public/router.js +55 -0
- data/lib/puppet-herald/purgecronjob.rb +35 -0
- data/lib/puppet-herald/version.rb +2 -2
- data/package.json +14 -16
- data/puppet-herald.gemspec +12 -7
- data/spec/integration/app/configuration_spec.rb +33 -0
- data/spec/integration/application_spec.rb +139 -20
- data/spec/integration/fixtures/nodes.yml +13 -0
- data/spec/integration/fixtures/pending-notify.yaml +346 -0
- data/spec/integration/fixtures/reports.yml +61 -0
- data/spec/integration/models/node_spec.rb +12 -3
- data/spec/integration/models/report_spec.rb +60 -4
- data/spec/spec_helper.rb +6 -10
- data/spec/support/active_record.rb +1 -0
- data/spec/support/fixtures.rb +16 -0
- data/spec/unit/puppet-herald/cli_spec.rb +4 -4
- data/spec/unit/puppet-herald/database_spec.rb +5 -3
- data/spec/unit/puppet-herald/purgecronjob_spec.rb +37 -0
- data/test/javascript/.bowerrc +3 -0
- data/test/javascript/bower.json +21 -0
- data/test/javascript/karma.conf.js +17 -22
- data/test/javascript/src/app_test.js +10 -61
- data/test/javascript/src/components/directives/status-button_test.js +10 -10
- data/test/javascript/src/components/paginate_test.js +183 -0
- data/test/javascript/src/node/node_test.js +16 -6
- data/test/javascript/src/nodes/nodes_test.js +14 -2
- data/test/javascript/src/report/report_test.js +6 -6
- data/test/javascript/src/router_test.js +79 -0
- metadata +642 -23
@@ -2,6 +2,7 @@ require 'sinatra/base'
|
|
2
2
|
require 'sinatra/namespace'
|
3
3
|
require 'puppet-herald'
|
4
4
|
require 'puppet-herald/app/configuration'
|
5
|
+
require 'puppet-herald/models'
|
5
6
|
require 'puppet-herald/models/node'
|
6
7
|
require 'puppet-herald/models/report'
|
7
8
|
|
@@ -18,6 +19,7 @@ module PuppetHerald
|
|
18
19
|
@app = app
|
19
20
|
end
|
20
21
|
# Creates a new report
|
22
|
+
#
|
21
23
|
# @param request [Sinatra::Request] an request object
|
22
24
|
# @return [Array] an response array: [code, body] or [code, headers, body]
|
23
25
|
def post_reports(request)
|
@@ -27,34 +29,46 @@ module PuppetHerald
|
|
27
29
|
[201, body]
|
28
30
|
end
|
29
31
|
# Get a report by its ID
|
32
|
+
#
|
30
33
|
# @param params [Hash] an requests parsed params
|
31
34
|
# @return [Array] an response array: [code, body] or [code, headers, body]
|
32
35
|
def get_report(params)
|
33
36
|
id = params[:id]
|
34
|
-
report = PuppetHerald::Models::Report.
|
37
|
+
report = PuppetHerald::Models::Report.with_log_entries(id)
|
35
38
|
status = 200
|
36
39
|
status = 404 if report.nil?
|
37
40
|
body = report.to_json(include: :log_entries)
|
38
41
|
[status, body]
|
39
42
|
end
|
40
|
-
# Gets all nodes
|
43
|
+
# Gets all nodes with pagination
|
44
|
+
#
|
45
|
+
# @param request [Sinatra::Request] an request object
|
41
46
|
# @return [Array] an response array: [code, body] or [code, headers, body]
|
42
|
-
def nodes
|
43
|
-
|
44
|
-
|
47
|
+
def nodes(request)
|
48
|
+
pag = paginate request
|
49
|
+
nodes = PuppetHerald::Models::Node.paginate(pag)
|
50
|
+
[200, headers(pag), nodes.to_json(methods: :no_of_reports)]
|
51
|
+
rescue ArgumentError => ex
|
52
|
+
clienterror ex
|
45
53
|
end
|
46
|
-
# Gets a node by its ID
|
54
|
+
# Gets a node by its ID, with pagination
|
55
|
+
#
|
47
56
|
# @param params [Hash] an requests parsed params
|
57
|
+
# @param request [Sinatra::Request] an request object
|
48
58
|
# @return [Array] an response array: [code, body] or [code, headers, body]
|
49
|
-
def get_node(params)
|
59
|
+
def get_node(params, request)
|
50
60
|
id = params[:id]
|
51
|
-
|
61
|
+
pag = paginate request
|
62
|
+
node = PuppetHerald::Models::Node.with_reports(id, pag)
|
52
63
|
status = 200
|
53
64
|
status = 404 if node.nil?
|
54
|
-
body = node.to_json(include: :reports)
|
55
|
-
[status, body]
|
65
|
+
body = node.to_json(include: :reports, methods: :no_of_reports)
|
66
|
+
[status, headers(pag), body]
|
67
|
+
rescue ArgumentError => ex
|
68
|
+
clienterror ex
|
56
69
|
end
|
57
70
|
# Get a app's artifact information
|
71
|
+
#
|
58
72
|
# @return [Array] an response array: [code, body] or [code, headers, body]
|
59
73
|
def version_json
|
60
74
|
ver = {}
|
@@ -63,6 +77,59 @@ module PuppetHerald
|
|
63
77
|
end
|
64
78
|
[200, ver.to_json]
|
65
79
|
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
# Creates headers for given pagination
|
84
|
+
#
|
85
|
+
# @param pagination [PuppetHerald::Models::Pagination] a pagination
|
86
|
+
# @param httpize [Boolean] if true given, will change headers to Rack format +HTTP_*+
|
87
|
+
# @return [Hash] a HTTP request headers
|
88
|
+
def headers(pagination, httpize = false)
|
89
|
+
keys = httpize_keys(httpize)
|
90
|
+
head = {
|
91
|
+
keys[:page] => pagination.page.to_s,
|
92
|
+
keys[:limit] => pagination.limit.to_s
|
93
|
+
}
|
94
|
+
head[keys[:total]] = pagination.total.to_s unless pagination.total.nil?
|
95
|
+
head[keys[:pages]] = pagination.pages.to_s unless pagination.pages.nil?
|
96
|
+
head
|
97
|
+
end
|
98
|
+
|
99
|
+
def httpize_keys(httpize = false)
|
100
|
+
map = PuppetHerald::Models::Pagination::KEYS.map do |k, str|
|
101
|
+
[k, httpize_key(str, httpize)]
|
102
|
+
end
|
103
|
+
Hash[map]
|
104
|
+
end
|
105
|
+
|
106
|
+
def httpize_key(key, httpize = false)
|
107
|
+
noop = ->(name) { name }
|
108
|
+
oper = httpize ? method(:httpize) : noop
|
109
|
+
oper.call key
|
110
|
+
end
|
111
|
+
|
112
|
+
# Creates a pagination from request
|
113
|
+
#
|
114
|
+
# @param request [Sinatra::Request] a HTTP request
|
115
|
+
# @return [PuppetHerald::Models::Pagination] a pagination
|
116
|
+
def paginate(request)
|
117
|
+
pkey = httpize(PuppetHerald::Models::Pagination::KEYS[:page])
|
118
|
+
lkey = httpize(PuppetHerald::Models::Pagination::KEYS[:limit])
|
119
|
+
page = request.env[pkey] ? request.env[pkey] : PuppetHerald::Models::Pagination::DEFAULT.page
|
120
|
+
limit = request.env[lkey] ? request.env[lkey] : PuppetHerald::Models::Pagination::DEFAULT.limit
|
121
|
+
PuppetHerald::Models::Pagination.new(page, limit)
|
122
|
+
end
|
123
|
+
|
124
|
+
def httpize(header_name)
|
125
|
+
upper = header_name.upcase.gsub('-', '_')
|
126
|
+
"HTTP_#{upper}"
|
127
|
+
end
|
128
|
+
|
129
|
+
def clienterror(ex)
|
130
|
+
err = { error: "#{ex.class}: #{ex.message}" }
|
131
|
+
[400, err.to_json]
|
132
|
+
end
|
66
133
|
end
|
67
134
|
|
68
135
|
# An API app module
|
@@ -92,12 +159,12 @@ module PuppetHerald
|
|
92
159
|
|
93
160
|
get '/nodes' do
|
94
161
|
content_type 'application/json'
|
95
|
-
api.nodes
|
162
|
+
api.nodes request
|
96
163
|
end
|
97
164
|
|
98
165
|
get '/nodes/:id' do
|
99
166
|
content_type 'application/json'
|
100
|
-
api.get_node params
|
167
|
+
api.get_node params, request
|
101
168
|
end
|
102
169
|
|
103
170
|
get '/reports/:id' do
|
@@ -4,6 +4,7 @@ require 'sinatra/namespace'
|
|
4
4
|
require 'sinatra/activerecord'
|
5
5
|
require 'puppet-herald'
|
6
6
|
require 'puppet-herald/javascript'
|
7
|
+
require 'puppet-herald/purgecronjob'
|
7
8
|
|
8
9
|
# A module for Herald
|
9
10
|
module PuppetHerald
|
@@ -16,14 +17,26 @@ module PuppetHerald
|
|
16
17
|
set :database, PuppetHerald.database.spec unless PuppetHerald.database.spec.nil?
|
17
18
|
|
18
19
|
class << self
|
19
|
-
#
|
20
|
+
# Configure the application
|
20
21
|
#
|
22
|
+
# @param options [Hash] optional parameters
|
21
23
|
# @return [nil]
|
22
|
-
def
|
23
|
-
|
24
|
+
def configure_app(options = {})
|
25
|
+
cron = options.fetch(:cron, true)
|
26
|
+
dbmigrate = options.fetch(:dbmigrate, true)
|
24
27
|
setup_database_logger
|
25
|
-
|
26
|
-
|
28
|
+
dbmigrate! if dbmigrate
|
29
|
+
enable_cron if cron
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
# De-configure the application
|
34
|
+
#
|
35
|
+
# @param options [Hash] optional parameters
|
36
|
+
# @return [nil]
|
37
|
+
def deconfigure_app(options = {})
|
38
|
+
cron = options.fetch(:cron, true)
|
39
|
+
disable_cron if cron
|
27
40
|
nil
|
28
41
|
end
|
29
42
|
|
@@ -36,24 +49,43 @@ module PuppetHerald
|
|
36
49
|
|
37
50
|
private
|
38
51
|
|
52
|
+
# Migrates a database to state desired for the application
|
53
|
+
#
|
54
|
+
# @return [nil]
|
55
|
+
def dbmigrate!
|
56
|
+
ActiveRecord::Base.establish_connection(PuppetHerald.database.spec)
|
57
|
+
ActiveRecord::Migrator.up 'db/migrate'
|
58
|
+
ActiveRecord::Base.clear_active_connections!
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
|
62
|
+
# Enable cron in application
|
63
|
+
def enable_cron
|
64
|
+
require 'rufus/scheduler'
|
65
|
+
set :scheduler, Rufus::Scheduler.new
|
66
|
+
job = PuppetHerald::PurgeCronJob.new
|
67
|
+
# Run every 30 minutes, by default
|
68
|
+
cron = ENV['PUPPET_HERALD_PURGE_CRON'] || '*/30 * * * *'
|
69
|
+
PuppetHerald.logger.info "Stating scheduler with: `#{cron}`..."
|
70
|
+
scheduler.cron(cron) { job.run! }
|
71
|
+
end
|
72
|
+
|
73
|
+
# Disable cron in application
|
74
|
+
def disable_cron
|
75
|
+
scheduler.shutdown if scheduler.up?
|
76
|
+
PuppetHerald.logger.info 'Scheduler stopped.'
|
77
|
+
end
|
78
|
+
|
39
79
|
# Sets logger level for database handlers
|
40
80
|
#
|
41
81
|
# @return [nil]
|
42
82
|
def setup_database_logger
|
43
|
-
|
44
|
-
ActiveRecord::Base.logger.level = Logger::DEBUG
|
45
|
-
else
|
46
|
-
ActiveRecord::Base.logger.level = Logger::WARN
|
47
|
-
end
|
83
|
+
ActiveRecord::Base.logger = PuppetHerald.logger
|
48
84
|
nil
|
49
85
|
end
|
50
86
|
end
|
51
87
|
|
52
|
-
|
53
|
-
set :environment, :development
|
54
|
-
else
|
55
|
-
set :environment, :production
|
56
|
-
end
|
88
|
+
set :environment, PuppetHerald.rackenv
|
57
89
|
set :show_exceptions, false
|
58
90
|
|
59
91
|
error do
|
@@ -37,20 +37,20 @@ module PuppetHerald
|
|
37
37
|
set :logic, PuppetHerald::App::LogicImpl.new
|
38
38
|
|
39
39
|
get '/' do
|
40
|
-
|
40
|
+
cache_control :public, :must_revalidate, max_age: 60 if PuppetHerald.in_prod?
|
41
|
+
@minified, @files = settings.logic.app_html
|
42
|
+
erb :app
|
41
43
|
end
|
42
44
|
|
43
45
|
get '/index.html' do
|
44
|
-
redirect '/
|
46
|
+
redirect '/', 301
|
45
47
|
end
|
46
48
|
|
47
49
|
get '/app.html' do
|
48
|
-
|
49
|
-
@minified, @files = settings.logic.app_html
|
50
|
-
erb :app
|
50
|
+
redirect '/', 301
|
51
51
|
end
|
52
52
|
|
53
|
-
get
|
53
|
+
get %r{^/app\.min\.(js\.map|js)$} do |ext|
|
54
54
|
content_type 'application/javascript'
|
55
55
|
contents = settings.logic.uglify('/app.min.js.map')[ext]
|
56
56
|
cache_control :public, :must_revalidate, max_age: 60 if PuppetHerald.in_prod?
|
@@ -3,37 +3,31 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
|
-
<title>Herald
|
6
|
+
<title>Herald</title>
|
7
7
|
|
8
8
|
<meta name="description" content="Herald - a Puppet report processor">
|
9
9
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
10
10
|
<!-- Latest compiled and minified CSS -->
|
11
|
-
<link rel="stylesheet" href="
|
11
|
+
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap<%= @minified %>.css">
|
12
12
|
<!-- Optional theme -->
|
13
|
-
<link rel="stylesheet" href="
|
13
|
+
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap-theme<%= @minified %>.css">
|
14
14
|
<link rel="stylesheet" href="css/herald.css">
|
15
|
+
<link rel="icon" type="image/png" href="img/shield97.png"/>
|
15
16
|
</head>
|
16
17
|
<body>
|
17
18
|
|
18
|
-
<
|
19
|
-
|
20
|
-
<h2><a href="#/"><img src="/img/shield97.svg" />Herald</a> <small>a Puppet report processor</small></h2>
|
19
|
+
<ui-view></ui-view>
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
<script type="text/javascript" src="bower_components/angular/angular<%= @minified %>.js"></script>
|
22
|
+
<script type="text/javascript" src="bower_components/angular-ui-router/release/angular-ui-router<%= @minified %>.js"></script>
|
23
|
+
<script type="text/javascript" src="bower_components/angular-breadcrumb/release/angular-breadcrumb<%= @minified %>.js"></script>
|
24
|
+
<script type="text/javascript" src="bower_components/moment/min/moment.min.js"></script>
|
25
|
+
<script type="text/javascript" src="bower_components/angular-moment/angular-moment<%= @minified %>.js"></script>
|
26
|
+
<script type="text/javascript" src="bower_components/ngstorage/ngStorage<%= @minified %>.js"></script>
|
27
|
+
<script type="text/javascript" src="bower_components/angular-utils-pagination/dirPagination.js"></script>
|
29
28
|
|
30
|
-
|
31
|
-
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-route<%= @minified %>.js"></script>
|
32
|
-
<script src="//cdn.jsdelivr.net/momentjs/2.8.4/moment.min.js"></script>
|
33
|
-
<script src="//cdn.jsdelivr.net/angular.moment/0.8.3/angular-moment<%= @minified %>.js"></script>
|
34
|
-
|
35
|
-
<!-- Automatic incudes of project files -->
|
29
|
+
<!-- Automatic includes of project files -->
|
36
30
|
<% @files.each do |file| %>
|
37
|
-
<script src="<%= file %>"></script><% end %>
|
31
|
+
<script type="text/javascript" src="<%= file %>"></script><% end %>
|
38
32
|
</body>
|
39
33
|
</html>
|
@@ -3,13 +3,16 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
|
-
<title>
|
6
|
+
<title>Herald</title>
|
7
|
+
<title>Error 500 | Herald</title>
|
7
8
|
<meta name="description" content="Herald - a Puppet report processor">
|
8
9
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
9
10
|
<!-- Latest compiled and minified CSS -->
|
10
|
-
<link rel="stylesheet" href="
|
11
|
+
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap<%= @minified %>.css">
|
11
12
|
<!-- Optional theme -->
|
12
|
-
<link rel="stylesheet" href="
|
13
|
+
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap-theme<%= @minified %>.css">
|
14
|
+
<link rel="stylesheet" href="css/herald.css">
|
15
|
+
<link rel="icon" type="image/png" href="img/shield97.png"/>
|
13
16
|
</head>
|
14
17
|
<body>
|
15
18
|
|
@@ -18,10 +21,10 @@
|
|
18
21
|
|
19
22
|
<div class="jumbotron">
|
20
23
|
<h2 class="text-danger glyphicon glyphicon-fire">Internal Server Error (500)</h2>
|
21
|
-
<p>Something
|
24
|
+
<p>Something really unpredictable just happend...</p>
|
22
25
|
<div class="well well-lg"><samp><%= @bug[:message] %></samp></div>
|
23
26
|
<p><small><strong>Pro Tip!</strong> Please report this bug by passing contents of bug file: <code><%= @bug[:bugfile] %></code></small></p>
|
24
|
-
<p><a class="btn btn-danger btn-lg" href="<%= @bug[:homepage]
|
27
|
+
<p><a class="btn btn-danger btn-lg" href="<%= @bug[:homepage] %>/issues/new" role="button">Report a bug</a></p>
|
25
28
|
</div>
|
26
29
|
</section>
|
27
30
|
</body>
|
@@ -19,9 +19,17 @@ module PuppetHerald
|
|
19
19
|
# @param block [block] an extra configuration block
|
20
20
|
# @return [Sinatra::Application] an Herald application
|
21
21
|
def run!(options = {}, &block)
|
22
|
-
PuppetHerald::App::Configuration.
|
22
|
+
PuppetHerald::App::Configuration.configure_app
|
23
23
|
super options, *block
|
24
24
|
end
|
25
|
+
|
26
|
+
# Deconfigure application
|
27
|
+
#
|
28
|
+
# @return [nil]
|
29
|
+
def quit!
|
30
|
+
PuppetHerald::App::Configuration.deconfigure_app
|
31
|
+
super
|
32
|
+
end
|
25
33
|
end
|
26
34
|
end
|
27
35
|
end
|
data/lib/puppet-herald/cli.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'micro-optparse'
|
2
|
-
require 'logger'
|
3
2
|
require 'puppet-herald'
|
4
3
|
require 'puppet-herald/version'
|
5
4
|
require 'puppet-herald/database'
|
@@ -11,21 +10,15 @@ module PuppetHerald
|
|
11
10
|
# Initialize CLI
|
12
11
|
# @return [CLI] an CLI object
|
13
12
|
def initialize
|
14
|
-
@logger = Logger.new STDOUT
|
15
|
-
@errlogger = Logger.new STDERR
|
16
13
|
self
|
17
14
|
end
|
18
15
|
|
19
|
-
# Logger for CLI interface (error and std)
|
20
|
-
# @return [Logger] logger for CLI
|
21
|
-
attr_reader :logger, :errlogger
|
22
|
-
|
23
16
|
# Executes an Herald app from CLI
|
24
17
|
#
|
25
18
|
# @param argv [Array] an argv from CLI
|
26
19
|
# @return [Integer] a status code for program
|
27
20
|
def run!(argv = ARGV)
|
28
|
-
PuppetHerald.
|
21
|
+
PuppetHerald.rackenv
|
29
22
|
|
30
23
|
options = parse_or_kill argv, 2
|
31
24
|
run_or_kill options, 1
|
@@ -40,7 +33,8 @@ module PuppetHerald
|
|
40
33
|
def parse(argv)
|
41
34
|
options = parser.process!(argv)
|
42
35
|
|
43
|
-
|
36
|
+
msg = "Starting #{PuppetHerald::NAME} v#{PuppetHerald::VERSION} in #{PuppetHerald.rackenv}..."
|
37
|
+
PuppetHerald.logger.info msg
|
44
38
|
PuppetHerald.database.dbconn = options[:dbconn]
|
45
39
|
PuppetHerald.database.passfile = options[:passfile]
|
46
40
|
PuppetHerald.database.spec(true)
|
@@ -54,14 +48,14 @@ module PuppetHerald
|
|
54
48
|
PuppetHerald::Application.run! options
|
55
49
|
rescue StandardError => ex
|
56
50
|
bug = PuppetHerald.bug(ex)
|
57
|
-
errlogger.fatal "Unexpected error occured, mayby a bug?\n\n#{bug[:message]}\n\n#{bug[:help]}"
|
51
|
+
PuppetHerald.errlogger.fatal "Unexpected error occured, mayby a bug?\n\n#{bug[:message]}\n\n#{bug[:help]}"
|
58
52
|
Kernel.exit retcode
|
59
53
|
end
|
60
54
|
|
61
55
|
def parse_or_kill(argv, retcode)
|
62
56
|
return parse argv
|
63
57
|
rescue StandardError => ex
|
64
|
-
errlogger.fatal "Database configuration is invalid!\n\n#{ex.message}"
|
58
|
+
PuppetHerald.errlogger.fatal "Database configuration is invalid!\n\n#{ex.message}"
|
65
59
|
Kernel.exit retcode
|
66
60
|
end
|
67
61
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require 'logger'
|
3
2
|
|
4
3
|
# A module for Herald
|
5
4
|
module PuppetHerald
|
@@ -8,13 +7,8 @@ module PuppetHerald
|
|
8
7
|
def initialize
|
9
8
|
@dbconn = nil
|
10
9
|
@passfile = nil
|
11
|
-
@logger = Logger.new STDOUT
|
12
10
|
end
|
13
11
|
|
14
|
-
# Gets a logger for database
|
15
|
-
# @return [Logger] a logger
|
16
|
-
attr_reader :logger
|
17
|
-
|
18
12
|
# Sets a database connection
|
19
13
|
# @return [String] a dbconnection string
|
20
14
|
attr_writer :dbconn
|
@@ -57,7 +51,7 @@ module PuppetHerald
|
|
57
51
|
return unless log
|
58
52
|
copy = connection.dup
|
59
53
|
copy[:password] = '***' unless copy[:password].nil?
|
60
|
-
logger.info "Using #{copy.inspect} for database."
|
54
|
+
PuppetHerald.logger.info "Using #{copy.inspect} for database."
|
61
55
|
end
|
62
56
|
|
63
57
|
def sqlite(match)
|