all_images 0.4.1 → 0.6.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: f1e9a30544cd8da8ff78b08273145dc8c43f30ee61aee97e035444c7eca98b1d
4
- data.tar.gz: faba9ac223de4a106c77fd1dc943ab4933cde3b4a052c7411390e1b7335780d1
3
+ metadata.gz: cbf39eaf44bd3eef5cba7b22e942621717fd838cde984764c684ba2a7f8842f7
4
+ data.tar.gz: f8c257c224e80f2ae251ec8e05b8869d3348ae0408d4a0dadd789ef74ce182c3
5
5
  SHA512:
6
- metadata.gz: 3a95b63a886db349cf62083638f4686a4adefa2e013da197b5ae016cac16fc3f967a35b679a47ba2a86bbecceb85181c7fd85c1411b442891945f2d91ecbe8d8
7
- data.tar.gz: cfb5b0bf0a330623bfb37579f5606da2b2099511f31c7d28263dd249388856418d984d86f00889e1db2825b752ff30a74bf9de1dc90110b886220181ec92d458
6
+ metadata.gz: 39b423c850d91d8a7261c2b4677ba9935486797e0dd08ab2cca2ed6e9af78c162296cd89daa7e7ce71dd23999fed098f4158edc57d34222d99ef38db495bca10
7
+ data.tar.gz: 4a2d1611e0452b452963c099aed19163af335290015b25b72757db37803827a304d77282c3cc0919cfc0b24855703d8fb727cd74dd4c11664edcee7b3bbbac08
data/CHANGES.md ADDED
@@ -0,0 +1,96 @@
1
+ # Changes
2
+
3
+ ## 2024-10-14 v0.6.0
4
+
5
+ ### Significant Changes
6
+ * **Add support for environment variables to all_images**
7
+ + Require `'tins/xt/full'` and add new method `env` to set environment variables.
8
+ + Modified the `sh` method to use environment variables from the `env` method.
9
+ + Modified the `run_image` method to include environment variables in the Docker command.
10
+ * Update rake task to use spec instead of test
11
+ * Added `[IMAGE]` as an optional argument in the Usage message.
12
+
13
+ ### Other Changes
14
+ * Reformat CHANGES.md
15
+ * Add error reporting to `sh`
16
+ + Added require `'shellwords'`
17
+
18
+ #### Environment Variables
19
+ * Added `env` section to `.all_images.yml`
20
+ * Defined `FOO=bar` and `USER` environment variables
21
+
22
+ ## 2024-09-01 v0.5.0
23
+
24
+ * **Update image processing for parallel execution**:
25
+ + Added random suffix to image names to prevent conflicts between concurrent processes.
26
+ * Added `CHANGES.md` file
27
+
28
+ ## 2024-08-08 v0.4.1
29
+
30
+ * **License File Added**: A license file was added in written form.
31
+
32
+ ## 2024-02-07 v0.4.0
33
+
34
+ * Added support for outputting colors in addition to existing functionality.
35
+
36
+ ## 2023-08-17 v0.3.0
37
+
38
+ * **New Feature**: Allow running scripts within a Docker container, enabling
39
+ more flexible and isolated testing environments.
40
+
41
+ ## 2023-08-17 v0.2.5
42
+
43
+ * Corrected actual checking logic.
44
+
45
+ ## 2023-08-17 v0.2.4
46
+
47
+ * **Improved Error Handling**:
48
+ * Added checks to prevent premature failure in critical sections of the code.
49
+
50
+ ## 2023-06-01 v0.2.3
51
+
52
+ * **New Features**
53
+ + Added support for Ruby 3.2
54
+ * **Changes**
55
+ + Bumped build version
56
+ + Removed support for Ruby 2.5
57
+ * **Bug Fixes**
58
+ + Repaired `fail_fast` mode
59
+
60
+ ## 2023-04-19 v0.2.2
61
+
62
+ * **New Version Features**
63
+ + Progress into the future of ruby development
64
+ + Progress into the future
65
+ * **Significant Changes**
66
+ + Removed development dependency (again)
67
+
68
+ ## 2022-11-17 v0.2.1
69
+
70
+ * Added a new `help` command.
71
+
72
+ ## 2022-11-17 v0.2.0
73
+
74
+ * **New Features**
75
+ + Added commands to run and debug single images
76
+ + Added a debug debugger feature
77
+
78
+ ## 2022-11-17 v0.1.0
79
+
80
+ * Added `fail_fast` configuration option.
81
+
82
+ ## 2022-07-11 v0.0.2
83
+
84
+ * **Security Fix**: Local config files are now properly sanitized to prevent potential security vulnerabilities.
85
+
86
+ ## 2022-05-16 v0.0.1
87
+
88
+ * **Bug Fix**: Fixed bug in `required_ruby_version` functionality, which was causing issues with certain RubyGems releases.
89
+
90
+ ### Significant Changes
91
+ * Removed buggy implementation of `required_ruby_version`
92
+ * Improved stability and compatibility with RubyGems releases
93
+
94
+ ## 2022-05-15 v0.0.0
95
+
96
+ * Start
data/all_images.gemspec CHANGED
@@ -1,29 +1,29 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: all_images 0.4.1 ruby lib
2
+ # stub: all_images 0.6.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "all_images".freeze
6
- s.version = "0.4.1".freeze
6
+ s.version = "0.6.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2024-08-08"
11
+ s.date = "2024-10-14"
12
12
  s.description = "A script that runs a script in all of the configured docker images".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["all_images".freeze]
