Class: Pvectl::Commands::Get::Handlers::Dns
- Inherits:
-
Object
- Object
- Pvectl::Commands::Get::Handlers::Dns
- Includes:
- ResourceHandler
- Defined in:
- lib/pvectl/commands/get/handlers/dns.rb
Overview
Handler for reading per-node DNS resolver settings.
Implements ResourceHandler interface for the “dns” resource type. DNS is a singleton resource per node — there is no cluster-wide DNS configuration, so a node name is always required.
Instance Method Summary collapse
-
#describe(name:, node: nil, **_opts) ⇒ Models::DnsConfig
Describes the DNS configuration for a single node.
-
#initialize(repository: nil) ⇒ Dns
constructor
Creates handler with optional repository for dependency injection.
-
#list(node: nil, **_options) ⇒ Array<Models::DnsConfig>
Returns the DNS configuration for the given node, wrapped in an array.
-
#presenter ⇒ Presenters::DnsConfig
Returns presenter for DNS configuration.
Methods included from ResourceHandler
Constructor Details
#initialize(repository: nil) ⇒ Dns
Creates handler with optional repository for dependency injection.
26 27 28 |
# File 'lib/pvectl/commands/get/handlers/dns.rb', line 26 def initialize(repository: nil) @repository = repository end |
Instance Method Details
#describe(name:, node: nil, **_opts) ⇒ Models::DnsConfig
Describes the DNS configuration for a single node.
Accepts either ‘name` (positional argument from describe command) or `node` (–node flag) as the node identifier.
59 60 61 62 63 64 |
# File 'lib/pvectl/commands/get/handlers/dns.rb', line 59 def describe(name:, node: nil, **_opts) node_name = name || node raise ArgumentError, "Node name required: pvectl describe dns NODE or --node NODE" if node_name.nil? || node_name.to_s.empty? repository.fetch(node_name) end |
#list(node: nil, **_options) ⇒ Array<Models::DnsConfig>
Returns the DNS configuration for the given node, wrapped in an array.
36 37 38 39 40 |
# File 'lib/pvectl/commands/get/handlers/dns.rb', line 36 def list(node: nil, **) raise ArgumentError, "DNS requires --node NODE to identify which node's settings to read" if node.nil? || node.to_s.empty? [repository.fetch(node)] end |
#presenter ⇒ Presenters::DnsConfig
Returns presenter for DNS configuration.
45 46 47 |
# File 'lib/pvectl/commands/get/handlers/dns.rb', line 45 def presenter Pvectl::Presenters::DnsConfig.new end |