@@ -13,7 +13,6 @@ import (
1313 "helm.sh/helm/v3/pkg/release"
1414 "helm.sh/helm/v3/pkg/storage/driver"
1515 apierrors "k8s.io/apimachinery/pkg/api/errors"
16- "k8s.io/apimachinery/pkg/api/meta"
1716 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1817 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1918 "k8s.io/apimachinery/pkg/runtime"
@@ -283,10 +282,6 @@ type Boxcutter struct {
283282 FieldOwner string
284283}
285284
286- func (bc * Boxcutter ) Apply (ctx context.Context , contentFS fs.FS , ext * ocv1.ClusterExtension , objectLabels , revisionAnnotations map [string ]string ) (bool , string , error ) {
287- return bc .apply (ctx , contentFS , ext , objectLabels , revisionAnnotations )
288- }
289-
290285func (bc * Boxcutter ) getObjects (rev * ocv1.ClusterExtensionRevision ) []client.Object {
291286 var objs []client.Object
292287 for _ , phase := range rev .Spec .Phases {
@@ -308,21 +303,21 @@ func (bc *Boxcutter) createOrUpdate(ctx context.Context, obj client.Object) erro
308303 return bc .Client .Patch (ctx , obj , client .Apply , client .FieldOwner (bc .FieldOwner ), client .ForceOwnership )
309304}
310305
311- func (bc * Boxcutter ) apply (ctx context.Context , contentFS fs.FS , ext * ocv1.ClusterExtension , objectLabels , revisionAnnotations map [string ]string ) ( bool , string , error ) {
306+ func (bc * Boxcutter ) Apply (ctx context.Context , contentFS fs.FS , ext * ocv1.ClusterExtension , objectLabels , revisionAnnotations map [string ]string ) error {
312307 // Generate desired revision
313308 desiredRevision , err := bc .RevisionGenerator .GenerateRevision (ctx , contentFS , ext , objectLabels , revisionAnnotations )
314309 if err != nil {
315- return false , "" , err
310+ return err
316311 }
317312
318313 if err := controllerutil .SetControllerReference (ext , desiredRevision , bc .Scheme ); err != nil {
319- return false , "" , fmt .Errorf ("set ownerref: %w" , err )
314+ return fmt .Errorf ("set ownerref: %w" , err )
320315 }
321316
322317 // List all existing revisions
323318 existingRevisions , err := bc .getExistingRevisions (ctx , ext .GetName ())
324319 if err != nil {
325- return false , "" , err
320+ return err
326321 }
327322
328323 currentRevision := & ocv1.ClusterExtensionRevision {}
@@ -344,7 +339,7 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
344339 // inplace patch was successful, no changes in phases
345340 state = StateUnchanged
346341 default :
347- return false , "" , fmt .Errorf ("patching %s Revision: %w" , desiredRevision .Name , err )
342+ return fmt .Errorf ("patching %s Revision: %w" , desiredRevision .Name , err )
348343 }
349344 }
350345
@@ -358,7 +353,7 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
358353 case StateNeedsInstall :
359354 err := preflight .Install (ctx , plainObjs )
360355 if err != nil {
361- return false , "" , err
356+ return err
362357 }
363358 // TODO: jlanford's IDE says that "StateNeedsUpgrade" condition is always true, but
364359 // it isn't immediately obvious why that is. Perhaps len(existingRevisions) is
@@ -367,7 +362,7 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
367362 case StateNeedsUpgrade :
368363 err := preflight .Upgrade (ctx , plainObjs )
369364 if err != nil {
370- return false , "" , err
365+ return err
371366 }
372367 }
373368 }
@@ -381,34 +376,15 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
381376 desiredRevision .Spec .Revision = revisionNumber
382377
383378 if err = bc .garbageCollectOldRevisions (ctx , prevRevisions ); err != nil {
384- return false , "" , fmt .Errorf ("garbage collecting old revisions: %w" , err )
379+ return fmt .Errorf ("garbage collecting old revisions: %w" , err )
385380 }
386381
387382 if err := bc .createOrUpdate (ctx , desiredRevision ); err != nil {
388- return false , "" , fmt .Errorf ("creating new Revision: %w" , err )
383+ return fmt .Errorf ("creating new Revision: %w" , err )
389384 }
390- currentRevision = desiredRevision
391385 }
392386
393- progressingCondition := meta .FindStatusCondition (currentRevision .Status .Conditions , ocv1 .TypeProgressing )
394- availableCondition := meta .FindStatusCondition (currentRevision .Status .Conditions , ocv1 .ClusterExtensionRevisionTypeAvailable )
395- succeededCondition := meta .FindStatusCondition (currentRevision .Status .Conditions , ocv1 .ClusterExtensionRevisionTypeSucceeded )
396-
397- if progressingCondition == nil && availableCondition == nil && succeededCondition == nil {
398- return false , "New revision created" , nil
399- } else if progressingCondition != nil && progressingCondition .Status == metav1 .ConditionTrue {
400- switch progressingCondition .Reason {
401- case ocv1 .ReasonSucceeded :
402- return true , "" , nil
403- case ocv1 .ClusterExtensionRevisionReasonRetrying :
404- return false , "" , errors .New (progressingCondition .Message )
405- default :
406- return false , progressingCondition .Message , nil
407- }
408- } else if succeededCondition != nil && succeededCondition .Status != metav1 .ConditionTrue {
409- return false , succeededCondition .Message , nil
410- }
411- return true , "" , nil
387+ return nil
412388}
413389
414390// garbageCollectOldRevisions deletes archived revisions beyond ClusterExtensionRevisionRetentionLimit.
0 commit comments