Sha256: a03e34b05382e60828c7e7f3b41f34517464d093269768ba2b3a7a3298918a02

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'chef/knife'
require 'knife-spork/runner'
require 'json'

module KnifeSpork
  class SporkRoleFromFile < Chef::Knife
    include KnifeSpork::Runner

    deps do
      require 'chef/knife/role_from_file'
    end

    banner 'knife spork role from file FILENAME (options)'

    def run
      self.config = Chef::Config.merge!(config)

      if @name_args.empty?
        show_usage
        ui.error("You must specify a role name")
        exit 1
      end

      @name_args.each do |arg|
          @object_name = arg.split("/").last
          run_plugins(:before_rolefromfile)
          pre_role = load_role(@object_name.gsub(".json","").gsub(".rb",""))
          role_from_file
          post_role = load_role(@object_name.gsub(".json","").gsub(".rb",""))
          @object_difference = json_diff(pre_role,post_role).to_s
          run_plugins(:after_rolefromfile)
      end
    end

    private
    def role_from_file
      rff = Chef::Knife::RoleFromFile.new
      rff.name_args = @name_args
      rff.run
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
knife-spork-berks-1.3.2 lib/chef/knife/spork-role-fromfile.rb
knife-spork-1.3.2 lib/chef/knife/spork-role-fromfile.rb