Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom wait rules for kc resources #932

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading