Class: Pvectl::Presenters::DnsConfig
- Defined in:
- lib/pvectl/presenters/dns_config.rb
Overview
Presenter for per-node DNS resolver configuration.
Defines column layout for table output and structured data for JSON/YAML and describe output. DNS is a singleton resource per node.
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns column headers for standard table output.
-
#to_description(model) ⇒ Hash
Converts DnsConfig model to describe format (kubectl-style).
-
#to_hash(model) ⇒ Hash
Converts DnsConfig model to hash for JSON/YAML output.
-
#to_row(model, **_context) ⇒ Array<String>
Converts DnsConfig model to table row values.
Methods inherited from Base
#extra_columns, #extra_values, #tags_array, #tags_display, #template_display, #to_wide_row, #uptime_human, #wide_columns
Instance Method Details
#columns ⇒ Array<String>
Returns column headers for standard table output.
21 22 23 |
# File 'lib/pvectl/presenters/dns_config.rb', line 21 def columns %w[NODE SEARCH DNS1 DNS2 DNS3] end |
#to_description(model) ⇒ Hash
Converts DnsConfig model to describe format (kubectl-style).
58 59 60 61 62 63 64 65 |
# File 'lib/pvectl/presenters/dns_config.rb', line 58 def to_description(model) servers = model.servers { "Node" => model.node || "-", "Search Domain" => model.search || "-", "Nameservers" => servers.empty? ? "-" : servers } end |
#to_hash(model) ⇒ Hash
Converts DnsConfig model to hash for JSON/YAML output.
44 45 46 47 48 49 50 51 52 |
# File 'lib/pvectl/presenters/dns_config.rb', line 44 def to_hash(model) { "node" => model.node, "search" => model.search, "dns1" => model.dns1, "dns2" => model.dns2, "dns3" => model.dns3 } end |
#to_row(model, **_context) ⇒ Array<String>
Converts DnsConfig model to table row values.
30 31 32 33 34 35 36 37 38 |
# File 'lib/pvectl/presenters/dns_config.rb', line 30 def to_row(model, **_context) [ model.node || "-", model.search || "-", model.dns1 || "-", model.dns2 || "-", model.dns3 || "-" ] end |