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,
sig/pvectl/commands/get/handlers/dns.rbs
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 Attribute Summary collapse
-
#repository ⇒ Repositories::Dns
readonly
Returns repository, creating it if necessary.
Instance Method Summary collapse
-
#build_repository ⇒ Repositories::Dns
Builds repository with connection from config.
-
#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 Attribute Details
#repository ⇒ Repositories::Dns (readonly)
Returns repository, creating it if necessary.
71 72 73 |
# File 'lib/pvectl/commands/get/handlers/dns.rb', line 71 def repository @repository ||= build_repository end |
Instance Method Details
#build_repository ⇒ Repositories::Dns
Builds repository with connection from config.
78 79 80 81 82 83 |
# File 'lib/pvectl/commands/get/handlers/dns.rb', line 78 def build_repository config_service = Pvectl::Config::Service.new config_service.load connection = Pvectl::Connection.new(config_service.current_config) Pvectl::Repositories::Dns.new(connection) end |
#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 |