class SousVide::TrackedResource

It is a very simple data structure SousVide uses to capture information about resource execution.

@see www.rubydoc.info/gems/chef/Chef/Resource

Attributes

action[RW]

Action executed on this resource.

before_notifications[RW]

Number of before notifications attached to this resource.

chef_resource_handle[RW]

Chef API resource. It is used for comparsion only. @api private

completed_at[RW]
cookbook_name[RW]
cookbook_recipe[RW]
delayed_notifications[RW]

Number of delayed notifications attached to this resource.

duration_ms[RW]
error_output[RW]

Last error output if available. This can be populated when resource failed and when resource succeed after a retry.

error_source[RW]

Resource definition that triggered the error.

execution_order[RW]

Resource execution order. Takes into account notifications and does not reflect resource. order on the run list.

execution_phase[RW]

SousVide run-phase when this resource was executed.

guard_description[RW]
immediate_notifications[RW]

Number of immediate notifications attached to this resource.

name[RW]
notification_type[RW]
notifying_resource[RW]

Resource that triggered this execution. Delayed notifications do not have this.

retries[RW]

Number of retries.

source_line[RW]
started_at[RW]
status[RW]

Result of the action, ie. “updated”, “skipped”, …

type[RW]

Public Class Methods

new(name:, action:, type:) click to toggle source
# File lib/sous_vide/tracked_resource.rb, line 67
def initialize(name:, action:, type:)
  @name = name
  @action = action
  @type = type

  @status = "unprocessed"
  @duration_ms = nil
  @guard_description = nil

  @retries = 0
  @error_output = nil
  @error_source = nil
end

Public Instance Methods

to_h() click to toggle source

Serializes the resource to hash @return [Hash]

# File lib/sous_vide/tracked_resource.rb, line 89
def to_h
  {
    chef_resource: "#{@type}[#{@name}]##{@action}",
    chef_resource_name: @name,
    chef_resource_type: @type,
    chef_resource_cookbook: @cookbook_name,
    chef_resource_recipe: @cookbook_recipe,
    chef_resource_action: @action,
    chef_resource_guard: @guard_description,
    chef_resource_duration_ms: @duration_ms,
    chef_resource_error_output: @error_output,
    chef_resource_error_source: @error_source,
    chef_resource_retries: @retries,
    chef_resource_notified_by: @notifying_resource,
    chef_resource_notified_via: @notification_type,
    chef_resource_before_notifications: @before_notifications,
    chef_resource_immediate_notifications: @immediate_notifications,
    chef_resource_delayed_notifications: @delayed_notifications,
    chef_resource_order: @execution_order,
    chef_resource_execution_phase: @execution_phase,
    chef_resource_started_at: @started_at,
    chef_resource_completed_at: @completed_at,
    chef_resource_status: @status
  }
end
to_s() click to toggle source

String and human friendly represtnation of the resource @return [String]

# File lib/sous_vide/tracked_resource.rb, line 83
def to_s
  "#{@type}[#{@name}]##{@action}"
end