From b452e2efe0247cfb92a05349f9c23ccac768479a Mon Sep 17 00:00:00 2001 From: Andrew Lavery Date: Fri, 31 Jan 2025 12:50:54 -0500 Subject: [PATCH] fix compile --- operator/pkg/cli/migrate_v2.go | 4 +-- .../pkg/cli/migratev2/installation_test.go | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/operator/pkg/cli/migrate_v2.go b/operator/pkg/cli/migrate_v2.go index 778d2d00b..a26280543 100644 --- a/operator/pkg/cli/migrate_v2.go +++ b/operator/pkg/cli/migrate_v2.go @@ -2,8 +2,6 @@ package cli import ( "fmt" - "log" - ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1" "github.com/replicatedhq/embedded-cluster/operator/pkg/cli/migratev2" "github.com/replicatedhq/embedded-cluster/operator/pkg/k8sutil" @@ -42,7 +40,7 @@ func MigrateV2Cmd() *cobra.Command { return fmt.Errorf("failed to create kubernetes client: %w", err) } - err = migratev2.Run(ctx, log.Printf, cli, installation) + err = migratev2.Run(ctx, cli, installation) if err != nil { return fmt.Errorf("failed to run v2 migration: %w", err) } diff --git a/operator/pkg/cli/migratev2/installation_test.go b/operator/pkg/cli/migratev2/installation_test.go index 6c53a98c2..6cc451df3 100644 --- a/operator/pkg/cli/migratev2/installation_test.go +++ b/operator/pkg/cli/migratev2/installation_test.go @@ -3,6 +3,7 @@ package migratev2 import ( "context" "fmt" + "log/slog" "testing" ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1" @@ -15,6 +16,10 @@ import ( ) func Test_setV2MigrationInProgress(t *testing.T) { + // Discard log messages + old := slog.SetLogLoggerLevel(slog.LevelError) + defer slog.SetLogLoggerLevel(old) + scheme := runtime.NewScheme() require.NoError(t, ecv1beta1.AddToScheme(scheme)) @@ -76,10 +81,7 @@ func Test_setV2MigrationInProgress(t *testing.T) { WithStatusSubresource(&ecv1beta1.Installation{}). Build() - // Discard log messages - logf := func(format string, args ...any) {} - - err := setV2MigrationInProgress(context.Background(), logf, cli, tt.args.installation) + err := setV2MigrationInProgress(context.Background(), cli, tt.args.installation) require.NoError(t, err) // Verify that the condition was set correctly @@ -97,6 +99,10 @@ func Test_setV2MigrationInProgress(t *testing.T) { } func Test_setV2MigrationComplete(t *testing.T) { + // Discard log messages + old := slog.SetLogLoggerLevel(slog.LevelError) + defer slog.SetLogLoggerLevel(old) + scheme := runtime.NewScheme() require.NoError(t, ecv1beta1.AddToScheme(scheme)) @@ -156,11 +162,7 @@ func Test_setV2MigrationComplete(t *testing.T) { WithObjects(tt.args.installation). WithStatusSubresource(&ecv1beta1.Installation{}). Build() - - // Discard log messages - logf := func(format string, args ...any) {} - - err := setV2MigrationComplete(context.Background(), logf, cli, tt.args.installation) + err := setV2MigrationComplete(context.Background(), cli, tt.args.installation) require.NoError(t, err) // Verify that the condition was set correctly @@ -178,6 +180,10 @@ func Test_setV2MigrationComplete(t *testing.T) { } func Test_setV2MigrationFailed(t *testing.T) { + // Discard log messages + old := slog.SetLogLoggerLevel(slog.LevelError) + defer slog.SetLogLoggerLevel(old) + scheme := runtime.NewScheme() require.NoError(t, ecv1beta1.AddToScheme(scheme)) @@ -241,10 +247,7 @@ func Test_setV2MigrationFailed(t *testing.T) { WithStatusSubresource(&ecv1beta1.Installation{}). Build() - // Discard log messages - logf := func(format string, args ...any) {} - - err := setV2MigrationFailed(context.Background(), logf, cli, tt.args.installation, tt.args.failure) + err := setV2MigrationFailed(context.Background(), cli, tt.args.installation, tt.args.failure) require.NoError(t, err) // Verify that the condition was set correctly