From db449688c781ae7d61f0013be7d88d8b3e66d5a4 Mon Sep 17 00:00:00 2001 From: mmckenzie Date: Fri, 18 Nov 2022 23:01:21 -0600 Subject: [PATCH 1/2] fixing golang linter issues --- pkg/envfuncs/kind_funcs.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/envfuncs/kind_funcs.go b/pkg/envfuncs/kind_funcs.go index 02e531ee..724436a6 100644 --- a/pkg/envfuncs/kind_funcs.go +++ b/pkg/envfuncs/kind_funcs.go @@ -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) @@ -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) @@ -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)) @@ -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)) @@ -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)) From 5e8d4f7efd95303d1e987e5e9257d1d413aba01a Mon Sep 17 00:00:00 2001 From: mmckenzie Date: Fri, 18 Nov 2022 23:05:10 -0600 Subject: [PATCH 2/2] fixing decoder method calling create instead of delete handler --- klient/decoder/decoder.go | 4 ++-- klient/decoder/decoder_test.go | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/klient/decoder/decoder.go b/klient/decoder/decoder.go index 6124054d..c0cd314f 100644 --- a/klient/decoder/decoder.go +++ b/klient/decoder/decoder.go @@ -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) } diff --git a/klient/decoder/decoder_test.go b/klient/decoder/decoder_test.go index 88ff2bb5..f564666c 100644 --- a/klient/decoder/decoder_test.go +++ b/klient/decoder/decoder_test.go @@ -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) + } + }) }