Skip to content

Commit

Permalink
feat: pass platform from env variable or fall back to use old logic (#…
Browse files Browse the repository at this point in the history
…1252)

* feat: pass platform from env variables or fall back to use old logic

- introduce new env var ODH_PLATFORM_TYPE, value set during build time
  - if value not match, fall back to detect managed then self-managed
- introduce new env var OPERATOR_RELEASE_VERSION, value also set during build time
  - if value is empty, fall back to use old way from CSV to read version or use 0.0.0
- add support from makefile
  - use envstubst to replace version

Signed-off-by: Wen Zhou <[email protected]>

* update: remove release version in the change

Signed-off-by: Wen Zhou <[email protected]>

---------

Signed-off-by: Wen Zhou <[email protected]>
  • Loading branch information
zdtsw authored Oct 9, 2024
1 parent e40c770 commit 283d350
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,8 @@ spec:
fieldPath: metadata.namespace
- name: DEFAULT_MANIFESTS_PATH
value: /opt/manifests
- name: ODH_PLATFORM_TYPE
value: OpenDataHub
image: REPLACE_IMAGE:latest
imagePullPolicy: Always
livenessProbe:
Expand Down
2 changes: 2 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ spec:
fieldPath: metadata.namespace
- name: DEFAULT_MANIFESTS_PATH
value: /opt/manifests
- name: ODH_PLATFORM_TYPE
value: OpenDataHub
args:
- --leader-elect
- --operator-name=opendatahub
Expand Down
21 changes: 14 additions & 7 deletions pkg/cluster/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,21 @@ func detectManagedRHODS(ctx context.Context, cli client.Client) (Platform, error
}

func getPlatform(ctx context.Context, cli client.Client) (Platform, error) {
// First check if its addon installation to return 'ManagedRhods, nil'
if platform, err := detectManagedRHODS(ctx, cli); err != nil {
return Unknown, err
} else if platform == ManagedRhods {
switch os.Getenv("ODH_PLATFORM_TYPE") {
case "OpenDataHub", "":
return OpenDataHub, nil
case "ManagedRHOAI":
return ManagedRhods, nil
case "SelfManagedRHOAI":
return SelfManagedRhods, nil
default: // fall back to detect platform if ODH_PLATFORM_TYPE env is not provided
if platform, err := detectManagedRHODS(ctx, cli); err != nil {
return Unknown, err
} else if platform == ManagedRhods {
return ManagedRhods, nil
}
return detectSelfManaged(ctx, cli)
}

// check and return whether ODH or self-managed platform
return detectSelfManaged(ctx, cli)
}

func getRelease(ctx context.Context, cli client.Client) (Release, error) {
Expand All @@ -197,6 +203,7 @@ func getRelease(ctx context.Context, cli client.Client) (Release, error) {
if os.Getenv("CI") == "true" {
return initRelease, nil
}

// Set Version
// Get watchNamespace
operatorNamespace, err := GetOperatorNamespace()
Expand Down

0 comments on commit 283d350

Please sign in to comment.