Skip to content

Commit

Permalink
Allow custom wait rules for kc resources (#932)
Browse files Browse the repository at this point in the history
Signed-off-by: Praveen Rewar <8457124+praveenrewar@users.noreply.github.com>
  • Loading branch information
praveenrewar authored Apr 24, 2024
1 parent 6321d10 commit 32b2b6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/kapp/clusterapply/converged_resource_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func (f ConvergedResourceFactory) New(res ctlres.Resource,
associatedRsFunc func(ctlres.Resource, []ctlres.ResourceRef) ([]ctlres.Resource, error)) ConvergedResource {

specificResFactories := []SpecificResFactory{
// custom waiting resource waiter deals with reconciliation _and_ deletion
func(res ctlres.Resource, _ []ctlres.Resource) (SpecificResource, []ctlres.ResourceRef) {
return ctlresm.NewCustomWaitingResource(res, f.waitRules), nil
},
// kapp-controller app resource waiter deals with reconciliation _and_ deletion
func(res ctlres.Resource, _ []ctlres.Resource) (SpecificResource, []ctlres.ResourceRef) {
return ctlresm.NewKappctrlK14sIoV1alpha1App(res), nil
Expand All @@ -38,14 +42,12 @@ func (f ConvergedResourceFactory) New(res ctlres.Resource,
func(res ctlres.Resource, _ []ctlres.Resource) (SpecificResource, []ctlres.ResourceRef) {
return ctlresm.NewPackagingCarvelDevV1alpha1PackageRepo(res), nil
},

// Deal with deletion generically since below resource waiters do not not know about that
// TODO shoud we make all of them deal with deletion internally?
func(res ctlres.Resource, _ []ctlres.Resource) (SpecificResource, []ctlres.ResourceRef) {
return ctlresm.NewDeleting(res), nil
},
func(res ctlres.Resource, _ []ctlres.Resource) (SpecificResource, []ctlres.ResourceRef) {
return ctlresm.NewCustomWaitingResource(res, f.waitRules), nil
},
func(res ctlres.Resource, _ []ctlres.Resource) (SpecificResource, []ctlres.ResourceRef) {
return ctlresm.NewAPIExtensionsVxCRD(res), nil
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/kapp/resourcesmisc/custom_waiting_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ type customWaitingResourceCondition struct {
}

func (s CustomWaitingResource) IsDoneApplying() DoneApplyState {
deletingRes := NewDeleting(s.resource)
if deletingRes != nil {
return deletingRes.IsDoneApplying()
}

obj := customWaitingResourceStruct{}

err := s.resource.AsUncheckedTypedObj(&obj)
Expand Down

0 comments on commit 32b2b6f

Please sign in to comment.