zonesync 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a674bd1519c4b8bd6a30814b43e70365191c18a59b24615e0ed93bbf8f79c286
4
- data.tar.gz: c929821a57474a2d4be05f39f2e24e0cef38ab1484d5dbe6d8fbefba05ec60fc
3
+ metadata.gz: 28f9ce19995f365781be12a19d5275cdf6e8448a9e48024032071739c8742784
4
+ data.tar.gz: 668226c517ca89940c1d74dd25a1ce54777cee4bdb98a27ccde7607c412b1802
5
5
  SHA512:
6
- metadata.gz: e7678dc403b138a88de0d30a19a980c6c9d23ec3dcb6aa89157530cfc2e260b9e2dd610a1461b3d09174d3c70246c35d34d418a51802cc3c52cd651e5a42d1b2
7
- data.tar.gz: 42bf9f0ba6346af233735e236e0cc39e69adc3caf9e41901f8aeddc6936cfdf602086b9a0b3b2999bc8852c493f72a453d66106c8543bc9c95b218caaae35a53
6
+ metadata.gz: 897243ccc6bbf7812713a9acc1238018affce8691d03cabc8e3cf5ea11efc92be23dc79aee80c7f6da969d94aae471bff1a5a9ddcce6c11bd4089d586d18bb89
7
+ data.tar.gz: e633c1772ba7da543d75c93528ed1a54a4a57b79a7ff9e25fdb766fb4cb4ee7040048735c192d2f4f828e9a961044d59bca52e1e86c3064f87a4e28eda8efd47
data/lib/zonesync/cli.rb CHANGED
@@ -3,18 +3,24 @@ require "thor"
3
3
  module Zonesync
4
4
  class CLI < Thor
5
5
  default_command :sync
6
- desc "sync", "syncs the contents of Zonefile to the DNS server configured in Rails.application.credentials.zonesync"
6
+ desc "sync --source=Zonefile --destination=zonesync", "syncs the contents of the Zonefile to the DNS server configured in Rails.application.credentials.zonesync"
7
+ option :source, default: "Zonefile", desc: "path to the zonefile"
8
+ option :destination, default: "zonesync", desc: "key to the DNS server configuration in Rails.application.credentials"
7
9
  method_option :dry_run, type: :boolean, default: false, aliases: :n, desc: "log operations to STDOUT but don't perform the sync"
8
10
  def sync
9
- Zonesync.call dry_run: options[:dry_run]
11
+ kwargs = options.to_hash.transform_keys(&:to_sym)
12
+ Zonesync.call(**kwargs)
10
13
  rescue ConflictError, MissingManifestError, ChecksumMismatchError => e
11
14
  puts e.message
12
15
  exit 1
13
16
  end
14
17
 
15
- desc "generate", "generates a Zonefile from the DNS server configured in Rails.application.credentials.zonesync"
18
+ desc "generate --source=zonesync --destination=Zonefile", "generates a Zonefile from the DNS server configured in Rails.application.credentials.zonesync"
19
+ option :source, default: "zonesync", desc: "key to the DNS server configuration in Rails.application.credentials"
20
+ option :destination, default: "Zonefile", desc: "path to the zonefile"
16
21
  def generate
17
- Zonesync.generate
22
+ kwargs = options.to_hash.transform_keys(&:to_sym)
23
+ Zonesync.generate(**kwargs)
18
24
  end
19
25
 
20
26
  def self.exit_on_failure? = true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zonesync
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
data/lib/zonesync.rb CHANGED
@@ -7,15 +7,21 @@ require "zonesync/rake"
7
7
  require "zonesync/errors"
8
8
 
9
9
  module Zonesync
10
- def self.call zonefile: "Zonefile", credentials: default_credentials, dry_run: false
11
- Sync.new({ provider: "Filesystem", path: zonefile }, credentials).call(dry_run: dry_run)
10
+ def self.call source: "Zonefile", destination: "zonesync", dry_run: false
11
+ Sync.new(
12
+ { provider: "Filesystem", path: source },
13
+ credentials[destination]
14
+ ).call(dry_run: dry_run)
12
15
  end
13
16
 
14
- def self.generate zonefile: "Zonefile", credentials: default_credentials
15
- Generate.new({ provider: "Filesystem", path: zonefile }, credentials).call
17
+ def self.generate source: "zonesync", destination: "Zonefile"
18
+ Generate.new(
19
+ credentials[source],
20
+ { provider: "Filesystem", path: destination }
21
+ ).call
16
22
  end
17
23
 
18
- def self.default_credentials
24
+ def self.credentials
19
25
  require "active_support"
20
26
  require "active_support/encrypted_configuration"
21
27
  require "active_support/core_ext/hash/keys"
@@ -24,11 +30,7 @@ module Zonesync
24
30
  key_path: "config/master.key",
25
31
  env_key: "RAILS_MASTER_KEY",
26
32
  raise_if_missing_key: true,
27
- ).zonesync
28
- end
29
-
30
- def self.default_provider
31
- Provider.from(default_credentials)
33
+ )
32
34
  end
33
35
 
34
36
  class Sync < Struct.new(:source, :destination)
@@ -73,7 +75,7 @@ module Zonesync
73
75
  def call
74
76
  source = Provider.from(self.source)
75
77
  destination = Provider.from(self.destination)
76
- source.write(destination.read)
78
+ destination.write(source.read)
77
79
  end
78
80
  end
79
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zonesync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel