diff --git a/clients/dynamic/dynamic.go b/clients/dynamic/dynamic.go index b46ec3ec..a15168af 100644 --- a/clients/dynamic/dynamic.go +++ b/clients/dynamic/dynamic.go @@ -104,7 +104,9 @@ func (c *ResourceClient) Create(ctx context.Context, obj *unstructured.Unstructu if needsCleanup(obj) { c.ts.RegisterCleanupFunc(func() error { - err := c.Delete(context.TODO(), unstructuredObj.GetName(), metav1.DeleteOptions{}, subresources...) + // Using this policy avoids a flood of useless warnings on test logs. + orphanPolicy := metav1.DeletePropagationOrphan + err := c.Delete(context.TODO(), unstructuredObj.GetName(), metav1.DeleteOptions{PropagationPolicy: &orphanPolicy}, subresources...) if errors.IsNotFound(err) { return nil } diff --git a/pkg/config/config.go b/pkg/config/config.go index c9758722..9d21cf53 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -6,6 +6,7 @@ import ( "os" "github.com/creasty/defaults" + "github.com/sirupsen/logrus" "sigs.k8s.io/yaml" ) @@ -18,6 +19,7 @@ func LoadConfig(key string, config interface{}) { configPath := os.Getenv(ConfigEnvironmentKey) if configPath == "" { + logrus.Infof("No config file path provided via %s env var", ConfigEnvironmentKey) yaml.Unmarshal([]byte("{}"), config) return } @@ -33,7 +35,10 @@ func LoadConfig(key string, config interface{}) { panic(err) } - scoped := all[key] + scoped, ok := all[key] + if !ok { + logrus.Infof("Key %s not present in provided config", key) + } scopedString, err := yaml.Marshal(scoped) if err != nil { panic(err) diff --git a/pkg/config/operations/operations.go b/pkg/config/operations/operations.go index 21b48e8e..68f7feff 100644 --- a/pkg/config/operations/operations.go +++ b/pkg/config/operations/operations.go @@ -2,9 +2,9 @@ package operations import ( "encoding/json" - "errors" "fmt" + "github.com/sirupsen/logrus" "sigs.k8s.io/yaml" ) @@ -42,7 +42,7 @@ func GetValue(keyPath []string, searchMap map[string]any) (any, error) { if len(keyPath) == 1 { keypathvalues, ok := searchMap[keyPath[0]] if !ok { - err = errors.New(fmt.Sprintf("expected key does not exist: %s", keyPath[0])) + err = fmt.Errorf("expected key does not exist: %s", keyPath[0]) } return keypathvalues, err } else { @@ -66,7 +66,11 @@ func GetValue(keyPath []string, searchMap map[string]any) (any, error) { // LoadObjectFromMap unmarshals a specific key's value into an object func LoadObjectFromMap(key string, config map[string]any, object any) { - keyConfig := config[key] + keyConfig, ok := config[key] + if !ok { + logrus.Infof("Key %s not present in provided config", key) + } + scopedString, err := yaml.Marshal(keyConfig) if err != nil { panic(err)