44 "context"
55 "fmt"
66 "sort"
7- "strings"
87 "time"
98
109 embeddedclusterv1beta1 "github.com/replicatedhq/embedded-cluster-kinds/apis/v1beta1"
@@ -131,7 +130,7 @@ func WaitForInstallation(ctx context.Context, cli client.Client, writer *spinner
131130 lastInstall := installs [0 ]
132131
133132 if writer != nil {
134- writeStatusMessage (writer , lastInstall . Status )
133+ writeStatusMessage (writer , lastInstall )
135134 }
136135
137136 // check the status of the installation
@@ -148,27 +147,34 @@ func WaitForInstallation(ctx context.Context, cli client.Client, writer *spinner
148147 return nil
149148}
150149
151- func writeStatusMessage (writer * spinner.MessageWriter , status embeddedclusterv1beta1.InstallationStatus ) {
152- if status .State != embeddedclusterv1beta1 .InstallationStatePendingChartCreation {
153- writer .Infof ("Waiting for additional components to be ready: %s" , status .Reason )
150+ func writeStatusMessage (writer * spinner.MessageWriter , install embeddedclusterv1beta1.Installation ) {
151+ if install .Status .State != embeddedclusterv1beta1 .InstallationStatePendingChartCreation {
154152 return
155153 }
156154
157- chartNames := ""
158- if len (status .PendingCharts ) == 0 {
155+ if install .Spec .Config == nil || install .Spec .Config .Extensions .Helm == nil {
159156 return
160- } else if len (status .PendingCharts ) == 1 {
161- // A
162- chartNames = status .PendingCharts [0 ]
163- } else if len (status .PendingCharts ) == 2 {
164- // A and B
165- chartNames = strings .Join (status .PendingCharts , " and " )
166- } else {
167- // A, B, and C
168- chartNames = strings .Join (status .PendingCharts [:len (status .PendingCharts )- 1 ], ", " ) + " and " + status .PendingCharts [len (status .PendingCharts )- 1 ]
157+ }
158+ numDesiredCharts := len (install .Spec .Config .Extensions .Helm .Charts )
159+
160+ pendingChartsMap := map [string ]struct {}{}
161+ for _ , chartName := range install .Status .PendingCharts {
162+ pendingChartsMap [chartName ] = struct {}{}
169163 }
170164
171- writer .Infof ("Waiting for additional components %s to be ready" , chartNames )
165+ numPendingCharts := 0
166+ for _ , ch := range install .Spec .Config .Extensions .Helm .Charts {
167+ if _ , ok := pendingChartsMap [ch .Name ]; ok {
168+ numPendingCharts ++
169+ }
170+ }
171+ numCompletedCharts := numDesiredCharts - numPendingCharts
172+
173+ if numCompletedCharts < numDesiredCharts {
174+ writer .Infof ("Waiting for additional components to be ready (%d/%d)" , numCompletedCharts , numDesiredCharts )
175+ } else {
176+ writer .Infof ("Finalizing additional components" )
177+ }
172178}
173179
174180func IsNamespaceReady (ctx context.Context , cli client.Client , ns string ) (bool , error ) {
0 commit comments