Sha256: a93cf0afe3d13e3c10140b25d7c5154ac8ff027258a29e620447caa0198f7d3a
Contents?: true
Size: 1.61 KB
Versions: 2
Compression:
Stored size: 1.61 KB
Contents
require 'chef/knife' class Chef class Knife class SoloInit < Knife include FileUtils deps do require 'knife-solo/gitignore' end banner "knife solo init DIRECTORY" option :git, :long => '--no-git', :description => 'Do not generate .gitignore', :default => true option :librarian, :long => '--librarian', :description => 'Initialize Librarian' def run @base = @name_args.first validate! create_kitchen create_cupboards %w[nodes roles data_bags site-cookbooks cookbooks] librarian_init if config[:librarian] end def validate! unless @base show_usage ui.fatal "You must specify a directory. Use '.' to initialize the current one." exit 1 end end def create_cupboards(dirs) dirs.each do |dir| cupboard_dir = File.join(@base, dir) unless File.exist?(cupboard_dir) mkdir cupboard_dir touch File.join(cupboard_dir, '.gitkeep') end end end def create_kitchen mkdir @base unless @base == '.' end def librarian_init cheffile = File.join(@base, 'Cheffile') unless File.exist?(cheffile) File.open(cheffile, 'w') do |f| f.puts("site 'http://community.opscode.com/api/v1'") end end gitignore %w[/cookbooks/ /tmp/librarian/] end def gitignore(*entries) if config[:git] KnifeSolo::Gitignore.new(@base).add(*entries) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
knife-solo-0.3.0.pre2 | lib/chef/knife/solo_init.rb |
knife-solo-0.3.0.pre1 | lib/chef/knife/solo_init.rb |