dip 8.0.0 → 8.1.0

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: 027ac4456743eaef5ed3d2a461b15e57fcc13739500ef04bdedfca37b4c6c266
4
- data.tar.gz: e5cdc4f2597241c242bc91f007ab35a2392feafbf924109f97f48ff330228997
3
+ metadata.gz: 0b6092ebf900ada263123eecb33ee04460d0d8c03421d7f77b99486b6a66941f
4
+ data.tar.gz: f2753b321d575b0417ca3153283d8181fdf78f9d75a393c0df74671b0343e8ab
5
5
  SHA512:
6
- metadata.gz: 59685a0ab3f5d1174d58048d021b8f4f12d494aaa09773e0b0cfd05d4a2d12975c594efc7597b67e054912f5e6d75fdbd293ac7ca5ba69ab06af858f93dac1c5
7
- data.tar.gz: 505a3e3657f17a0c01e1d785bfb23a86982ee42da7a8185ccf753de0116e7f18d082d66d11bac07031e43600c9397a74728de62e0a6d70191f9dbe939080f2da
6
+ metadata.gz: 4b8bd274d40759d1bcb770d9bc6318980d6de06ce6a2f8e6569b7605cdbe9e77b205480bbf7436ee415bad24176ee90928f450875c33aa6cb997f70f6ba4425b
7
+ data.tar.gz: dd228653949ce59936aa21b1e63c2f624c522c4fa050eba9f484180e87eccf3b06a44f173cdbbd682d1f6b1045540aaf6af33a194c6ba09ba7c6468031b1adbe
data/README.md CHANGED
@@ -238,6 +238,92 @@ services:
238
238
 
239
239
  The container will run using the same user ID as your host machine.
240
240
 
241
+ ### Modules
242
+
243
+ Modules are defined as array in `modules` section of dip.yml, modules are stored in `.dip` subdirectory of dip.yml directory.
244
+
245
+ The main purpose of modules is to improve maintainability for a group of projects.
246
+ Imagine having multiple gems which are managed with dip, each of them has the same commands, so to change one command in dip you need to update all gems individualy.
247
+
248
+ With `modules` you can define a group of modules for dip.
249
+
250
+ For example having setup as this:
251
+
252
+ ```yml
253
+ # ./dip.yml
254
+ modules:
255
+ - sasts
256
+ - rails
257
+
258
+ ...
259
+ ```
260
+
261
+ ```yml
262
+ # ./.dip/sasts.yml
263
+ interaction:
264
+ brakeman:
265
+ description: Check brakeman sast
266
+ command: docker run ...
267
+ ```
268
+
269
+ ```yml
270
+ # ./.dip/rails.yml
271
+ interaction:
272
+ annotate:
273
+ description: Run annotate command
274
+ service: backend
275
+ command: bundle exec annotate
276
+ ```
277
+
278
+ Will be expanded to:
279
+
280
+ ```yml
281
+ # resultant configuration
282
+ interaction:
283
+ brakeman:
284
+ description: Check brakeman sast
285
+ command: docker run ...
286
+ annotate:
287
+ description: Run annotate command
288
+ service: backend
289
+ command: bundle exec annotate
290
+ ```
291
+
292
+ Imagine `.dip` to be a submodule so it can be managed only in one place.
293
+
294
+ If you want to override module command, you can redefine it in dip.yml
295
+
296
+ ```yml
297
+ # ./dip.yml
298
+ modules:
299
+ - sasts
300
+
301
+ interaction:
302
+ brakeman:
303
+ description: Check brakeman sast
304
+ command: docker run another-image ...
305
+ ```
306
+
307
+ ```yml
308
+ # ./.dip/sasts.yml
309
+ interaction:
310
+ brakeman:
311
+ description: Check brakeman sast
312
+ command: docker run some-image ...
313
+ ```
314
+
315
+ Will be expanded to:
316
+
317
+ ```yml
318
+ # resultant configuration
319
+ interaction:
320
+ brakeman:
321
+ description: Check brakeman sast
322
+ command: docker run another-image ...
323
+ ```
324
+
325
+ Nested modules are not supported.
326
+
241
327
  ### dip run
242
328
 
243
329
  Run commands defined within the `interaction` section of dip.yml
data/lib/dip/config.rb CHANGED
@@ -43,6 +43,10 @@ module Dip
43
43
  file_path&.exist?
44
44
  end
45
45
 
46
+ def modules_dir
47
+ file_path.dirname / ".dip"
48
+ end
49
+
46
50
  private
47
51
 
48
52
  attr_reader :override
@@ -90,6 +94,10 @@ module Dip
90
94
  finder.file_path
91
95
  end
92
96
 
97
+ def module_file(filename)
98
+ finder.modules_dir / "#{filename}.yml"
99
+ end
100
+
93
101
  def exist?
94
102
  finder.exist?
95
103
  end
@@ -125,10 +133,28 @@ module Dip
125
133
  "Please upgrade your dip!"
126
134
  end
127
135
 
136
+ base_config = {}
137
+
138
+ if (modules = config[:modules])
139
+ raise Dip::Error, "Modules should be specified as array" unless modules.is_a?(Array)
140
+
141
+ modules.each do |m|
142
+ file = module_file(m)
143
+ raise Dip::Error, "Could not find module `#{m}`" unless file.exist?
144
+
145
+ module_config = self.class.load_yaml(file)
146
+ raise Dip::Error, "Nested modules are not supported" if module_config[:modules]
147
+
148
+ base_config.deep_merge!(module_config)
149
+ end
150
+ end
151
+
152
+ base_config.deep_merge!(config)
153
+
128
154
  override_finder = ConfigFinder.new(work_dir, override: true)
129
- config.deep_merge!(self.class.load_yaml(override_finder.file_path)) if override_finder.exist?
155
+ base_config.deep_merge!(self.class.load_yaml(override_finder.file_path)) if override_finder.exist?
130
156
 
131
- @config = CONFIG_DEFAULTS.merge(config)
157
+ @config = CONFIG_DEFAULTS.merge(base_config)
132
158
  end
133
159
 
134
160
  def config_missing_error(config_key)
data/lib/dip/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dip
4
- VERSION = "8.0.0"
4
+ VERSION = "8.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dip
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bibendi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-29 00:00:00.000000000 Z
11
+ date: 2024-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor