Skip to content

Commit

Permalink
cluster: platform name cleanup (opendatahub-io#1054)
Browse files Browse the repository at this point in the history
* cluster: rename isXManaged to detectX

"is" prefix assumes that it returns boolean value while the
functions return actual results.

Signed-off-by: Yauheni Kaliuta <[email protected]>

* 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 <[email protected]>

---------

Signed-off-by: Yauheni Kaliuta <[email protected]>
  • Loading branch information
ykaliuta authored Jun 12, 2024
1 parent 261bbab commit 631cc2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions pkg/cluster/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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
}
}
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 631cc2a

Please sign in to comment.