15
15
  s.extra_rdoc_files = ["README.md".freeze, "lib/all_images.rb".freeze, "lib/all_images/app.rb".freeze, "lib/all_images/config.rb".freeze, "lib/all_images/version.rb".freeze]
16
- s.files = [".utilsrc".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "all_images.gemspec".freeze, "bin/all_images".freeze, "lib/all_images.rb".freeze, "lib/all_images/app.rb".freeze, "lib/all_images/config.rb".freeze, "lib/all_images/version.rb".freeze, "spec/app_spec.rb".freeze, "spec/spec_helper.rb".freeze]
16
+ s.files = [".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "all_images.gemspec".freeze, "bin/all_images".freeze, "lib/all_images.rb".freeze, "lib/all_images/app.rb".freeze, "lib/all_images/config.rb".freeze, "lib/all_images/version.rb".freeze, "spec/app_spec.rb".freeze, "spec/spec_helper.rb".freeze]
17
17
  s.homepage = "https://github.com/flori/all_images".freeze
18
18
  s.licenses = ["MIT".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "AllImages -- Runs a script in all of the docker images".freeze, "--main".freeze, "README.md".freeze]
20
- s.rubygems_version = "3.5.16".freeze
20
+ s.rubygems_version = "3.5.18".freeze
21
21
  s.summary = "Runs a script in all of the docker images".freeze
22
22
  s.test_files = ["spec/app_spec.rb".freeze, "spec/spec_helper.rb".freeze]
23
23
 
24
24
  s.specification_version = 4
25
25
 
26
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.16.1".freeze])
26
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.19".freeze])
27
27
  s.add_development_dependency(%q<rake>.freeze, [">= 0".freeze])
28
28
  s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
29
29
  s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
@@ -1,28 +1,29 @@
1
1
  require 'term/ansicolor'
2
2
  require 'tmpdir'
3
3
  require 'fileutils'
4
+ require 'tins'
5
+ require 'tins/xt/full'
6
+ require 'shellwords'
4
7
 
5
8
  class AllImages::App
6
9
  include Term::ANSIColor
7
10
  include FileUtils
8
11
 
9
- alias sh system
10
-
11
12
  def initialize(args)
12
13
  @args = args.dup
13
14
  @command = pick_command
14
15
  @commands = %w[ ls help run debug run_all ].sort
16
+ @suffix = Tins::Token.new(alphabet: Tins::Token::BASE32_ALPHABET, bits: 32)
15
17
  end
16
18
 
17
19
  def run
18
20
  @config = load_config or return 23
19
-
20
21
  result = 0
21
22
  case @command
22
23
  when 'ls'
23
24
  puts Array(@config['images']).map(&:first)
24
25
  when 'help'
25
- puts "Usage: #{File.basename($0)} #{@commands * ?|} IMAGE"
26
+ puts "Usage: #{File.basename($0)} #{@commands * ?|} [IMAGE]"
26
27
  else
27
28
  Array(@config['images']).each do |image, script|
28
29
  case @command
@@ -43,16 +44,45 @@ class AllImages::App
43
44
 
44
45
  private
45
46
 
47
+ def env
48
+ vars = @config.fetch('env', [])
49
+ vars << 'TERM' if ENV.key?('TERM')
50
+ vars.each_with_object({}) { |v, h|
51
+ name, value = v.split(?=, 2)
52
+ if value
53
+ h[name] = value
54
+ else
55
+ h[name] = ENV[name]
56
+ end
57
+ }
58
+ end
59
+
60
+ def sh(*a)
61
+ if $DEBUG
62
+ STDERR.puts "Executing #{a.inspect}."
63
+ end
64
+ system(*a)
65
+ if $?.success?
66
+ true
67
+ else
68
+ raise "Command #{Shellwords.join(a).inspect} failed with: #{$?.exitstatus}"
69
+ end
70
+ end
71
+
72
+ def name
73
+ [ 'all_images', @suffix ] * ?-
74
+ end
75
+
46
76
  def run_image(image, script, interactive: false)
47
77
  dockerfile = @config.fetch('dockerfile').to_s
48
- tag = provide_image image, dockerfile, script
49
- term = ENV.key?('TERM') ? %{ -e TERM=#{ENV['TERM'].inspect} } : ' '
78
+ tag = provide_image image, dockerfile, script
79
+ envs = env.full? { |e| +' ' << e.map { |n, v| '-e %s=%s' % [ n, v.inspect ] } * ' ' }
50
80
  if interactive
51
81
  puts "You can run /script interactively now."
52
- sh "docker run --name all_images -it #{term}-v `pwd`:/work '#{tag}' sh"
82
+ sh "docker run --name #{name} -it#{envs} -v `pwd`:/work '#{tag}' sh"
53
83
  return 0
54
84
  else
55
- if sh "docker run --name all_images -it #{term}-v `pwd`:/work '#{tag}' sh -c /script"
85
+ if sh "docker run --name #{name} -it#{envs} -v `pwd`:/work '#{tag}' sh -c /script"
56
86
  puts green('SUCCESS')
57
87
  return 0
58
88
  else
@@ -61,7 +91,7 @@ class AllImages::App
61
91
  end
62
92
  end
63
93
  ensure
64
- sh 'docker rm -f all_images >/dev/null'
94
+ sh "docker rm -f #{name} >/dev/null"
65
95
  end
66
96
 
67
97
  def pick_command
@@ -1,6 +1,6 @@
1
1
  module AllImages
2
2
  # AllImages version
3
- VERSION = '0.4.1'
3
+ VERSION = '0.6.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: all_images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-08 00:00:00.000000000 Z
11
+ date: 2024-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.16.1
19
+ version: '1.19'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.16.1
26
+ version: '1.19'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -121,6 +121,7 @@ extra_rdoc_files:
121
121
  - lib/all_images/version.rb
122
122
  files:
123
123
  - ".utilsrc"
124
+ - CHANGES.md
124
125
  - Gemfile
125
126
  - LICENSE
126
127
  - README.md
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  - !ruby/object:Gem::Version
157
158
  version: '0'
158
159
  requirements: []
159
- rubygems_version: 3.5.16
160
+ rubygems_version: 3.5.18
160
161
  signing_key:
161
162
  specification_version: 4
162
163
  summary: Runs a script in all of the docker images