diffend-monitor 0.2.32 → 0.2.33
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +10 -1
- data/Gemfile +0 -2
- data/Gemfile.lock +2 -14
- data/config/diffend.yml +6 -0
- data/lib/diffend/config.rb +5 -6
- data/lib/diffend/configs/fetcher.rb +15 -40
- data/lib/diffend/errors.rb +0 -4
- data/lib/diffend/monitor.rb +9 -5
- data/lib/diffend/plugin.rb +2 -2
- data/lib/diffend/request.rb +2 -1
- data/lib/diffend/version.rb +1 -1
- metadata +4 -4
- metadata.gz.sig +0 -0
- data/lib/diffend/configs/file_finder.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba1c9bb7665b8c21fd45c17d75edf757fa23a07170d62182c12630705a465dc9
|
4
|
+
data.tar.gz: ac0e9d69574c6b1fc7302ebada67570975f16e32c85c4f35caa5f2c11fa303d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2ab62a44ab9d8be96fd37eccb1af6d015645c34c2953c56f2481f3d91a49ea88df88962250554600a64d3e3b73140905c8fda755e8dbc66850c4d4b958a5206
|
7
|
+
data.tar.gz: 86b2f1c7f0bb5b2fb23a2c590574f087bdc621fa13e59da09bdf4033218322c501df2f77e773a158939be7e9bda1cf114b78e5315cbfe0edb65b398e6d21d59f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.2
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## [Unreleased][master]
|
4
4
|
|
5
|
+
## [0.2.33] (2020-10-25)
|
6
|
+
- fix an exception when configuration file is missing ([#65](https://github.com/diffend-io/diffend-ruby/pull/65))
|
7
|
+
- silently exit when configuration file is missing in `Diffend::Monitor` ([#66](https://github.com/diffend-io/diffend-ruby/pull/66))
|
8
|
+
- introduce default config ([#67](https://github.com/diffend-io/diffend-ruby/pull/67))
|
9
|
+
- handle `SocketError` ([#68](https://github.com/diffend-io/diffend-ruby/pull/68))
|
10
|
+
|
5
11
|
## [0.2.32] (2020-10-02)
|
6
12
|
- fix how we build platform from `Gem::Platform` ([#56](https://github.com/diffend-io/diffend-ruby/pull/56))
|
7
13
|
- introduce `Diffend::LatestVersion` ([#57](https://github.com/diffend-io/diffend-ruby/pull/57))
|
@@ -85,7 +91,10 @@
|
|
85
91
|
|
86
92
|
- initial release
|
87
93
|
|
88
|
-
[master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.
|
94
|
+
[master]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.33...HEAD
|
95
|
+
[0.2.33]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.32...v0.2.33
|
96
|
+
[0.2.32]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.31...v0.2.32
|
97
|
+
[0.2.31]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.30...v0.2.31
|
89
98
|
[0.2.30]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.29...v0.2.30
|
90
99
|
[0.2.29]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.28...v0.2.29
|
91
100
|
[0.2.28]: https://github.com/diffend-io/diffend-ruby/compare/v0.2.27...v0.2.28
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
diffend (0.2.
|
4
|
+
diffend (0.2.33)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
byebug (11.1.3)
|
10
|
-
coderay (1.1.3)
|
11
9
|
diff-lcs (1.4.4)
|
12
|
-
ffi (1.13.1-java)
|
13
|
-
method_source (1.0.0)
|
14
|
-
pry (0.13.1-java)
|
15
|
-
coderay (~> 1.1)
|
16
|
-
method_source (~> 1.0)
|
17
|
-
spoon (~> 0.0)
|
18
10
|
rake (13.0.1)
|
19
11
|
rspec (3.9.0)
|
20
12
|
rspec-core (~> 3.9.0)
|
21
13
|
rspec-expectations (~> 3.9.0)
|
22
14
|
rspec-mocks (~> 3.9.0)
|
23
|
-
rspec-core (3.9.
|
15
|
+
rspec-core (3.9.3)
|
24
16
|
rspec-support (~> 3.9.3)
|
25
17
|
rspec-expectations (3.9.2)
|
26
18
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -29,8 +21,6 @@ GEM
|
|
29
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
30
22
|
rspec-support (~> 3.9.0)
|
31
23
|
rspec-support (3.9.3)
|
32
|
-
spoon (0.0.6)
|
33
|
-
ffi
|
34
24
|
|
35
25
|
PLATFORMS
|
36
26
|
java
|
@@ -38,9 +28,7 @@ PLATFORMS
|
|
38
28
|
|
39
29
|
DEPENDENCIES
|
40
30
|
bundler
|
41
|
-
byebug
|
42
31
|
diffend!
|
43
|
-
pry
|
44
32
|
rake
|
45
33
|
rspec
|
46
34
|
|
data/config/diffend.yml
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
project_id: <%= ENV['DIFFEND_PROJECT_ID'] %>
|
2
|
+
shareable_id: <%= ENV['DIFFEND_SHAREABLE_ID'] %>
|
3
|
+
shareable_key: <%= ENV['DIFFEND_SHAREABLE_KEY'] %>
|
4
|
+
env: <%= ENV['DIFFEND_ENV'] || 'development' %>
|
5
|
+
ignore_errors: <%= ENV['DIFFEND_IGNORE_ERRORS'] || 'true' %>
|
6
|
+
development: <%= ENV['DIFFEND_DEVELOPMENT'] || 'true' %>
|
data/lib/diffend/config.rb
CHANGED
@@ -8,8 +8,6 @@ module Diffend
|
|
8
8
|
# Build diffend config object
|
9
9
|
#
|
10
10
|
# @return [Diffend::Config]
|
11
|
-
#
|
12
|
-
# @raise [Errors::MissingConfigurationFile] when no config file
|
13
11
|
def initialize(command: nil, severity: nil, build_path: nil)
|
14
12
|
@log_level = severity
|
15
13
|
build(command, build_path)
|
@@ -57,11 +55,8 @@ module Diffend
|
|
57
55
|
|
58
56
|
def build(command, build_path)
|
59
57
|
build_path ||= File.expand_path('..', ::Bundler.bin_path)
|
60
|
-
hash = Diffend::Configs::Fetcher.call(logger, build_path)
|
58
|
+
hash = Diffend::Configs::Fetcher.call(logger, plugin_path, build_path)
|
61
59
|
hash['build_path'] = build_path
|
62
|
-
hash['env'] = ENV['DIFFEND_ENV'] || 'development'
|
63
|
-
hash['ignore_errors'] = ENV['DIFFEND_IGNORE_ERRORS'] == 'true'
|
64
|
-
hash['development'] = ENV['DIFFEND_DEVELOPMENT'] == 'true'
|
65
60
|
hash['command'] = command || build_command
|
66
61
|
|
67
62
|
hash.each { |key, value| instance_variable_set(:"@#{key}", value) }
|
@@ -77,5 +72,9 @@ module Diffend
|
|
77
72
|
def build_command
|
78
73
|
ARGV.first || ::Bundler.feature_flag.default_cli_command.to_s
|
79
74
|
end
|
75
|
+
|
76
|
+
def plugin_path
|
77
|
+
Pathname.new(File.expand_path('../..', __dir__))
|
78
|
+
end
|
80
79
|
end
|
81
80
|
end
|
@@ -9,6 +9,7 @@ module Diffend
|
|
9
9
|
module Fetcher
|
10
10
|
class << self
|
11
11
|
# @param logger [Diffend::Logger]
|
12
|
+
# @param plugin_path [String] path of the plugin
|
12
13
|
# @param build_path [String] path of the current build
|
13
14
|
#
|
14
15
|
# @return [Hash] details from configuration file
|
@@ -16,18 +17,8 @@ module Diffend
|
|
16
17
|
# @example
|
17
18
|
# details = Fetcher.new.call('./')
|
18
19
|
# details.build_path #=> './'
|
19
|
-
def call(logger, build_path)
|
20
|
-
build(build_path)
|
21
|
-
rescue Errors::MissingConfigurationFile
|
22
|
-
build_missing_error_message(build_path)
|
23
|
-
.tap(&logger.method(:fatal))
|
24
|
-
|
25
|
-
raise Diffend::Errors::HandledException
|
26
|
-
rescue Errors::EmptyConfigurationFile
|
27
|
-
build_empty_error_message(build_path)
|
28
|
-
.tap(&logger.method(:fatal))
|
29
|
-
|
30
|
-
raise Diffend::Errors::HandledException
|
20
|
+
def call(logger, plugin_path, build_path)
|
21
|
+
build(plugin_path, build_path)
|
31
22
|
rescue Errors::MalformedConfigurationFile
|
32
23
|
build_malformed_error_message(build_path)
|
33
24
|
.tap(&logger.method(:fatal))
|
@@ -37,45 +28,29 @@ module Diffend
|
|
37
28
|
|
38
29
|
private
|
39
30
|
|
31
|
+
# @param plugin_path [String] path of the plugin
|
40
32
|
# @param build_path [String] path of the current build
|
41
33
|
#
|
42
34
|
# @return [OpenStruct] open struct with config details
|
43
|
-
def build(build_path)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
).result
|
35
|
+
def build(plugin_path, build_path)
|
36
|
+
default_config = File.join(plugin_path, 'config', 'diffend.yml')
|
37
|
+
project_config = File.join(build_path, '.diffend.yml')
|
38
|
+
|
39
|
+
hash = read_file(default_config)
|
49
40
|
|
50
|
-
|
41
|
+
if File.exist?(project_config)
|
42
|
+
hash.merge!(read_file(project_config) || {})
|
43
|
+
end
|
51
44
|
|
52
|
-
|
45
|
+
hash
|
53
46
|
end
|
54
47
|
|
55
|
-
def
|
56
|
-
YAML.safe_load(
|
48
|
+
def read_file(path)
|
49
|
+
YAML.safe_load(ERB.new(File.read(path)).result)
|
57
50
|
rescue Psych::SyntaxError
|
58
51
|
raise Errors::MalformedConfigurationFile
|
59
52
|
end
|
60
53
|
|
61
|
-
# @param build_path [String] path of the current build
|
62
|
-
#
|
63
|
-
# @return [String] missing configuration file message
|
64
|
-
def build_missing_error_message(build_path)
|
65
|
-
<<~MSG
|
66
|
-
\nWe were unable to locate Diffend configuration file.\n
|
67
|
-
Please make sure that .diffend.yml is present in #{build_path} folder.\n
|
68
|
-
MSG
|
69
|
-
end
|
70
|
-
|
71
|
-
# @return [String] empty configuration file message
|
72
|
-
def build_empty_error_message
|
73
|
-
<<~MSG
|
74
|
-
\nYour Diffend configuration file is empty.\n
|
75
|
-
Please re-setup.\n
|
76
|
-
MSG
|
77
|
-
end
|
78
|
-
|
79
54
|
# @return [String] malformed configuration file message
|
80
55
|
def build_malformed_error_message
|
81
56
|
<<~MSG
|
data/lib/diffend/errors.rb
CHANGED
@@ -5,10 +5,6 @@ module Diffend
|
|
5
5
|
module Errors
|
6
6
|
# Base error class from which all the errors should inherit
|
7
7
|
BaseError = Class.new(StandardError)
|
8
|
-
# Raised when we couldn't find a valid configuration file
|
9
|
-
MissingConfigurationFile = Class.new(BaseError)
|
10
|
-
# Raised when configuration file is empty
|
11
|
-
EmptyConfigurationFile = Class.new(BaseError)
|
12
8
|
# Raised when configuration file is malformed
|
13
9
|
MalformedConfigurationFile = Class.new(BaseError)
|
14
10
|
# Raised when project_id is missing in configuration file
|
data/lib/diffend/monitor.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
commands
|
9
9
|
config
|
10
10
|
configs/fetcher
|
11
|
-
configs/file_finder
|
12
11
|
configs/validator
|
13
12
|
handle_errors/messages
|
14
13
|
handle_errors/build_exception_payload
|
@@ -26,10 +25,15 @@
|
|
26
25
|
track
|
27
26
|
].each { |file| require "diffend/#{file}" }
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
begin
|
29
|
+
config = Diffend::Config.new(
|
30
|
+
command: Diffend::Commands::EXEC,
|
31
|
+
severity: Diffend::Logger::FATAL
|
32
|
+
)
|
33
|
+
rescue Diffend::Errors::HandledException
|
34
|
+
# we silent exit here because we don't want to break client boot
|
35
|
+
return
|
36
|
+
end
|
33
37
|
|
34
38
|
return if %w[development test].include?(config.env)
|
35
39
|
|
data/lib/diffend/plugin.rb
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
commands
|
14
14
|
config
|
15
15
|
configs/fetcher
|
16
|
-
configs/file_finder
|
17
16
|
configs/validator
|
18
17
|
handle_errors/messages
|
19
18
|
handle_errors/build_exception_payload
|
@@ -51,7 +50,8 @@ module Diffend
|
|
51
50
|
|
52
51
|
Diffend::Execute.call(config)
|
53
52
|
rescue Diffend::Errors::HandledException
|
54
|
-
|
53
|
+
# config will not be initialized when configuration file is missing
|
54
|
+
return if config&.ignore_errors?
|
55
55
|
|
56
56
|
exit 255
|
57
57
|
rescue StandardError => e
|
data/lib/diffend/request.rb
CHANGED
@@ -14,7 +14,8 @@ module Diffend
|
|
14
14
|
Errno::ECONNRESET,
|
15
15
|
Errno::ENETUNREACH,
|
16
16
|
Errno::EHOSTUNREACH,
|
17
|
-
Errno::ECONNREFUSED
|
17
|
+
Errno::ECONNREFUSED,
|
18
|
+
SocketError
|
18
19
|
].freeze
|
19
20
|
# Message displayed when timeout occured and we will retry
|
20
21
|
TIMEOUT_MESSAGE = 'We experienced a connection issue, retrying...'
|
data/lib/diffend/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diffend-monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Pajor
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
9MmF6uCQa1EjK2p8tYT0MnbHrFkoehxdX4VO9y99GAkhZyJNKPYPtyAUFV27sT2V
|
35
35
|
LfCJRk4ifKIN/FUCwDSn8Cz0m6oH265q0p6wdzI6qrWOjP8tGOMBTA==
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2020-10-
|
37
|
+
date: 2020-10-25 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: bundler
|
@@ -90,13 +90,13 @@ files:
|
|
90
90
|
- bin/rspec
|
91
91
|
- certs/mensfeld.pem
|
92
92
|
- certs/tomaszpajor.pem
|
93
|
+
- config/diffend.yml
|
93
94
|
- diffend.gemspec
|
94
95
|
- lib/diffend.rb
|
95
96
|
- lib/diffend/build_bundler_definition.rb
|
96
97
|
- lib/diffend/commands.rb
|
97
98
|
- lib/diffend/config.rb
|
98
99
|
- lib/diffend/configs/fetcher.rb
|
99
|
-
- lib/diffend/configs/file_finder.rb
|
100
100
|
- lib/diffend/configs/validator.rb
|
101
101
|
- lib/diffend/errors.rb
|
102
102
|
- lib/diffend/execute.rb
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
|
-
rubygems_version: 3.1.
|
142
|
+
rubygems_version: 3.1.4
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: OSS supply chain security and management platform
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Diffend
|
4
|
-
module Configs
|
5
|
-
# Class used to figure out the file from which we should load the settings
|
6
|
-
module FileFinder
|
7
|
-
# Names of the files or paths where we will look for the settings
|
8
|
-
#
|
9
|
-
# @note We do the double dot trick, to look outside of the current dir because when
|
10
|
-
# executed from a docker container, we copy the local uncommitted settings into the
|
11
|
-
# dir above the app location not to pollute the reset state of the git repo
|
12
|
-
#
|
13
|
-
# @note Order is important, as for local env we should load from
|
14
|
-
# local file (if present first)
|
15
|
-
FILE_NAMES = %w[
|
16
|
-
.diffend.yml
|
17
|
-
].map { |name| ["../#{name}", name] }.tap(&:flatten!).freeze
|
18
|
-
|
19
|
-
private_constant :FILE_NAMES
|
20
|
-
|
21
|
-
class << self
|
22
|
-
# Looks for Diffend settings file for a given env
|
23
|
-
#
|
24
|
-
# @param build_path [String] path of the current build
|
25
|
-
#
|
26
|
-
# @return [String] path to the file from which we should load all the settings
|
27
|
-
def call(build_path)
|
28
|
-
FILE_NAMES
|
29
|
-
.map { |name| File.join(build_path, name) }
|
30
|
-
.map { |name| Dir[name] }
|
31
|
-
.find { |selection| !selection.empty? }
|
32
|
-
.tap { |path| path || raise(Errors::MissingConfigurationFile) }
|
33
|
-
.first
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|