ufo 6.2.2 → 6.2.3

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: e630cb6fc68958a6b7f7264e6b0ff03a2d41ae13d9a1648bd13fa601d9f9aae0
4
- data.tar.gz: 2693b4ca4e3e5ffa31ff881f706de093792d93a4ff7263820308565d44685c38
3
+ metadata.gz: 2fd574a73d9028bd0627e5c7d74b5bb516ee62aa1ae2a0d3c85f01470ef39284
4
+ data.tar.gz: 96fcdff5429e785572cff2f4face5cc2100a1ce95a912adf6bfc275343471518
5
5
  SHA512:
6
- metadata.gz: 116244ca9466e2458845904b34d99bc1fd2e7d1d8379c32066d2f90d70cfe7eb84628552a8250f7d4cca13dcdcf1cdad0ba812e602ba1df25c4f0b383131c057
7
- data.tar.gz: 7e7aa81c1595f231465f1694a80dc7e4f0a8f7f7c77399e28b12b71c109a2c5ea0b9674fd0e8a9b485792253e16c4fd4a27734a121affd01bb69e163fb6e9f51
6
+ metadata.gz: 11fccb6c4b62fe986f77a12e2aeb2d67ec7d2874ca1a9eed9afab32317a94e5235340896bd7fc590abf665b06bccfe4961fda78a0b77b2749cfbaffb4361dca3
7
+ data.tar.gz: 32e9654b2700f3445a2383a84e323458bc1b81368901c3d83dac7c4d809fa7c5ef5d6bf5405dbd858b95f0ff34f8939f4660ee35118a11b5fa8976868c6f9b93
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [6.2.3] - 2022-03-20
7
+ - [#157](https://github.com/tongueroo/ufo/pull/157) layering.show_for_commands option
8
+
6
9
  ## [6.2.2] - 2022-03-20
7
10
  - [#155](https://github.com/tongueroo/ufo/pull/155) layering.show option ability to show layers
8
11
  - [#156](https://github.com/tongueroo/ufo/pull/156) extra layering support
@@ -0,0 +1,39 @@
1
+ # Some limitations:
2
+ #
3
+ # * Only parsing one file: .ufo/config.rb
4
+ # * If user is using Ruby code that cannot be parse will fallback to default
5
+ #
6
+ # Think it's worth it so user only has to configure
7
+ #
8
+ # config.layering.show = true
9
+ #
10
+ class Ufo::Config
11
+ class Parse
12
+ def for(config, type: :boolean)
13
+ lines = IO.readlines("#{Ufo.root}/.ufo/config.rb")
14
+ config_line = lines.find do |l|
15
+ # IE: Regexp.new("config\.layering.show.*=")
16
+ regexp = Regexp.new("config\.#{config}.*=")
17
+ l =~ regexp && l !~ /^\s+#/
18
+ end
19
+ return false unless config_line # default is false
20
+ config_value = config_line.gsub(/.*=/,'').strip.gsub(/["']/,'')
21
+ case type
22
+ when :boolean
23
+ config_value != "false" && config_value != "nil"
24
+ when :array
25
+ eval(config_value) # IE: '["a"]' => ["a"]
26
+ else
27
+ raise "Type #{type.inspect} not supported"
28
+ end
29
+ rescue Exception => e
30
+ # if ENV['UFO_DEBUG']
31
+ puts "#{e.class} #{e.message}".color(:yellow)
32
+ puts "WARN: Unable to parse for config.layering.show".color(:yellow)
33
+ puts "Using default: config.layering.show = false"
34
+ # end
35
+ false
36
+ end
37
+ end
38
+ end
39
+
data/lib/ufo/config.rb CHANGED
@@ -86,7 +86,8 @@ module Ufo
86
86
  config.exec.enabled = true # EcsService EnableExecuteCommand
87
87
 
88
88
  config.layering = ActiveSupport::OrderedOptions.new
89
- config.layering.show = show_layers?
89
+ config.layering.show = parsed_layering_show
90
+ config.layering.show_for_commands = parsed_layering_show_for
90
91
 
91
92
  config.log = ActiveSupport::OrderedOptions.new
92
93
  config.log.root = Ufo.log_root
@@ -165,7 +166,7 @@ module Ufo
165
166
  end
166
167
  # load_project_config gets called so early that logger is not yet configured.
167
168
  # Cannot use Ufo.config yet and cannot use logger which relies on Ufo.config
168
- # Use puts and use show_layers? which parses for the config
169
+ # Use puts and use parsed_layering_show
169
170
  show = show_layers?
170
171
  puts "Config Layers" if show
171
172
  layers.each do |layer|
@@ -180,34 +181,25 @@ module Ufo
180
181
  end
181
182
 
182
183
  def show_layers?
183
- ENV['UFO_LAYERS'] || parse_for_layering_show
184
+ show_for = parsed_layering_show_for
185
+ command = ARGV[0]
186
+ parsed_layering_show && show_for.include?(command)
184
187
  end
185
- private :show_layers?
186
188
 
187
- # Some limitations:
188
- #
189
- # * Only parsing one file: .ufo/config.rb
190
- # * If user is using Ruby code that cannot be parse will fallback to default
191
- #
192
- # Think it's worth it so user only has to configure
193
- #
194
- # config.layering.show = true
195
- #
196
- def parse_for_layering_show
197
- lines = IO.readlines("#{Ufo.root}/.ufo/config.rb")
198
- config_line = lines.find { |l| l =~ /config\.layering.show.*=/ && l !~ /^\s+#/ }
199
- return false unless config_line # default is false
200
- config_value = config_line.gsub(/.*=/,'').strip.gsub(/["']/,'')
201
- config_value != "false" && config_value != "nil"
202
- rescue Exception => e
203
- if ENV['UFO_DEBUG']
204
- puts "#{e.class} #{e.message}".color(:yellow)
205
- puts "WARN: Unable to parse for config.layering.show".color(:yellow)
206
- puts "Using default: config.layering.show = false"
207
- end
208
- false
189
+ def parsed_layering_show_for
190
+ parse.for("layering.show_for_commands", type: :array) || %w[build ship] # IE: ps exec logs are not shown
191
+ end
192
+ memoize :parsed_layering_show_for
193
+
194
+ def parsed_layering_show
195
+ ENV['UFO_LAYERS'] || parse.for("layering.show", type: :boolean)
196
+ end
197
+ private :parsed_layering_show
198
+
199
+ def parse
200
+ Parse.new
209
201
  end
210
- memoize :parse_for_layering_show
202
+ memoize :parse
211
203
 
212
204
  # Works similiar to Layering::Layer. Consider combining the logic and usin Layering::Layer
213
205
  #
@@ -75,7 +75,7 @@ module Ufo::Layering
75
75
  paths.each do |path|
76
76
  if ENV['UFO_LAYERS_ALL']
77
77
  logger.info " #{pretty_path(path)}"
78
- elsif Ufo.config.layering.show
78
+ elsif Ufo.config.show_layers?
79
79
  logger.info " #{pretty_path(path)}" if File.exist?(path)
80
80
  end
81
81
  end
data/lib/ufo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ufo
2
- VERSION = "6.2.2"
2
+ VERSION = "6.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.2
4
+ version: 6.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
@@ -594,6 +594,7 @@ files:
594
594
  - lib/ufo/config/callable_option.rb
595
595
  - lib/ufo/config/callable_option/concern.rb
596
596
  - lib/ufo/config/inits.rb
597
+ - lib/ufo/config/parse.rb
597
598
  - lib/ufo/core.rb
598
599
  - lib/ufo/docker/builder.rb
599
600
  - lib/ufo/docker/cleaner.rb