polyn-cli 0.1.7 → 0.1.8
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/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/polyn/cli/configuration.rb +3 -2
- data/lib/polyn/cli/schema_loader.rb +24 -10
- data/lib/polyn/cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc201c551bb6f0b5e55c32ff47557164de1a2020cd11e1997c2e2acc8f61025d
|
4
|
+
data.tar.gz: 50e911060818ec5b06db12ad09f683212b1b02fdb3241cafde48e8eccde2d4ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc1541bbaa72a2126c6d42a0c40352e0baf347a2cf6855213d70361b77154516cf998365ed0ddf5734292427a8411ec7fc3085b44856db3f13d8716e9278da58
|
7
|
+
data.tar.gz: c46bf95e3fe9afa651fccab77d8bd9e9cf4671a02a9c5a05952ce6c3bc0ab8854a38839aeb71a1fda6c5c121875d43a759037d781a4f8d58367bfd84fea96359
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -35,6 +35,7 @@ Run `polyn up` to update your NATS server with the latest configuration in your
|
|
35
35
|
* `NATS_SERVERS` - locations of your servers (defaults to localhost)
|
36
36
|
* `NATS_CREDENTIALS` - path to nats credentials file
|
37
37
|
* `NATS_CA_FILE` - Fully Qualified Path to a file containing Root CA (PEM format). Use when the server has certs signed by an unknown authority.
|
38
|
+
* `NATS_TLS` - Boolean, defaults to `false`. Should NATS connect with TLS?
|
38
39
|
* `POLYN_ENV` - type of environment (defaults to "development")
|
39
40
|
|
40
41
|
## Development
|
@@ -5,13 +5,14 @@ module Polyn
|
|
5
5
|
##
|
6
6
|
# Configuration data for Polyn::Cli
|
7
7
|
class Configuration
|
8
|
-
attr_reader :polyn_env, :nats_servers, :nats_credentials, :nats_ca_file
|
8
|
+
attr_reader :polyn_env, :nats_servers, :nats_credentials, :nats_ca_file, :nats_tls
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@polyn_env = ENV["POLYN_ENV"] || "development"
|
12
|
-
@nats_servers = ENV["NATS_SERVERS"] || "
|
12
|
+
@nats_servers = ENV["NATS_SERVERS"] || "nats://127.0.0.1:4222"
|
13
13
|
@nats_credentials = ENV["NATS_CREDENTIALS"] || ""
|
14
14
|
@nats_ca_file = ENV["NATS_CA_FILE"] || ""
|
15
|
+
@nats_tls = ENV["NATS_TLS"] || false
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -18,7 +18,7 @@ module Polyn
|
|
18
18
|
|
19
19
|
def initialize(thor, **opts)
|
20
20
|
@thor = thor
|
21
|
-
@client =
|
21
|
+
@client = connect
|
22
22
|
@store_name = opts.fetch(:store_name, STORE_NAME)
|
23
23
|
@bucket = client.key_value(@store_name)
|
24
24
|
@cloud_event_schema = Polyn::Cli::CloudEvent.to_h.freeze
|
@@ -52,6 +52,20 @@ module Polyn
|
|
52
52
|
:store_name,
|
53
53
|
:existing_events
|
54
54
|
|
55
|
+
def connect
|
56
|
+
opts = {
|
57
|
+
max_reconnect_attempts: 5,
|
58
|
+
reconnect_time_wait: 0.5,
|
59
|
+
servers: Polyn::Cli.configuration.nats_servers.split(","),
|
60
|
+
}
|
61
|
+
|
62
|
+
if Polyn::Cli.configuration.nats_tls
|
63
|
+
opts.tls = { context: ::OpenSSL::SSL::SSLContext.new(:TLSv1_2) }
|
64
|
+
end
|
65
|
+
|
66
|
+
NATS.connect(opts).jetstream
|
67
|
+
end
|
68
|
+
|
55
69
|
def read_events
|
56
70
|
event_files = Dir.glob(File.join(events_dir, "/**/*.json"))
|
57
71
|
validate_unique_event_types!(event_files)
|
@@ -70,16 +84,16 @@ module Polyn
|
|
70
84
|
|
71
85
|
def validate_unique_event_types!(event_files)
|
72
86
|
duplicates = find_duplicates(event_files)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
message = [
|
78
|
-
"There can only be one of each event type. The following events were duplicated:",
|
79
|
-
*messages,
|
80
|
-
].join("\n")
|
81
|
-
raise Polyn::Cli::ValidationError, message
|
87
|
+
return if duplicates.empty?
|
88
|
+
|
89
|
+
messages = duplicates.reduce([]) do |memo, (event_type, files)|
|
90
|
+
memo << [event_type, *files].join("\n")
|
82
91
|
end
|
92
|
+
message = [
|
93
|
+
"There can only be one of each event type. The following events were duplicated:",
|
94
|
+
*messages,
|
95
|
+
].join("\n")
|
96
|
+
raise Polyn::Cli::ValidationError, message
|
83
97
|
end
|
84
98
|
|
85
99
|
def find_duplicates(event_files)
|
data/lib/polyn/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyn-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarod
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-11-
|
12
|
+
date: 2022-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dotenv
|