Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Add support for report format 9
Browse files Browse the repository at this point in the history
This adds provider_used to the resource_status model
  • Loading branch information
ZeroPointEnergy committed Aug 22, 2018
1 parent 06a5071 commit 83eacc9
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 6 deletions.
5 changes: 5 additions & 0 deletions db/migrate/20180614210435_add_report_format9.rb
@@ -0,0 +1,5 @@
class AddReportFormat9 < ActiveRecord::Migration[5.2]
def change
add_column :resource_statuses, :provider_used, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2018_06_14_161626) do
ActiveRecord::Schema.define(version: 2018_06_14_210435) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -200,6 +200,7 @@
t.string "status"
t.text "containment_path"
t.boolean "corrective_change"
t.string "provider_used"
t.index ["report_id"], name: "index_resource_statuses_on_report_id"
end

Expand Down
34 changes: 29 additions & 5 deletions lib/puppet/report_sanitizer.rb
Expand Up @@ -23,8 +23,10 @@ def sanitize(raw)
format6sanitizer.sanitize(raw)
when 7
format7sanitizer.sanitize(raw)
else
when 8
format8sanitizer.sanitize(raw)
else
format9sanitizer.sanitize(raw)
end
when raw.include?('resource_statuses')
format1sanitizer.sanitize(raw)
Expand Down Expand Up @@ -70,6 +72,10 @@ def format7sanitizer()
def format8sanitizer()
@format8sanitizer ||= ReportSanitizer::FormatVersion8.new
end

def format9sanitizer()
@format9sanitizer ||= ReportSanitizer::FormatVersion9.new
end
end

module Util
Expand Down Expand Up @@ -331,7 +337,7 @@ class FormatVersion6 < FormatVersion5
def initialize(
log_sanitizer = FormatVersion4LogSanitizer.new,
metric_sanitizer = MetricSanitizer.new,
status_sanitizer = FormatVersion5StatusSanitizer.new
status_sanitizer = FormatVersion6StatusSanitizer.new
)
super(log_sanitizer, metric_sanitizer, status_sanitizer)
end
Expand All @@ -342,8 +348,8 @@ def sanitize(raw)
Util.copy_attributes(sanitized, raw, %w[noop noop_pending corrective_change master_used])
end

class FormatVersion5StatusSanitizer < FormatVersion4StatusSanitizer
def initialize(event_sanitizer = FormatVersion5EventSanitizer.new)
class FormatVersion6StatusSanitizer < FormatVersion4StatusSanitizer
def initialize(event_sanitizer = FormatVersion6EventSanitizer.new)
super(event_sanitizer)
end

Expand All @@ -353,7 +359,7 @@ def sanitize(raw)
Util.copy_attributes(sanitized, raw, %w[corrective_change])
end

class FormatVersion5EventSanitizer < FormatVersion4EventSanitizer
class FormatVersion6EventSanitizer < FormatVersion4EventSanitizer
def sanitize(raw)
sanitized = super
Util.verify_attributes(raw, %w[corrective_change redacted])
Expand All @@ -379,4 +385,22 @@ def sanitize(raw)
end
end

class FormatVersion9 < FormatVersion8
def initialize(
log_sanitizer = FormatVersion4LogSanitizer.new,
metric_sanitizer = MetricSanitizer.new,
status_sanitizer = FormatVersion9StatusSanitizer.new
)
super(log_sanitizer, metric_sanitizer, status_sanitizer)
end

class FormatVersion9StatusSanitizer < FormatVersion6StatusSanitizer
def sanitize(raw)
sanitized = super
Util.verify_attributes(raw, %w[provider_used])
Util.copy_attributes(sanitized, raw, %w[provider_used])
end
end
end

end

0 comments on commit 83eacc9

Please sign in to comment.