class Taeval::Hadolint::Runner

Public Class Methods

new(config, output, reporter) click to toggle source
# File lib/taeval/hadolint/runner.rb, line 8
def initialize(config, output, reporter)
  @config   = Config.new(config)
  @output   = output
  @reporter = reporter
end

Public Instance Methods

run() click to toggle source
# File lib/taeval/hadolint/runner.rb, line 14
def run
  solutions = Dir.glob("#{@config.solutions}/*")
  solutions.each do |repo|
    cmd = "docker run --rm -i -v #{@config.path}:/root/.config/hadolint.yaml hadolint/hadolint < #{repo}/docker/Dockerfile"
    stdout, stderr, status = Open3.capture3(cmd)
    @output.print "hadolint #{repo}/Dockerfile", stdout, stderr

    if 0 != status
      @reporter.add(repo: repo, runner: :hadolint, msg: "Status: #{status} Error: #{stderr}.") if !stderr.empty?
      @reporter.add(repo: repo, runner: :hadolint, msg: "Status: #{status} Message: #{stdout}.") if !stdout.empty? 
    end
  end
end