Class: DnsMadeEasy::CLI::Commands::Zone::Plan
- Defined in:
- lib/dnsmadeeasy/cli/commands/zone.rb
Overview
Produces a non-destructive plan comparing a zone file to remote records.
Constant Summary
Constants inherited from Base
Base::DEFAULT_CREDENTIAL_PATHS, Base::SUPPORTED_FORMATS
Constants included from MessageHelpers
Instance Method Summary collapse
Methods included from MessageHelpers
error, included, info, print_box, success, warn
Instance Method Details
#call(file:, domain: nil, format: 'text', diff_ttl: false, credentials: nil, api_key: nil, api_secret: nil) ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/dnsmadeeasy/cli/commands/zone.rb', line 186 def call(file:, domain: nil, format: 'text', diff_ttl: false, credentials: nil, api_key: nil, api_secret: nil, **) configure_authentication(credentials: credentials, api_key: api_key, api_secret: api_secret) desired_result = DnsMadeEasy::Zone::Parser.new(::File.read(file)).call return fail_with('Zone file is invalid', desired_result.failure) if desired_result.failure? plan_domain = domain || desired_result.value!.origin remote_result = remote_records(plan_domain) return fail_with('Remote records are invalid', remote_result.failure) if remote_result.failure? plan = DnsMadeEasy::Zone::Diff.new( desired_records: desired_result.value!.records, remote_records: remote_result.value!.records, compare_ttl: diff_ttl ).call renderer = DnsMadeEasy::Zone::PlanRenderer.new(plan) puts(format == 'json' ? renderer.to_json : renderer.to_text) success(plan_summary(plan_domain, plan)) end |