diff --git a/pkg/nuke/nuke.go b/pkg/nuke/nuke.go index c473ffb..4f679a4 100644 --- a/pkg/nuke/nuke.go +++ b/pkg/nuke/nuke.go @@ -464,9 +464,9 @@ func (n *Nuke) HandleQueue(ctx context.Context) { // HandleRemove is used to handle the removal of a resource. It will remove the resource and set the state of the // resource to pending if it was successful or failed if it was not. -func (n *Nuke) HandleRemove(_ context.Context, item *queue.Item) { +func (n *Nuke) HandleRemove(ctx context.Context, item *queue.Item) { // TODO: pass context to remove for remove functions to use - err := item.Resource.Remove() + err := item.Resource.Remove(ctx) if err != nil { var resErr liberrors.ErrHoldResource if errors.As(err, &resErr) { diff --git a/pkg/nuke/nuke_filter_test.go b/pkg/nuke/nuke_filter_test.go index 690efde..40f2326 100644 --- a/pkg/nuke/nuke_filter_test.go +++ b/pkg/nuke/nuke_filter_test.go @@ -177,7 +177,7 @@ func (r TestResourceFilter) Properties() types.Properties { return props } -func (r TestResourceFilter) Remove() error { +func (r TestResourceFilter) Remove(_ context.Context) error { return nil } diff --git a/pkg/nuke/nuke_run_test.go b/pkg/nuke/nuke_run_test.go index becd2ca..797d8b4 100644 --- a/pkg/nuke/nuke_run_test.go +++ b/pkg/nuke/nuke_run_test.go @@ -15,8 +15,8 @@ import ( type TestResourceSuccess struct{} -func (r *TestResourceSuccess) Remove() error { return nil } -func (r *TestResourceSuccess) String() string { return "TestResourceFailure" } +func (r *TestResourceSuccess) Remove(_ context.Context) error { return nil } +func (r *TestResourceSuccess) String() string { return "TestResourceFailure" } type TestResourceSuccessLister struct { listed bool @@ -32,7 +32,9 @@ func (l *TestResourceSuccessLister) List(_ context.Context, o interface{}) ([]re type TestResourceFailure struct{} -func (r *TestResourceFailure) Remove() error { return fmt.Errorf("unable to remove") } +func (r *TestResourceFailure) Remove(_ context.Context) error { + return fmt.Errorf("unable to remove") +} func (r *TestResourceFailure) String() string { return "TestResourceFailure" } type TestResourceFailureLister struct{} diff --git a/pkg/nuke/nuke_test.go b/pkg/nuke/nuke_test.go index 23caaea..c46dc38 100644 --- a/pkg/nuke/nuke_test.go +++ b/pkg/nuke/nuke_test.go @@ -237,7 +237,7 @@ type TestResource3 struct { Error bool } -func (r TestResource3) Remove() error { +func (r TestResource3) Remove(_ context.Context) error { if r.Error { return fmt.Errorf("remove error") } @@ -344,7 +344,7 @@ type TestResource4 struct { parentID string } -func (r *TestResource4) Remove() error { +func (r *TestResource4) Remove(_ context.Context) error { if r.parentID != "" { parentFound := false diff --git a/pkg/nuke/scan_test.go b/pkg/nuke/scan_test.go index c034e56..dced527 100644 --- a/pkg/nuke/scan_test.go +++ b/pkg/nuke/scan_test.go @@ -57,7 +57,7 @@ func (r TestResource) Filter() error { return nil } -func (r TestResource) Remove() error { +func (r TestResource) Remove(_ context.Context) error { if r.RemoveError { return fmt.Errorf("remove error") } @@ -81,7 +81,7 @@ func (r TestResource2) Filter() error { return nil } -func (r TestResource2) Remove() error { +func (r TestResource2) Remove(_ context.Context) error { if r.RemoveError { return fmt.Errorf("remove error") } diff --git a/pkg/queue/item_test.go b/pkg/queue/item_test.go index d11d1dc..c04b1cc 100644 --- a/pkg/queue/item_test.go +++ b/pkg/queue/item_test.go @@ -19,7 +19,7 @@ func (r *TestItemResource) Properties() types.Properties { props.Set(r.id, "testing") return props } -func (r *TestItemResource) Remove() error { +func (r *TestItemResource) Remove(_ context.Context) error { return nil } func (r *TestItemResource) String() string { @@ -28,7 +28,7 @@ func (r *TestItemResource) String() string { type TestItemResource2 struct{} -func (r TestItemResource2) Remove() error { +func (r TestItemResource2) Remove(_ context.Context) error { return nil } @@ -169,7 +169,7 @@ func Test_ItemPrint(t *testing.T) { type TestItemResourceProperties struct{} -func (r *TestItemResourceProperties) Remove() error { +func (r *TestItemResourceProperties) Remove(_ context.Context) error { return nil } func (r *TestItemResourceProperties) Properties() types.Properties { @@ -191,7 +191,7 @@ func Test_ItemEqualProperties(t *testing.T) { type TestItemResourceStringer struct{} -func (r *TestItemResourceStringer) Remove() error { +func (r *TestItemResourceStringer) Remove(_ context.Context) error { return nil } func (r *TestItemResourceStringer) String() string { @@ -221,7 +221,7 @@ func Test_ItemEqualStringer(t *testing.T) { type TestItemResourceNothing struct{} -func (r *TestItemResourceNothing) Remove() error { +func (r *TestItemResourceNothing) Remove(_ context.Context) error { return nil } diff --git a/pkg/resource/resource.go b/pkg/resource/resource.go index b956650..0f0ee5b 100644 --- a/pkg/resource/resource.go +++ b/pkg/resource/resource.go @@ -1,12 +1,14 @@ package resource import ( + "context" + "github.com/ekristen/libnuke/pkg/featureflag" "github.com/ekristen/libnuke/pkg/types" ) type Resource interface { - Remove() error + Remove(ctx context.Context) error } type Filter interface { diff --git a/pkg/resource/resource_test.go b/pkg/resource/resource_test.go index c99a2a9..1c6f176 100644 --- a/pkg/resource/resource_test.go +++ b/pkg/resource/resource_test.go @@ -1,6 +1,7 @@ package resource import ( + "context" "fmt" "testing" @@ -15,7 +16,7 @@ type TestResource struct { Flags *featureflag.FeatureFlags } -func (r *TestResource) Remove() error { +func (r *TestResource) Remove(_ context.Context) error { return fmt.Errorf("remove called") } @@ -39,7 +40,7 @@ func (r *TestResource) FeatureFlags(ff *featureflag.FeatureFlags) { func TestInterfaceResource(t *testing.T) { r := TestResource{} - err := r.Remove() + err := r.Remove(context.TODO()) assert.Error(t, err) assert.Equal(t, "remove called", err.Error()) }