Sha256: e53358442d1476dfcc4d4e97ca57a03887eaa0fc836d1db6ee40b3a0fdac193e

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require 'deploy_rubygem/inspec'

# DeployRubygem - deploy a gem using rake
# Containing a class
module DeployRubygem
  # Using Kitchen to deploy and manage Kitchen
  class Kitchen
    attr_reader :kitchen_name, :cookbook

    def initialize(kitchen_name, cookbook)
      @kitchen_name = kitchen_name
      @cookbook = cookbook
    end

    def check_file
      ::File.join("#{kitchen_name}_check.log")
    end

    def converge
      system("kitchen converge #{kitchen_name}")
    end

    def destroy
      system("kitchen destroy #{kitchen_name}")
    end

    def ip
      switch_to_cookbook
      system("kitchen exec #{kitchen_name} -c 'hostname -I'")
    end

    def verify(showing: true)
      cookbook.switch_to_cookbook
      if showing
        system("kitchen verify #{kitchen_name}")
      else
        system("kitchen verify #{kitchen_name} > #{check_file}")
      end
    end

    def target
      verify(showing: false)
      system("grep -n Target #{check_file}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deploy_rubygem-0.60.4 lib/deploy_rubygem/kitchen.rb