From 289b569de45257d0a046870185cfcafdc3f54f18 Mon Sep 17 00:00:00 2001 From: niharikab Date: Tue, 6 Apr 2021 17:27:36 +0530 Subject: [PATCH] Add Plan Status() to ifc.plan interface This commit adds plan Status() method to ifc.plan interface. Relates-To: #412 Change-Id: I4857eec9ea125902e305af64fbb336ff6de4faa8 --- pkg/phase/client.go | 14 ++++++++++++++ pkg/phase/ifc/phase.go | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/pkg/phase/client.go b/pkg/phase/client.go index ad4e7b64d..fd256b681 100644 --- a/pkg/phase/client.go +++ b/pkg/phase/client.go @@ -246,6 +246,20 @@ func (p *plan) Run(ro ifc.RunOptions) error { return nil } +// Status returns the status of phases in a given plan +func (p *plan) Status(options ifc.StatusOptions) (ifc.PlanStatus, error) { + for _, step := range p.apiObj.Phases { + phase, err := p.phaseClient.PhaseByID(ifc.ID{Name: step.Name}) + if err != nil { + return ifc.PlanStatus{}, err + } + if _, err = phase.Status(); err != nil { + return ifc.PlanStatus{}, err + } + } + return ifc.PlanStatus{}, nil +} + var _ ifc.Client = &client{} type client struct { diff --git a/pkg/phase/ifc/phase.go b/pkg/phase/ifc/phase.go index 618689292..827215fdc 100644 --- a/pkg/phase/ifc/phase.go +++ b/pkg/phase/ifc/phase.go @@ -41,8 +41,15 @@ type PhaseStatus struct { type Plan interface { Validate() error Run(RunOptions) error + Status(StatusOptions) (PlanStatus, error) } +// StatusOptions is used to define status options +type StatusOptions struct{} + +// PlanStatus is a struct which defines status of PLAN +type PlanStatus struct{} + // ID uniquely identifies the phase type ID struct { Name string