@@ -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,7 +282,7 @@ 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 ) {
285+ func (bc * Boxcutter ) Apply (ctx context.Context , contentFS fs.FS , ext * ocv1.ClusterExtension , objectLabels , revisionAnnotations map [string ]string ) error {
287286 return bc .apply (ctx , contentFS , ext , objectLabels , revisionAnnotations )
288287}
289288
@@ -308,21 +307,21 @@ func (bc *Boxcutter) createOrUpdate(ctx context.Context, obj client.Object) erro
308307 return bc .Client .Patch (ctx , obj , client .Apply , client .FieldOwner (bc .FieldOwner ), client .ForceOwnership )
309308}
310309
311- func (bc * Boxcutter ) apply (ctx context.Context , contentFS fs.FS , ext * ocv1.ClusterExtension , objectLabels , revisionAnnotations map [string ]string ) ( bool , string , error ) {
310+ func (bc * Boxcutter ) apply (ctx context.Context , contentFS fs.FS , ext * ocv1.ClusterExtension , objectLabels , revisionAnnotations map [string ]string ) error {
312311 // Generate desired revision
313312 desiredRevision , err := bc .RevisionGenerator .GenerateRevision (ctx , contentFS , ext , objectLabels , revisionAnnotations )
314313 if err != nil {
315- return false , "" , err
314+ return err
316315 }
317316
318317 if err := controllerutil .SetControllerReference (ext , desiredRevision , bc .Scheme ); err != nil {
319- return false , "" , fmt .Errorf ("set ownerref: %w" , err )
318+ return fmt .Errorf ("set ownerref: %w" , err )
320319 }
321320
322321 // List all existing revisions
323322 existingRevisions , err := bc .getExistingRevisions (ctx , ext .GetName ())
324323 if err != nil {
325- return false , "" , err
324+ return err
326325 }
327326
328327 currentRevision := & ocv1.ClusterExtensionRevision {}
@@ -344,7 +343,7 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
344343 // inplace patch was successful, no changes in phases
345344 state = StateUnchanged
346345 default :
347- return false , "" , fmt .Errorf ("patching %s Revision: %w" , desiredRevision .Name , err )
346+ return fmt .Errorf ("patching %s Revision: %w" , desiredRevision .Name , err )
348347 }
349348 }
350349
@@ -358,7 +357,7 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
358357 case StateNeedsInstall :
359358 err := preflight .Install (ctx , plainObjs )
360359 if err != nil {
361- return false , "" , err
360+ return err
362361 }
363362 // TODO: jlanford's IDE says that "StateNeedsUpgrade" condition is always true, but
364363 // it isn't immediately obvious why that is. Perhaps len(existingRevisions) is
@@ -367,7 +366,7 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
367366 case StateNeedsUpgrade :
368367 err := preflight .Upgrade (ctx , plainObjs )
369368 if err != nil {
370- return false , "" , err
369+ return err
371370 }
372371 }
373372 }
@@ -381,34 +380,15 @@ func (bc *Boxcutter) apply(ctx context.Context, contentFS fs.FS, ext *ocv1.Clust
381380 desiredRevision .Spec .Revision = revisionNumber
382381
383382 if err = bc .garbageCollectOldRevisions (ctx , prevRevisions ); err != nil {
384- return false , "" , fmt .Errorf ("garbage collecting old revisions: %w" , err )
383+ return fmt .Errorf ("garbage collecting old revisions: %w" , err )
385384 }
386385
387386 if err := bc .createOrUpdate (ctx , desiredRevision ); err != nil {
388- return false , "" , fmt .Errorf ("creating new Revision: %w" , err )
387+ return fmt .Errorf ("creating new Revision: %w" , err )
389388 }
390- currentRevision = desiredRevision
391389 }
392390
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
391+ return nil
412392}
413393
414394// garbageCollectOldRevisions deletes archived revisions beyond ClusterExtensionRevisionRetentionLimit.
0 commit comments