Skip to content

Commit

Permalink
feat: enable trustyai to use different manifests path (opendatahub-io…
Browse files Browse the repository at this point in the history
…#1218)

- trustyai has introduced overlays for odh and rhoai
- we can switch to use these than base

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw authored Sep 4, 2024
1 parent d57bb12 commit a990dea
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions components/trustyai/trustyai.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
var (
ComponentName = "trustyai"
ComponentPathName = "trustyai-service-operator"
Path = deploy.DefaultManifestPath + "/" + ComponentPathName + "/base"
PathUpstream = deploy.DefaultManifestPath + "/" + ComponentPathName + "/overlays/odh"
PathDownstream = deploy.DefaultManifestPath + "/" + ComponentPathName + "/overlays/rhoai"
OverridePath = ""
)

// Verifies that TrustyAI implements ComponentInterface.
Expand All @@ -45,7 +47,7 @@ func (t *TrustyAI) OverrideManifests(ctx context.Context, _ cluster.Platform) er
if manifestConfig.SourcePath != "" {
defaultKustomizePath = manifestConfig.SourcePath
}
Path = filepath.Join(deploy.DefaultManifestPath, ComponentPathName, defaultKustomizePath)
OverridePath = filepath.Join(deploy.DefaultManifestPath, ComponentPathName, defaultKustomizePath)
}
return nil
}
Expand All @@ -60,6 +62,13 @@ func (t *TrustyAI) ReconcileComponent(ctx context.Context, cli client.Client, lo
"trustyaiServiceImage": "RELATED_IMAGE_ODH_TRUSTYAI_SERVICE_IMAGE",
"trustyaiOperatorImage": "RELATED_IMAGE_ODH_TRUSTYAI_SERVICE_OPERATOR_IMAGE",
}
entryPath := map[cluster.Platform]string{
cluster.SelfManagedRhods: PathDownstream,
cluster.ManagedRhods: PathDownstream,
cluster.OpenDataHub: PathUpstream,
cluster.Unknown: PathUpstream,
}[platform]

l := t.ConfigComponentLogger(logger, ComponentName, dscispec)

enabled := t.GetManagementState() == operatorv1.Managed
Expand All @@ -71,15 +80,18 @@ func (t *TrustyAI) ReconcileComponent(ctx context.Context, cli client.Client, lo
if err := t.OverrideManifests(ctx, platform); err != nil {
return err
}
if OverridePath != "" {
entryPath = OverridePath
}
}
if (dscispec.DevFlags == nil || dscispec.DevFlags.ManifestsUri == "") && (t.DevFlags == nil || len(t.DevFlags.Manifests) == 0) {
if err := deploy.ApplyParams(Path, imageParamMap); err != nil {
return fmt.Errorf("failed to update image %s: %w", Path, err)
if err := deploy.ApplyParams(entryPath, imageParamMap); err != nil {
return fmt.Errorf("failed to update image %s: %w", entryPath, err)
}
}
}
// Deploy TrustyAI Operator
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, Path, dscispec.ApplicationsNamespace, t.GetComponentName(), enabled); err != nil {
if err := deploy.DeployManifestsFromPath(ctx, cli, owner, entryPath, dscispec.ApplicationsNamespace, t.GetComponentName(), enabled); err != nil {
return err
}
l.Info("apply manifests done")
Expand Down

0 comments on commit a990dea

Please sign in to comment.