Class: KnifeSpork::SporkRoleFromFile

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/spork-role-fromfile.rb

Instance Method Summary collapse

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/chef/knife/spork-role-fromfile.rb', line 14

def run
  self.class.send(:include, KnifeSpork::Runner)
  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)
      begin
        pre_role = load_role(@object_name.gsub(".json","").gsub(".rb",""))
      rescue Net::HTTPServerException => e
        pre_role = {}
      end
      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