Skip to content

fakeClient Delete and DeleteAllOf functions do not check for dry run options #1871

Closed
@everettraven

Description

@everettraven

Problem

When using a fakeClient returned via fake.NewClientBuilder().Build() as a parameter to NewDryRunClient() I noticed that calls to the resulting dryRunClient's Delete() still deleted the resources instead of honoring the metav1.DryRunAll option.

A brief example of what my setup looks like:

fakeClient := fake.NewClientBuilder().Build()
dryRunClient := client.NewDryRunClient(fakeClient)

// This still deletes the objects passed in
dryRunClient.Delete(ctx, object)

This lead me to take a look at the source code for the fakeClient CRUD functions. I noticed that this snippet (or ones similar to it):

for _, dryRunOpt := range createOptions.DryRun {
	if dryRunOpt == metav1.DryRunAll {
		return nil
	}
}

are present in the following functions:

Proposed Solution

I am proposing that code is added to the fakeClient Delete() and DeleteAllOf() functions similar to the ones that exist in the above mentioned functions.

I am happy to take on the development work for this if the proposed solution is accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions