Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed Jul 29, 2024
1 parent 06ace76 commit 4a486e2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions stack_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ type stackPlans struct {

var _ StackPlans = &stackPlans{}

// StackPlanStatusTimestamps are the timestamps of the status changes for a stack
type StackPlanStatusTimestamps struct {
CreatedAt time.Time `jsonapi:"attr,created-at,rfc3339"`
RunningAt time.Time `jsonapi:"attr,running-at,rfc3339"`
PausedAt time.Time `jsonapi:"attr,paused-at,rfc3339"`
FinishedAt time.Time `jsonapi:"attr,finished-at,rfc3339"`
}

// PlanChanges is the summary of the planned changes
type PlanChanges struct {
Add int `jsonapi:"attr,add"`
Total int `jsonapi:"attr,total"`
Expand Down Expand Up @@ -108,12 +110,8 @@ type JSONChangeDesc struct {
Outputs map[string]JSONOutput `json:"outputs"`
}

// JSONComponent represents a change description of a single component in a plan.
type JSONComponent struct {
// FIXME: UI seems to want a "name" that is something more compact
// than the full address, but not sure exactly what that ought to
// be once we consider the possibility of embedded stacks and
// components with for_each set. For now we just return the
// full address pending further discussion.
Address string `json:"address"`
ComponentAddress string `json:"component_address"`
InstanceCorrelator string `json:"instance_correlator"`
Expand All @@ -122,8 +120,10 @@ type JSONComponent struct {
Complete bool `json:"complete"`
}

// ChangeAction are the actions a change can have: no-op, create, read, update, delte, forget.
type ChangeAction string

// JSONResourceInstance is the change description of a single resource instance in a plan.
type JSONResourceInstance struct {
ComponentInstanceCorrelator string `json:"component_instance_correlator"`
ComponentInstanceAddress string `json:"component_instance_address"`
Expand All @@ -137,24 +137,27 @@ type JSONResourceInstance struct {
Change Change `json:"change"`
}

// JSONResourceInstanceDeferral is the change description of a single resource instance that is deferred.
type JSONResourceInstanceDeferral struct {
ResourceInstance JSONResourceInstance `json:"resource_instance"`
Deferred JSONDeferred `json:"deferred"`
}

// JSONDeferred contains the reason why a resource instance is deferred: instance_count_unknown, resource_config_unknown, provider_config_unknown, provider_config_unknown, or deferred_prereq.
type JSONDeferred struct {
Reason string `json:"reason"`
}

// JSONOutput is the value of a single output in a plan.
type JSONOutput struct {
Change json.RawMessage `json:"change"`
}

// Change represents the change of a resource instance in a plan.
type Change struct {
Actions []ChangeAction `json:"actions"`
After json.RawMessage `json:"after"`
Before json.RawMessage `json:"before"`
// TODO: Add after_sensitive, after_unknown, before_sensitive
}

func (s stackPlans) Read(ctx context.Context, stackPlanID string) (*StackPlan, error) {
Expand Down

0 comments on commit 4a486e2

Please sign in to comment.