Skip to content

Commit

Permalink
Merge pull request #170 from mitchmckenzie/fix-decoder-delete-ignore-…
Browse files Browse the repository at this point in the history
…not-found

Fix decoder delete ignore not found
  • Loading branch information
k8s-ci-robot authored Nov 28, 2022
2 parents 571a8b1 + 5e8d4f7 commit abdd155
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
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

0 comments on commit abdd155

Please sign in to comment.