Sha256: 709f6e9a071e4d610f5a471061cf48252a39f1976f4ce9f6d3eea226474dc563
Contents?: true
Size: 1.43 KB
Versions: 4
Compression:
Stored size: 1.43 KB
Contents
require 'fileutils' module Bourdain module Checks class ChefCheck < Check usage :check, <<-END Check the underlying Kitchen chef END def initialize cookbook_config super [] return unless require_chef! check_chef_repo! install_knife_plugins! end private def check_chef_repo! # Check if we have an up-to-date copy of the Kitchen if youre_dirty? '.' log.warn "Your Kitchen is dirty." elsif youre_ahead? '.' log.warn "Your Kitchen is ahead of the remote." elsif youre_behind? '.' log.error "Looks like your Kitchen is behind the remote." error! else log.info "Your Kitchen looks up-to-date." end end def install_knife_plugins! plugin_glob = File.join \ gem_path('templates', 'chef'), 'knife_plugin_*.rb' plugin_dir = File.join \ ENV['HOME'], '.chef', 'plugins', 'knife' Dir[plugin_glob].each do |template_path| plugin = File.basename template_path plugin =~ /knife_plugin_(.*?).rb/ plugin_name = $1.sub('_', ' ') FileUtils.mkdir_p plugin_dir plugin_path = File.join plugin_dir, plugin apply_template plugin_path, template: [ 'chef', plugin ] log.info "Installed 'knife #{plugin_name}' plugin" end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems