summaryrefslogtreecommitdiff
path: root/lib/chef/provider/resource_update.rb
blob: 8d4b8db5b6eae96bd4ecf1669ef67369acd8f6c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

class Chef
  class Provider

    # {
    #    "run_id" : "1000",
    #    "resource" : {
    #         "type" : "file",
    #         "name" : "/etc/passwd",
    #         "start_time" : "2012-01-09T08:15:30-05:00",
    #         "end_time" : "2012-01-09T08:15:30-05:00",
    #         "status" : "modified",
    #         "initial_state" : "exists",
    #         "final_state" : "modified",
    #         "before" : {
    #              "group" : "root",
    #              "owner" : "root",
    #              "checksum" : "xyz"
    #         },
    #         "after" : {
    #              "group" : "root",
    #              "owner" : "root",
    #              "checksum" : "abc"
    #         },
    #         "delta" : "escaped delta goes here"
    #    },
    #    "event_data" : ""
    # }

    class ResourceUpdate

      attr_accessor :type, :name, :duration, :status, :initial_state, :final_state, :initial_properties, :final_properties, :event_data

       # ms

       # e.g., a diff.

      def initial_state_from_resource(resource)
        @initial_properties = resource.to_hash
      end

      def updated_state_from_resource(resource)
        @final_properties = resource.to_hash
      end

    end
  end
end