Class: Dash::Configuration::Report
- Inherits:
-
Object
- Object
- Dash::Configuration::Report
- Includes:
- Validation
- Defined in:
- lib/dash/configuration/report.rb
Overview
The report: block: how much of the deploy report to print, and how much of it to keep.
Every key is optional and the defaults are what an operator who has never heard of the block gets — the table always prints, the advice under it prints, and hadolint joins in only if they already have it installed.
Constant Summary collapse
- DEFAULT_HISTORY =
20- HADOLINT_AUTO =
"auto".freeze
- HADOLINT_SETTINGS =
[ HADOLINT_AUTO, true, false ].freeze
Instance Attribute Summary collapse
-
#report_config ⇒ Object
readonly
Returns the value of attribute report_config.
Instance Method Summary collapse
- #advice? ⇒ Boolean
- #hadolint ⇒ Object
-
#hadolint? ⇒ Boolean
"auto" (or true) means run it when it is on PATH — the availability check itself lives in Dash::Dockerfile::Hadolint, because only it knows what running costs.
- #history ⇒ Object
- #ignore ⇒ Object
-
#initialize(config:) ⇒ Report
constructor
A new instance of Report.
- #to_h ⇒ Object
Methods included from Validation
Constructor Details
#initialize(config:) ⇒ Report
Returns a new instance of Report.
16 17 18 19 20 21 |
# File 'lib/dash/configuration/report.rb', line 16 def initialize(config:) @report_config = config.raw_config.report || {} validate! @report_config unless @report_config.empty? ensure_valid_hadolint_setting ensure_valid_history end |
Instance Attribute Details
#report_config ⇒ Object (readonly)
Returns the value of attribute report_config.
12 13 14 |
# File 'lib/dash/configuration/report.rb', line 12 def report_config @report_config end |
Instance Method Details
#advice? ⇒ Boolean
23 24 25 |
# File 'lib/dash/configuration/report.rb', line 23 def advice? report_config.fetch("advice", true) end |
#hadolint ⇒ Object
27 28 29 |
# File 'lib/dash/configuration/report.rb', line 27 def hadolint report_config.fetch("hadolint", HADOLINT_AUTO) end |
#hadolint? ⇒ Boolean
"auto" (or true) means run it when it is on PATH — the availability check itself lives in Dash::Dockerfile::Hadolint, because only it knows what running costs.
33 34 35 |
# File 'lib/dash/configuration/report.rb', line 33 def hadolint? hadolint != false end |
#history ⇒ Object
37 38 39 |
# File 'lib/dash/configuration/report.rb', line 37 def history report_config.fetch("history", DEFAULT_HISTORY).to_i end |
#ignore ⇒ Object
41 42 43 |
# File 'lib/dash/configuration/report.rb', line 41 def ignore Array(report_config["ignore"]).map(&:to_s) end |
#to_h ⇒ Object
45 46 47 |
# File 'lib/dash/configuration/report.rb', line 45 def to_h report_config end |