package console import ( "context" "sort" "github.com/carlosframework/platform/internal/hostclaim" "github.com/carlosframework/platform/internal/hostops" ) type claimPendingView struct { Host string `json:"host"` Name string `json:"name,omitempty"` Incarnation string `json:"incarnation"` OperationID string `json:"operation_id"` Phase string `json:"phase"` } func (s *Server) claimPendingViews(ctx context.Context, account, app, family string) ([]claimPendingView, error) { out := []claimPendingView{} hosts, err := hostops.ListClaims(ctx, s.cfg.Releases) if err != nil { return nil, err } for _, host := range hosts { obs, err := hostclaim.Read(ctx, s.cfg.Releases, host) if err != nil { return nil, err } if obs.Absent || obs.Claim.Holder == nil { continue } h, op := obs.Claim.Holder, obs.Claim.Op if h.Account != account || h.App != app || h.Family != family || op.ID == "" || op.Kind == hostclaim.KindServing { continue } phase := op.Phase if phase == "" { phase = op.Kind } out = append(out, claimPendingView{Host: host, Name: h.Name, Incarnation: h.Incarnation, OperationID: op.ID, Phase: phase}) } sort.Slice(out, func(i, j int) bool { return out[i].Host < out[j].Host }) return out, nil }