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 +4 -4
- data/lib/zonesync/cli.rb +10 -4
- data/lib/zonesync/version.rb +1 -1
- data/lib/zonesync.rb +13 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28f9ce19995f365781be12a19d5275cdf6e8448a9e48024032071739c8742784
|
4
|
+
data.tar.gz: 668226c517ca89940c1d74dd25a1ce54777cee4bdb98a27ccde7607c412b1802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
data/lib/zonesync/version.rb
CHANGED
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
|
11
|
-
Sync.new(
|
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
|
15
|
-
Generate.new(
|
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.
|
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
|
-
)
|
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
|
-
|
78
|
+
destination.write(source.read)
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|