Class: AllImages::App
- Inherits:
-
Object
- Object
- AllImages::App
- Includes:
- FileUtils, SearchUI, Term::ANSIColor
- Defined in:
- lib/all_images/app.rb
Overview
AllImages::App is the core application class that orchestrates Docker image execution workflows
This class provides the main interface for running scripts across multiple Docker images, handling configuration loading, command processing, and Docker container operations.
It supports various commands including listing available images, running all images, running specific images, and debugging interactive sessions.
The application manages Docker image building, tagging, and cleanup while providing environment variable handling and error reporting capabilities.
Instance Method Summary collapse
-
#initialize(args) ⇒ App
constructor
Initializes a new instance of the AllImages application.
-
#run ⇒ Integer
Executes the configured command across Docker images.
Constructor Details
#initialize(args) ⇒ App
Initializes a new instance of the AllImages application
Sets up the application with the provided command-line arguments, determines the initial command to execute, and prepares internal state for processing configuration and Docker image operations.
application
34 35 36 37 38 39 40 |
# File 'lib/all_images/app.rb', line 34 def initialize(args) @args = args.dup @config = load_config or return 23 @command = pick_command @commands = %w[ ls help run debug run_all ].sort @suffix = Tins::Token.new(alphabet: Tins::Token::BASE32_ALPHABET, bits: 32) end |
Instance Method Details
#run ⇒ Integer
Executes the configured command across Docker images
Processes the specified command and runs it against the configured Docker images. Depending on the command, this method may list available images, display help information, or execute scripts in containers. It handles both individual image execution and batch processing of all configured images.
across images, where 0 indicates success and non-zero values indicate failures
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/all_images/app.rb', line 52 def run result = 0 case @command when 'ls' puts images.map(&:first) when 'help' puts "Usage: #{File.basename($0)} #{@commands * ?|} [IMAGE]" else images.each do |image, script| case @command when 'run_all' result |= run_image(image, script) when 'run_selected' image == @selected and result |= run_image(image, script) when 'debug_selected' image == @selected and result |= run_image(image, script, interactive: true) end if @config['fail_fast'] && result != 0 return 1 end end end result end |