Sha256: cfbefc5dd6691a168db5d25670e82a3bc1f25e5a984b9ad3e726de1de0588e9e

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

require 'thor'

require_relative '../interface/berkshelf'
require_relative '../patch/thor-actions'

module Builderator
  module Tasks
    ##
    # Wrap Berkshelf commands
    ##
    class Berkshelf < Thor
      include Thor::Actions

      def self.exit_on_failure?
        true
      end

      desc 'configure', 'Write a Berksfile into the project workspace'
      def configure
        Interface.berkshelf.write
      end

      desc 'vendor', 'Vendor a cookbook release and its dependencies'
      def vendor
        invoke :configure, [], options
        empty_directory Interface.berkshelf.vendor

        command = "#{Interface.berkshelf.command} vendor #{Interface.berkshelf.vendor} "
        command << "-c #{Interface.berkshelf.berkshelf_config} "
        command << "-b #{Interface.berkshelf.source}"

        inside Interface.berkshelf.directory do
          remove_file Interface.berkshelf.lockfile
          run command
        end
      end

      desc 'upload', 'Upload the local cookbook source and its dependencies to the Chef server'
      def upload
        vendor

        command = "#{Interface.berkshelf.command} upload "
        command << "-c #{Interface.berkshelf.berkshelf_config} "
        command << "-b #{Interface.berkshelf.source}"

        inside Interface.berkshelf.directory do
          run command
        end
      end

      desc 'uncache', 'Delete the Berkshelf cache'
      def uncache
        remove_dir File.join(ENV['HOME'], '.berkshelf/cookbooks')
      end

      desc 'clean', 'Remove a local vendor directory'
      def clean
        remove_dir Interface.berkshelf.vendor
        remove_file Interface.berkshelf.source
        remove_file Interface.berkshelf.lockfile
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
builderator-1.1.0 lib/builderator/tasks/berkshelf.rb
builderator-1.0.4 lib/builderator/tasks/berkshelf.rb
builderator-1.0.3 lib/builderator/tasks/berkshelf.rb
builderator-1.0.2 lib/builderator/tasks/berkshelf.rb