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

Fix decoder delete ignore not found #170

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
4 changes: 2 additions & 2 deletions klient/decoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,6 @@ func CreateIgnoreAlreadyExists(r *resources.Resources, opts ...resources.CreateO
}

// DeleteIgnoreNotFound returns a HandlerFunc that will delete objects if they do not already exist
func DeleteIgnoreNotFound(r *resources.Resources, opts ...resources.CreateOption) HandlerFunc {
return IgnoreErrorHandler(CreateHandler(r, opts...), apierrors.IsNotFound)
func DeleteIgnoreNotFound(r *resources.Resources, opts ...resources.DeleteOption) HandlerFunc {
return IgnoreErrorHandler(DeleteHandler(r, opts...), apierrors.IsNotFound)
}
7 changes: 7 additions & 0 deletions klient/decoder/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,11 @@ func TestHandlerFuncs(t *testing.T) {
}
})
})

t.Run("DecodeEach_DeleteIgnoreNotFound", func(t *testing.T) {
err := DecodeEachFile(context.TODO(), testdata, "*", DeleteIgnoreNotFound(res), patches...)
if err != nil {
t.Fatalf("DeleteIgnoreNotFound should not return an error if object is not found. Error: %s", err)
}
})
}
5 changes: 0 additions & 5 deletions pkg/envfuncs/kind_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func GetKindClusterFromContext(ctx context.Context, clusterName string) (*kind.C
//
// NOTE: the returned function will update its env config with the
// kubeconfig file for the config client.
//
func CreateKindCluster(clusterName string) env.Func {
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
k := kind.NewCluster(clusterName)
Expand Down Expand Up @@ -78,7 +77,6 @@ func CreateKindCluster(clusterName string) env.Func {
//
// NOTE: the returned function will update its env config with the
// kubeconfig file for the config client.
//
func CreateKindClusterWithConfig(clusterName, image, configFilePath string) env.Func {
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
k := kind.NewCluster(clusterName)
Expand Down Expand Up @@ -142,7 +140,6 @@ func waitForControlPlane(client klient.Client) error {
// retrieves a previously saved kind Cluster in the context (using the name), then deletes it.
//
// NOTE: this should be used in a Environment.Finish step.
//
func DestroyKindCluster(name string) env.Func {
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
clusterVal := ctx.Value(kindContextKey(name))
Expand All @@ -166,7 +163,6 @@ func DestroyKindCluster(name string) env.Func {
// LoadDockerImageToCluster returns an EnvFunc that
// retrieves a previously saved kind Cluster in the context (using the name), and then loads a docker image
// from the host into the cluster.
//
func LoadDockerImageToCluster(name, image string) env.Func {
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
clusterVal := ctx.Value(kindContextKey(name))
Expand All @@ -190,7 +186,6 @@ func LoadDockerImageToCluster(name, image string) env.Func {
// LoadImageArchiveToCluster returns an EnvFunc that
// retrieves a previously saved kind Cluster in the context (using the name), and then loads a docker image TAR archive
// from the host into the cluster.
//
func LoadImageArchiveToCluster(name, imageArchive string) env.Func {
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
clusterVal := ctx.Value(kindContextKey(name))
Expand Down