diffend 0.2.32 → 0.2.33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e0efaea5a8bb4c724e24057821578b6c257a5eb313c472ac17dd60747fe10e4
4
- data.tar.gz: af3b702fa128eabcc8f6f054895c0e64097f38672b650697e292ab705b749b69
3
+ metadata.gz: ca45ede600a1ba9ef22e538d14f4de5be8c662e7b3c39211e52327fbf99b6f92
4
+ data.tar.gz: 5054f7dfa57e79adb3734e30c6cecaa7865fe3b9c0aef345c146cad49019529f
5
5
  SHA512:
6
- metadata.gz: 00e60e3f610e03cad43a65b11c1b7f17d839d4b43009dde4436b9eebd96b82bdbf0035860eb85fb0e57c7042221403894a1aaf5f89cb606a86dd15e94f65bc58
7
- data.tar.gz: f45b310e0e376b50e27b7a1876f3704a3f282dbadac5c868b4548a4a6a2d582632aeb3f204e47fda5545f47807446e648b0bf2fe70b4a0abdefb17ea40cf1ff1
6
+ metadata.gz: cede14b22f216cdf7c520d1455676dea8d0a911adf2206d59ba6fc4db8e880b38cd846aeb29cd8e82ec27f13db533442c3853433c7032336879eb7c05d5ddd4c
7
+ data.tar.gz: 8f6e842c2b9557e76e7cf09e9ed62a8a9f251a7caa21cc2cae5a488aae928ae006df9f081429116d8df8e46acbf5c62e7e9f0097875813bcd0b8b75ef57a3b7b
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.7.2
@@ -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.30...HEAD
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
@@ -7,7 +7,5 @@ plugin 'diffend'
7
7
  gemspec
8
8
 
9
9
  group :development, :test do
10
- gem 'byebug', platform: :ruby
11
- gem 'pry', platform: :jruby
12
10
  gem 'rspec'
13
11
  end
@@ -1,26 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- diffend (0.2.32)
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.2)
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
 
@@ -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' %>
@@ -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
- content = ERB.new(
45
- File.read(
46
- FileFinder.call(build_path)
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
- raise Errors::EmptyConfigurationFile if content.empty?
41
+ if File.exist?(project_config)
42
+ hash.merge!(read_file(project_config) || {})
43
+ end
51
44
 
52
- parse_file(content)
45
+ hash
53
46
  end
54
47
 
55
- def parse_file(content)
56
- YAML.safe_load(content)
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
@@ -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
@@ -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
- config = Diffend::Config.new(
30
- command: Diffend::Commands::EXEC,
31
- severity: Diffend::Logger::FATAL
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
 
@@ -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
- return if config.ignore_errors?
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
@@ -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...'
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Diffend
4
4
  # Current version
5
- VERSION = '0.2.32'
5
+ VERSION = '0.2.33'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diffend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.32
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-02 00:00:00.000000000 Z
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.2
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