Class: Microsandbox::ModificationPlan

Inherits:
Object
  • Object
show all
Defined in:
lib/microsandbox/modification.rb

Overview

The plan produced by Sandbox#modify / SandboxHandle#modify: the classified set of changes a modification requested, and (for a non-dry-run apply) whether they were applied plus any live-resize convergence outcomes. Mirrors the official SDKs' SandboxModificationPlan.

The nested collections (#changes, #conflicts, #warnings, #resize_status) are frozen Arrays of frozen, symbol-keyed Hashes carrying the canonical snake_case fields verbatim (e.g. a config change is { kind: "config", field:, change:, before:, after:, disposition:, reason: }; a secret change adds name:, before_ref:, after_ref:, allow_hosts:). Enum values stay as the runtime's strings (e.g. a disposition of "next start", a state of "guest-refused").

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ModificationPlan

Returns a new instance of ModificationPlan.



77
78
79
80
81
82
83
84
85
86
# File 'lib/microsandbox/modification.rb', line 77

def initialize(data)
  @sandbox = data["sandbox"]
  @status = data["status"]
  @applied = data["applied"]
  @policy = data["policy"]&.to_sym
  @changes = freeze_items(data["changes"])
  @conflicts = freeze_items(data["conflicts"])
  @warnings = freeze_items(data["warnings"])
  @resize_status = freeze_items(data["resize_status"])
end

Instance Attribute Details

#changesArray<Hash> (readonly)

Returns the planned changes (config and secret).

Returns:

  • (Array<Hash>)

    the planned changes (config and secret)



69
70
71
# File 'lib/microsandbox/modification.rb', line 69

def changes
  @changes
end

#conflictsArray<Hash> (readonly)

Returns conflicts that must be resolved before applying.

Returns:

  • (Array<Hash>)

    conflicts that must be resolved before applying



71
72
73
# File 'lib/microsandbox/modification.rb', line 71

def conflicts
  @conflicts
end

#policySymbol (readonly)

Returns :no_restart, :next_start, or :restart.

Returns:

  • (Symbol)

    :no_restart, :next_start, or :restart



67
68
69
# File 'lib/microsandbox/modification.rb', line 67

def policy
  @policy
end

#resize_statusArray<Hash> (readonly)

Returns live resource-resize outcomes (populated by an apply).

Returns:

  • (Array<Hash>)

    live resource-resize outcomes (populated by an apply)



75
76
77
# File 'lib/microsandbox/modification.rb', line 75

def resize_status
  @resize_status
end

#sandboxString (readonly)

Returns the sandbox the plan applies to.

Returns:

  • (String)

    the sandbox the plan applies to



63
64
65
# File 'lib/microsandbox/modification.rb', line 63

def sandbox
  @sandbox
end

#statusString (readonly)

Returns the sandbox status used to classify the changes.

Returns:

  • (String)

    the sandbox status used to classify the changes



65
66
67
# File 'lib/microsandbox/modification.rb', line 65

def status
  @status
end

#warningsArray<Hash> (readonly)

Returns non-fatal warnings about the patch.

Returns:

  • (Array<Hash>)

    non-fatal warnings about the patch



73
74
75
# File 'lib/microsandbox/modification.rb', line 73

def warnings
  @warnings
end

Instance Method Details

#applied?Boolean

Returns whether the changes were applied (false for a dry run).

Returns:

  • (Boolean)

    whether the changes were applied (false for a dry run)



89
90
91
# File 'lib/microsandbox/modification.rb', line 89

def applied?
  @applied
end

#inspectObject



93
94
95
96
97
# File 'lib/microsandbox/modification.rb', line 93

def inspect
  "#<Microsandbox::ModificationPlan sandbox=#{@sandbox.inspect} applied=#{@applied} " \
    "policy=#{@policy} changes=#{@changes.size} conflicts=#{@conflicts.size} " \
    "warnings=#{@warnings.size}>"
end