github.com/replicatedhq/ship@v0.55.0/pkg/lifecycle/daemon/routes_navcycle_getcycle.go (about)

     1  package daemon
     2  
     3  import (
     4  	"github.com/gin-gonic/gin"
     5  	"github.com/replicatedhq/ship/pkg/lifecycle/daemon/daemontypes"
     6  )
     7  
     8  type lifeycleStep struct {
     9  	ID          string                `json:"id"`
    10  	Description string                `json:"description"`
    11  	Phase       string                `json:"phase"`
    12  	Progress    *daemontypes.Progress `json:"progress,omitempty"`
    13  }
    14  
    15  func (d *NavcycleRoutes) getNavcycle(c *gin.Context) {
    16  	lifecycleIDs := make([]lifeycleStep, 0)
    17  	for _, step := range d.Release.Spec.Lifecycle.V1 {
    18  		stepResponse := lifeycleStep{
    19  			ID:          step.Shared().ID,
    20  			Description: step.Shared().Description,
    21  			Phase:       step.ShortName(),
    22  		}
    23  
    24  		if progress, ok := d.StepProgress.Load(step.Shared().ID); ok {
    25  			stepResponse.Progress = &progress
    26  		}
    27  
    28  		lifecycleIDs = append(lifecycleIDs, stepResponse)
    29  	}
    30  	c.JSON(200, lifecycleIDs)
    31  }