From 631cc2a731383585ffee2e87ac8c44fc242946bc Mon Sep 17 00:00:00 2001 From: Yauheni Kaliuta Date: Wed, 12 Jun 2024 22:07:45 +0300 Subject: [PATCH] cluster: platform name cleanup (#1054) * cluster: rename isXManaged to detectX "is" prefix assumes that it returns boolean value while the functions return actual results. Signed-off-by: Yauheni Kaliuta * cluster: tune managed/selfmanaged user facing name Jira: https://issues.redhat.com/browse/RHOAIENG-8497 The config map name "addon-managed-odh-catalog" is not pretty enough. Also self managed variant is ambiguous, does not say it explicitly. Change the names to: - Managed Red Hat OpenShift AI - Self Managed Red Hat OpenShift AI Signed-off-by: Yauheni Kaliuta --------- Signed-off-by: Yauheni Kaliuta --- pkg/cluster/cluster_config.go | 14 +++++++------- pkg/cluster/const.go | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/cluster/cluster_config.go b/pkg/cluster/cluster_config.go index cbfd20a3712..274abae0c97 100644 --- a/pkg/cluster/cluster_config.go +++ b/pkg/cluster/cluster_config.go @@ -66,8 +66,8 @@ func GetClusterServiceVersion(ctx context.Context, c client.Client, watchNameSpa type Platform string -// isSelfManaged detects if it is Self Managed Rhods or OpenDataHub. -func isSelfManaged(cli client.Client) (Platform, error) { +// detectSelfManaged detects if it is Self Managed Rhods or OpenDataHub. +func detectSelfManaged(cli client.Client) (Platform, error) { variants := map[string]Platform{ "opendatahub-operator": OpenDataHub, "rhods-operator": SelfManagedRhods, @@ -86,8 +86,8 @@ func isSelfManaged(cli client.Client) (Platform, error) { return Unknown, nil } -// isManagedRHODS checks if CRD add-on exists and contains string ManagedRhods. -func isManagedRHODS(cli client.Client) (Platform, error) { +// detectManagedRHODS checks if CRD add-on exists and contains string ManagedRhods. +func detectManagedRHODS(cli client.Client) (Platform, error) { catalogSourceCRD := &apiextv1.CustomResourceDefinition{} err := cli.Get(context.TODO(), client.ObjectKey{Name: "catalogsources.operators.coreos.com"}, catalogSourceCRD) @@ -101,7 +101,7 @@ func isManagedRHODS(cli client.Client) (Platform, error) { } if len(expectedCatlogSource.Items) > 0 { for _, cs := range expectedCatlogSource.Items { - if cs.Name == string(ManagedRhods) { + if cs.Name == "addon-managed-odh-catalog" { return ManagedRhods, nil } } @@ -112,14 +112,14 @@ func isManagedRHODS(cli client.Client) (Platform, error) { func GetPlatform(cli client.Client) (Platform, error) { // First check if its addon installation to return 'ManagedRhods, nil' - if platform, err := isManagedRHODS(cli); err != nil { + if platform, err := detectManagedRHODS(cli); err != nil { return Unknown, err } else if platform == ManagedRhods { return ManagedRhods, nil } // check and return whether ODH or self-managed platform - return isSelfManaged(cli) + return detectSelfManaged(cli) } // Release includes information on operator version and platform diff --git a/pkg/cluster/const.go b/pkg/cluster/const.go index 697f21ff105..877b8a67313 100644 --- a/pkg/cluster/const.go +++ b/pkg/cluster/const.go @@ -2,9 +2,9 @@ package cluster const ( // ManagedRhods defines expected addon catalogsource. - ManagedRhods Platform = "addon-managed-odh-catalog" + ManagedRhods Platform = "Managed Red Hat OpenShift AI" // SelfManagedRhods defines display name in csv. - SelfManagedRhods Platform = "Red Hat OpenShift AI" + SelfManagedRhods Platform = "Self Managed Red Hat OpenShift AI" // OpenDataHub defines display name in csv. OpenDataHub Platform = "Open Data Hub Operator" // Unknown indicates that operator is not deployed using OLM.