env-checker 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/.rubocop_todo.yml +5 -10
- data/Gemfile.lock +1 -1
- data/README.md +26 -13
- data/lib/env_checker.rb +13 -27
- data/lib/env_checker/cli.rb +5 -4
- data/lib/env_checker/configuration.rb +18 -0
- data/lib/env_checker/version.rb +1 -1
- data/sample_config.yml +25 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c947e5de754d1f3516256571096b944fda28114
|
4
|
+
data.tar.gz: 2e9491a8e67ab09847f242d6e69bfcd426bc386c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 468664562b4cdcf6237f7d3cba41472b88290db4fbfff3520ada45467fc98b363b91edf573f9c4650db1bef1ddb649d75b4ef1fa0ba4fef7dd673c844dea02fc
|
7
|
+
data.tar.gz: 74fa44ecf12cec49fd81199fb5cc83a5acc37f1f43bd070aa45abf70b62d07bd0657f7e4bfee41df28c969d76722d54b1eb6fa3471a456c5aac9458bd570f5cf
|
data/.rubocop_todo.yml
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2016-11-
|
3
|
+
# on 2016-11-21 18:20:26 +0100 using RuboCop version 0.45.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 2
|
10
10
|
Metrics/AbcSize:
|
11
|
-
Max:
|
11
|
+
Max: 27
|
12
12
|
|
13
13
|
# Offense count: 1
|
14
14
|
# Configuration parameters: CountComments.
|
@@ -21,15 +21,10 @@ Metrics/BlockLength:
|
|
21
21
|
Metrics/LineLength:
|
22
22
|
Max: 95
|
23
23
|
|
24
|
-
# Offense count:
|
24
|
+
# Offense count: 4
|
25
25
|
# Configuration parameters: CountComments.
|
26
26
|
Metrics/MethodLength:
|
27
|
-
Max:
|
28
|
-
|
29
|
-
# Offense count: 1
|
30
|
-
# Configuration parameters: CountComments.
|
31
|
-
Metrics/ModuleLength:
|
32
|
-
Max: 109
|
27
|
+
Max: 23
|
33
28
|
|
34
29
|
# Offense count: 1
|
35
30
|
# Cop supports --auto-correct.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -93,23 +93,36 @@ end
|
|
93
93
|
|
94
94
|
Inline passing the variables with the shell:
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
```shell
|
97
|
+
$ env-checker check --optional MyOptVar1 MyOptVar2 --required MyReqVar1 MyReqVar2
|
98
|
+
|
99
|
+
Usage:
|
100
|
+
env-checker check
|
101
|
+
|
102
|
+
Options:
|
103
|
+
e, [--environment=ENVIRONMENT]
|
104
|
+
cf, [--config-file=CONFIG_FILE]
|
105
|
+
r, required, [--required-variables=one two three]
|
106
|
+
o, optional, [--optional-variables=one two three]
|
107
|
+
slack, [--slack-webhook-url=SLACK_WEBHOOK_URL]
|
108
|
+
[--run=RUN]
|
109
|
+
```
|
100
110
|
|
101
|
-
|
102
|
-
e, [--environment=ENVIRONMENT]
|
103
|
-
cf, [--config-file=CONFIG_FILE]
|
104
|
-
r, required, [--required-variables=one two three]
|
105
|
-
o, optional, [--optional-variables=one two three]
|
106
|
-
slack, [--slack-webhook-url=SLACK_WEBHOOK_URL]
|
107
|
-
[--run=RUN]
|
111
|
+
- All the parameters can be set by environment variables like:
|
108
112
|
|
113
|
+
```shell
|
114
|
+
$ export ENV_CHECKER_ENVIRONMENT=staging
|
115
|
+
$ export ENV_CHECKER_REQUIRED_VARIABLES=one two three
|
116
|
+
$ export ENV_CHECKER_OPTIONAL_VARIABLES=one two three
|
117
|
+
$ export ENV_CHECKER_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/.../.../.../
|
118
|
+
$ env-checker check
|
119
|
+
```
|
109
120
|
|
110
|
-
Example with a `.yml` [example file](https://raw.githubusercontent.com/ryanfox1985/env-checker/master/sample_config.yml):
|
121
|
+
- Example with a `.yml` [example file](https://raw.githubusercontent.com/ryanfox1985/env-checker/master/sample_config.yml):
|
111
122
|
|
112
|
-
|
123
|
+
```shell
|
124
|
+
$ env-checker check --config_file sample_config.yml
|
125
|
+
```
|
113
126
|
|
114
127
|
#### Show help
|
115
128
|
|
data/lib/env_checker.rb
CHANGED
@@ -5,7 +5,6 @@ require 'env_checker/version'
|
|
5
5
|
require 'env_checker/missing_keys_error'
|
6
6
|
require 'env_checker/configuration'
|
7
7
|
require 'env_checker/cli'
|
8
|
-
require 'byebug'
|
9
8
|
|
10
9
|
module EnvChecker
|
11
10
|
class << self
|
@@ -58,26 +57,23 @@ module EnvChecker
|
|
58
57
|
def create_config_from_parameters(options)
|
59
58
|
config = Configuration.new
|
60
59
|
|
60
|
+
attributes = %w(environment
|
61
|
+
optional_variables
|
62
|
+
required_variables
|
63
|
+
slack_webhook_url)
|
64
|
+
|
61
65
|
if options[:config_file]
|
62
66
|
from_file = YAML.load_file(options[:config_file])
|
63
|
-
config.optional_variables = from_file['optional_variables']
|
64
|
-
config.required_variables = from_file['required_variables']
|
65
|
-
config.slack_webhook_url = from_file['slack_webhook_url']
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
config.environment = options[:environment] if options[:environment]
|
71
|
-
if options[:optional_variables]
|
72
|
-
config.optional_variables = options[:optional_variables]
|
73
|
-
end
|
68
|
+
attributes.each do |a|
|
69
|
+
config.public_send("#{a}=", from_file[a]) if from_file[a]
|
70
|
+
end
|
74
71
|
|
75
|
-
|
76
|
-
config.required_variables = options[:required_variables]
|
72
|
+
return { 'global' => config }
|
77
73
|
end
|
78
74
|
|
79
|
-
|
80
|
-
config.
|
75
|
+
attributes.each do |a|
|
76
|
+
config.public_send("#{a}=", options[a.to_sym]) if options[a.to_sym]
|
81
77
|
end
|
82
78
|
|
83
79
|
{ 'global' => config }
|
@@ -123,19 +119,9 @@ module EnvChecker
|
|
123
119
|
|
124
120
|
message = format_error_message(environment, error_message)
|
125
121
|
|
126
|
-
configuration.
|
127
|
-
configuration.slack_notifier.ping(message)
|
122
|
+
configuration.notify_slack(message)
|
128
123
|
# TODO: add other integrations like email...
|
129
|
-
|
130
|
-
configuration.logger &&
|
131
|
-
case type
|
132
|
-
when :warning
|
133
|
-
configuration.logger.warn(message)
|
134
|
-
when :error
|
135
|
-
configuration.logger.error(message)
|
136
|
-
else
|
137
|
-
configuration.logger.info(message)
|
138
|
-
end
|
124
|
+
configuration.notify_logger(type, message)
|
139
125
|
end
|
140
126
|
|
141
127
|
def format_error_message(environment, error_message)
|
data/lib/env_checker/cli.rb
CHANGED
@@ -27,11 +27,12 @@ module EnvChecker
|
|
27
27
|
|
28
28
|
my_options = {}
|
29
29
|
variables.each do |v|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
env_var_name = "env_checker_#{v}".upcase
|
31
|
+
if ENV[env_var_name]
|
32
|
+
my_options[v.to_sym] ||= if env_var_name.include?('_VARIABLES')
|
33
|
+
ENV[env_var_name].split(' ')
|
33
34
|
else
|
34
|
-
ENV[
|
35
|
+
ENV[env_var_name]
|
35
36
|
end
|
36
37
|
end
|
37
38
|
my_options[v.to_sym] = options[v.to_sym] if options[v.to_sym]
|
@@ -35,6 +35,24 @@ module EnvChecker
|
|
35
35
|
true
|
36
36
|
end
|
37
37
|
|
38
|
+
def notify_slack(message)
|
39
|
+
slack_notifier && slack_notifier.ping(message)
|
40
|
+
rescue StandardError => e
|
41
|
+
notify_logger(:error, e)
|
42
|
+
end
|
43
|
+
|
44
|
+
def notify_logger(type, message)
|
45
|
+
logger &&
|
46
|
+
case type
|
47
|
+
when :warning
|
48
|
+
logger.warn(message)
|
49
|
+
when :error
|
50
|
+
logger.error(message)
|
51
|
+
else
|
52
|
+
logger.info(message)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
38
56
|
private
|
39
57
|
|
40
58
|
def valid?
|
data/lib/env_checker/version.rb
CHANGED
data/sample_config.yml
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
environments:
|
2
|
+
- staging
|
3
|
+
- production
|
4
|
+
- test
|
5
|
+
|
1
6
|
optional_variables:
|
2
7
|
- MyOptVar1
|
3
8
|
- MyOptVar2
|
@@ -6,3 +11,23 @@ required_variables:
|
|
6
11
|
- MyReqVar2
|
7
12
|
|
8
13
|
slack_webhook_url: https://hooks.slack.com/services/.../.../...
|
14
|
+
|
15
|
+
staging:
|
16
|
+
optional_variables:
|
17
|
+
- Staging_MyOptVar1
|
18
|
+
- Staging_MyOptVar2
|
19
|
+
required_variables:
|
20
|
+
- Staging_MyReqVar1
|
21
|
+
- Staging_MyReqVar2
|
22
|
+
|
23
|
+
slack_webhook_url: https://hooks.slack.com/services/.../.../...
|
24
|
+
|
25
|
+
production:
|
26
|
+
optional_variables:
|
27
|
+
- Production_MyOptVar1
|
28
|
+
- Production_MyOptVar2
|
29
|
+
required_variables:
|
30
|
+
- Production_MyReqVar1
|
31
|
+
- Production_MyReqVar2
|
32
|
+
|
33
|
+
slack_webhook_url: https://hooks.slack.com/services/.../.../...
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: env-checker
|
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
|
- Guillermo Guerrero Ibarra
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|