Sha256: 9ab7ebb36547ccc0a22d6369719a4dd06e7eeadc7672994032fdf6eda150f25b

Contents?: true

Size: 1.11 KB

Versions: 20

Compression:

Stored size: 1.11 KB

Contents

require "cc/analyzer"

module CC
  module CLI
    module Engines
      class Install < EngineCommand
        ImagePullFailure = Class.new(StandardError)

        def run
          require_codeclimate_yml

          say "Pulling docker images."
          pull_docker_images
        end

        private

        def pull_docker_images
          engine_names.each do |name|
            if engine_exists?(name)
              image = engine_image(name)
              pull_engine_image(image)
            else
              warn("unknown engine name: #{name}")
            end
          end
        end

        def engine_names
          @engine_names ||= parsed_yaml.engine_names
        end

        def engine_exists?(engine_name)
          engines_registry_list.keys.include?(engine_name)
        end

        def engine_image(engine_name)
          engines_registry_list[engine_name]["image"]
        end

        def pull_engine_image(engine_image)
          if !system("docker pull #{engine_image}")
            raise ImagePullFailure, "unable to pull image #{engine_image}"
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
codeclimate-0.2.4 lib/cc/cli/engines/install.rb
codeclimate-0.2.2 lib/cc/cli/engines/install.rb
codeclimate-0.2.1 lib/cc/cli/engines/install.rb
codeclimate-0.2 lib/cc/cli/engines/install.rb
codeclimate-0.1.5 lib/cc/cli/engines/install.rb
codeclimate-0.1.4 lib/cc/cli/engines/install.rb
codeclimate-0.1.3 lib/cc/cli/engines/install.rb
codeclimate-0.1.2 lib/cc/cli/engines/install.rb
codeclimate-0.1.0 lib/cc/cli/engines/install.rb
codeclimate-0.0.25 lib/cc/cli/engines/install.rb
codeclimate-0.0.24 lib/cc/cli/engines/install.rb
codeclimate-0.0.23 lib/cc/cli/engines/install.rb
codeclimate-0.0.22 lib/cc/cli/engines/install.rb
codeclimate-0.0.21 lib/cc/cli/engines/install.rb
codeclimate-0.0.18 lib/cc/cli/engines/install.rb
codeclimate-0.0.17 lib/cc/cli/engines/install.rb
codeclimate-0.0.16 lib/cc/cli/engines/install.rb
codeclimate-0.0.15 lib/cc/cli/engines/install.rb
codeclimate-0.0.14 lib/cc/cli/engines/install.rb
codeclimate-0.0.13 lib/cc/cli/engines/install.rb