Class: Taeval::Hadolint::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/taeval/hadolint/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, output, reporter) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
12
# File 'lib/taeval/hadolint/runner.rb', line 8

def initialize(config, output, reporter)
  @config   = Config.new(config)
  @output   = output
  @reporter = reporter
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# 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