diff --git a/.golangci.yaml b/.golangci.yaml index e4ba57da9c..ea71d66e1d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -40,7 +40,7 @@ linters: alias: ctrl - pkg: github.com/blang/semver/v4 alias: bsemver - - pkg: ^github.com/operator-framework/operator-controller/internal/util/([^/]+)$ + - pkg: ^github.com/operator-framework/operator-controller/internal/shared/util/([^/]+)$ alias: ${1}util exclusions: generated: lax diff --git a/internal/catalogd/features/features.go b/internal/catalogd/features/features.go index 298cbc8590..abf23083aa 100644 --- a/internal/catalogd/features/features.go +++ b/internal/catalogd/features/features.go @@ -5,7 +5,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/component-base/featuregate" - fgutil "github.com/operator-framework/operator-controller/internal/shared/util/featuregates" + featuregatesutil "github.com/operator-framework/operator-controller/internal/shared/util/featuregates" ) const ( @@ -24,5 +24,5 @@ func init() { // LogFeatureGateStates logs the state of all known feature gates for catalogd func LogFeatureGateStates(log logr.Logger, fg featuregate.FeatureGate) { - fgutil.LogFeatureGateStates(log, "catalogd feature gate status", fg, catalogdFeatureGates) + featuregatesutil.LogFeatureGateStates(log, "catalogd feature gate status", fg, catalogdFeatureGates) } diff --git a/internal/operator-controller/features/features.go b/internal/operator-controller/features/features.go index 4926ff8539..1ad409e099 100644 --- a/internal/operator-controller/features/features.go +++ b/internal/operator-controller/features/features.go @@ -5,7 +5,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/component-base/featuregate" - fgutil "github.com/operator-framework/operator-controller/internal/shared/util/featuregates" + featuregatesutil "github.com/operator-framework/operator-controller/internal/shared/util/featuregates" ) const ( @@ -90,5 +90,5 @@ func init() { // LogFeatureGateStates logs the state of all known feature gates. func LogFeatureGateStates(log logr.Logger, fg featuregate.FeatureGate) { - fgutil.LogFeatureGateStates(log, "feature gate status", fg, operatorControllerFeatureGates) + featuregatesutil.LogFeatureGateStates(log, "feature gate status", fg, operatorControllerFeatureGates) } diff --git a/internal/shared/util/testutils/artifacts.go b/internal/shared/util/test/artifacts.go similarity index 99% rename from internal/shared/util/testutils/artifacts.go rename to internal/shared/util/test/artifacts.go index 6bda44b673..dc10546923 100644 --- a/internal/shared/util/testutils/artifacts.go +++ b/internal/shared/util/test/artifacts.go @@ -1,4 +1,4 @@ -package testutils +package test import ( "context" diff --git a/internal/shared/util/testutils/summary.go b/internal/shared/util/test/summary.go similarity index 99% rename from internal/shared/util/testutils/summary.go rename to internal/shared/util/test/summary.go index 37c1d51e01..5baa4db069 100644 --- a/internal/shared/util/testutils/summary.go +++ b/internal/shared/util/test/summary.go @@ -1,4 +1,4 @@ -package testutils +package test import ( "context" diff --git a/internal/shared/util/testutils/templates/alert.md.tmpl b/internal/shared/util/test/templates/alert.md.tmpl similarity index 100% rename from internal/shared/util/testutils/templates/alert.md.tmpl rename to internal/shared/util/test/templates/alert.md.tmpl diff --git a/internal/shared/util/testutils/templates/mermaid_chart.md.tmpl b/internal/shared/util/test/templates/mermaid_chart.md.tmpl similarity index 100% rename from internal/shared/util/testutils/templates/mermaid_chart.md.tmpl rename to internal/shared/util/test/templates/mermaid_chart.md.tmpl diff --git a/internal/shared/util/testutils/templates/summary.md.tmpl b/internal/shared/util/test/templates/summary.md.tmpl similarity index 100% rename from internal/shared/util/testutils/templates/summary.md.tmpl rename to internal/shared/util/test/templates/summary.md.tmpl diff --git a/internal/shared/util/testutils/utils.go b/internal/shared/util/test/utils.go similarity index 97% rename from internal/shared/util/testutils/utils.go rename to internal/shared/util/test/utils.go index 94eb2d5b3c..41128e46f0 100644 --- a/internal/shared/util/testutils/utils.go +++ b/internal/shared/util/test/utils.go @@ -1,4 +1,4 @@ -package testutils +package test import ( "os/exec" diff --git a/test/e2e/cluster_extension_install_test.go b/test/e2e/cluster_extension_install_test.go index b3380ff0f5..b1994d7e03 100644 --- a/test/e2e/cluster_extension_install_test.go +++ b/test/e2e/cluster_extension_install_test.go @@ -22,7 +22,7 @@ import ( "k8s.io/utils/ptr" ocv1 "github.com/operator-framework/operator-controller/api/v1" - utils "github.com/operator-framework/operator-controller/internal/shared/util/testutils" + testutil "github.com/operator-framework/operator-controller/internal/shared/util/test" . "github.com/operator-framework/operator-controller/test/helpers" ) @@ -59,7 +59,7 @@ func TestClusterExtensionInstallRegistry(t *testing.T) { clusterExtension, extensionCatalog, sa, ns := TestInit(t) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) clusterExtension.Spec = ocv1.ClusterExtensionSpec{ Source: ocv1.SourceConfig{ @@ -129,7 +129,7 @@ func TestClusterExtensionInstallRegistryDynamic(t *testing.T) { clusterExtension, extensionCatalog, sa, ns := TestInit(t) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) clusterExtension.Spec = ocv1.ClusterExtensionSpec{ Source: ocv1.SourceConfig{ @@ -203,7 +203,7 @@ func TestClusterExtensionInstallRegistryMultipleBundles(t *testing.T) { require.NoError(t, err) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) defer func(cat *ocv1.ClusterCatalog) { require.NoError(t, c.Delete(context.Background(), cat)) require.Eventually(t, func() bool { @@ -254,7 +254,7 @@ func TestClusterExtensionBlockInstallNonSuccessorVersion(t *testing.T) { clusterExtension, extensionCatalog, sa, ns := TestInit(t) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) t.Log("By creating an ClusterExtension at a specified version") clusterExtension.Spec = ocv1.ClusterExtensionSpec{ @@ -315,7 +315,7 @@ func TestClusterExtensionForceInstallNonSuccessorVersion(t *testing.T) { clusterExtension, extensionCatalog, sa, ns := TestInit(t) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) t.Log("By creating an ClusterExtension at a specified version") clusterExtension.Spec = ocv1.ClusterExtensionSpec{ @@ -362,7 +362,7 @@ func TestClusterExtensionInstallSuccessorVersion(t *testing.T) { t.Log("When resolving upgrade edges") clusterExtension, extensionCatalog, sa, ns := TestInit(t) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) t.Log("By creating an ClusterExtension at a specified version") clusterExtension.Spec = ocv1.ClusterExtensionSpec{ @@ -408,7 +408,7 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) { t.Log("It resolves again when a catalog is patched with new ImageRef") clusterExtension, extensionCatalog, sa, ns := TestInit(t) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) clusterExtension.Spec = ocv1.ClusterExtensionSpec{ Source: ocv1.SourceConfig{ @@ -495,7 +495,7 @@ func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) { sa, err := CreateServiceAccount(context.Background(), types.NamespacedName{Name: clusterExtensionName, Namespace: ns.Name}, clusterExtensionName) require.NoError(t, err) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) clusterExtension.Spec = ocv1.ClusterExtensionSpec{ Source: ocv1.SourceConfig{ @@ -553,7 +553,7 @@ func TestClusterExtensionInstallReResolvesWhenManagedContentChanged(t *testing.T t.Log("It resolves again when managed content is changed") clusterExtension, extensionCatalog, sa, ns := TestInit(t) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) clusterExtension.Spec = ocv1.ClusterExtensionSpec{ Source: ocv1.SourceConfig{ @@ -607,7 +607,7 @@ func TestClusterExtensionRecoversFromNoNamespaceWhenFailureFixed(t *testing.T) { clusterExtension, extensionCatalog := TestInitClusterExtensionClusterCatalog(t) defer TestCleanup(t, extensionCatalog, clusterExtension, nil, nil) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) clusterExtension.Spec = ocv1.ClusterExtensionSpec{ Source: ocv1.SourceConfig{ @@ -682,7 +682,7 @@ func TestClusterExtensionRecoversFromExistingDeploymentWhenFailureFixed(t *testi clusterExtension, extensionCatalog, sa, ns := TestInit(t) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) clusterExtension.Spec = ocv1.ClusterExtensionSpec{ Source: ocv1.SourceConfig{ diff --git a/test/e2e/cluster_extension_revision_test.go b/test/e2e/cluster_extension_revision_test.go index 5bf5f2d70f..5c21e66ab0 100644 --- a/test/e2e/cluster_extension_revision_test.go +++ b/test/e2e/cluster_extension_revision_test.go @@ -20,7 +20,7 @@ import ( ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/operator-controller/features" - . "github.com/operator-framework/operator-controller/internal/shared/util/testutils" + . "github.com/operator-framework/operator-controller/internal/shared/util/test" . "github.com/operator-framework/operator-controller/test/helpers" ) diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index bb28ccdf77..847f5c7535 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -15,7 +15,7 @@ import ( ocv1 "github.com/operator-framework/operator-controller/api/v1" "github.com/operator-framework/operator-controller/internal/operator-controller/scheme" - utils "github.com/operator-framework/operator-controller/internal/shared/util/testutils" + testutil "github.com/operator-framework/operator-controller/internal/shared/util/test" ) var ( @@ -45,7 +45,7 @@ func TestMain(m *testing.M) { if path == "" { fmt.Printf("Note: E2E_SUMMARY_OUTPUT is unset; skipping summary generation") } else { - err = utils.PrintSummary(path) + err = testutil.PrintSummary(path) if err != nil { // Fail the run if alerts are found fmt.Printf("%v", err) diff --git a/test/e2e/metrics_test.go b/test/e2e/metrics_test.go index e41827987d..6df85e567e 100644 --- a/test/e2e/metrics_test.go +++ b/test/e2e/metrics_test.go @@ -25,12 +25,12 @@ import ( "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/util/rand" - utils "github.com/operator-framework/operator-controller/internal/shared/util/testutils" + testutil "github.com/operator-framework/operator-controller/internal/shared/util/test" ) // TestOperatorControllerMetricsExportedEndpoint verifies that the metrics endpoint for the operator controller func TestOperatorControllerMetricsExportedEndpoint(t *testing.T) { - client := utils.FindK8sClient(t) + client := testutil.FindK8sClient(t) curlNamespace := createRandomNamespace(t, client) componentNamespace := getComponentNamespace(t, client, "control-plane=operator-controller-controller-manager") metricsURL := fmt.Sprintf("https://operator-controller-service.%s.svc.cluster.local:8443/metrics", componentNamespace) @@ -50,7 +50,7 @@ func TestOperatorControllerMetricsExportedEndpoint(t *testing.T) { // TestCatalogdMetricsExportedEndpoint verifies that the metrics endpoint for catalogd func TestCatalogdMetricsExportedEndpoint(t *testing.T) { - client := utils.FindK8sClient(t) + client := testutil.FindK8sClient(t) curlNamespace := createRandomNamespace(t, client) componentNamespace := getComponentNamespace(t, client, "control-plane=catalogd-controller-manager") metricsURL := fmt.Sprintf("https://catalogd-service.%s.svc.cluster.local:7443/metrics", componentNamespace) diff --git a/test/e2e/network_policy_test.go b/test/e2e/network_policy_test.go index 00143df416..8e0465f41d 100644 --- a/test/e2e/network_policy_test.go +++ b/test/e2e/network_policy_test.go @@ -15,7 +15,7 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - utils "github.com/operator-framework/operator-controller/internal/shared/util/testutils" + testutil "github.com/operator-framework/operator-controller/internal/shared/util/test" ) const ( @@ -160,7 +160,7 @@ func TestNetworkPolicyJustifications(t *testing.T) { } } - clientForComponent := utils.FindK8sClient(t) + clientForComponent := testutil.FindK8sClient(t) operatorControllerNamespace := getComponentNamespace(t, clientForComponent, operatorManagerSelector) catalogDNamespace := getComponentNamespace(t, clientForComponent, catalogdManagerSelector) diff --git a/test/e2e/single_namespace_support_test.go b/test/e2e/single_namespace_support_test.go index 2c3b825a1a..190e786ba8 100644 --- a/test/e2e/single_namespace_support_test.go +++ b/test/e2e/single_namespace_support_test.go @@ -18,7 +18,7 @@ import ( "k8s.io/utils/ptr" ocv1 "github.com/operator-framework/operator-controller/api/v1" - utils "github.com/operator-framework/operator-controller/internal/shared/util/testutils" + testutil "github.com/operator-framework/operator-controller/internal/shared/util/test" . "github.com/operator-framework/operator-controller/test/helpers" ) @@ -29,7 +29,7 @@ const ( func TestClusterExtensionSingleNamespaceSupport(t *testing.T) { SkipIfFeatureGateDisabled(t, soNsFlag) t.Log("Test support for cluster extension config") - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) t.Log("By creating install namespace, watch namespace and necessary rbac resources") namespace := corev1.Namespace{ @@ -187,7 +187,7 @@ func TestClusterExtensionSingleNamespaceSupport(t *testing.T) { func TestClusterExtensionOwnNamespaceSupport(t *testing.T) { SkipIfFeatureGateDisabled(t, soNsFlag) t.Log("Test support for cluster extension with OwnNamespace install mode support") - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) t.Log("By creating install namespace, watch namespace and necessary rbac resources") namespace := corev1.Namespace{ @@ -363,7 +363,7 @@ func TestClusterExtensionVersionUpdate(t *testing.T) { clusterExtension, extensionCatalog, sa, ns := TestInit(t) defer TestCleanup(t, extensionCatalog, clusterExtension, sa, ns) - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) t.Log("By creating an ClusterExtension at a specified version") clusterExtension.Spec = ocv1.ClusterExtensionSpec{ diff --git a/test/e2e/webhook_support_test.go b/test/e2e/webhook_support_test.go index 1c80c615be..9fd05184a6 100644 --- a/test/e2e/webhook_support_test.go +++ b/test/e2e/webhook_support_test.go @@ -20,7 +20,7 @@ import ( "k8s.io/utils/ptr" ocv1 "github.com/operator-framework/operator-controller/api/v1" - utils "github.com/operator-framework/operator-controller/internal/shared/util/testutils" + testutil "github.com/operator-framework/operator-controller/internal/shared/util/test" . "github.com/operator-framework/operator-controller/test/helpers" ) @@ -29,7 +29,7 @@ var dynamicClient dynamic.Interface func TestWebhookSupport(t *testing.T) { SkipIfFeatureGateDisabled(t, "WebhookProviderCertManager") t.Log("Test support for bundles with webhooks") - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) if dynamicClient == nil { var err error diff --git a/test/upgrade-e2e/post_upgrade_test.go b/test/upgrade-e2e/post_upgrade_test.go index 785d91ea3b..af17ac5c8d 100644 --- a/test/upgrade-e2e/post_upgrade_test.go +++ b/test/upgrade-e2e/post_upgrade_test.go @@ -19,7 +19,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ocv1 "github.com/operator-framework/operator-controller/api/v1" - utils "github.com/operator-framework/operator-controller/internal/shared/util/testutils" + testutil "github.com/operator-framework/operator-controller/internal/shared/util/test" ) const ( @@ -99,7 +99,7 @@ func TestClusterCatalogUnpacking(t *testing.T) { func TestClusterExtensionAfterOLMUpgrade(t *testing.T) { t.Log("Starting checks after OLM upgrade") ctx := context.Background() - defer utils.CollectTestArtifacts(t, artifactName, c, cfg) + defer testutil.CollectTestArtifacts(t, artifactName, c, cfg) // wait for catalogd deployment to finish t.Log("Wait for catalogd deployment to be ready")