-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Mapping component versions to RHOAI releases #1299
base: incubation
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,18 @@ import ( | |
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/blang/semver/v4" | ||
"github.com/go-logr/logr" | ||
"github.com/joho/godotenv" | ||
operatorv1 "github.com/openshift/api/operator/v1" | ||
"github.com/operator-framework/api/pkg/lib/version" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
logf "sigs.k8s.io/controller-runtime/pkg/log" | ||
|
||
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/components" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" | ||
) | ||
|
@@ -72,6 +76,37 @@ func (c *CodeFlare) GetComponentName() string { | |
return ComponentName | ||
} | ||
|
||
func (c *CodeFlare) GetComponentStatus() ([]status.ComponentReleaseStatus, error) { | ||
var componentVersion semver.Version | ||
var repositoryURL string | ||
var upstreamReleases = make([]status.ComponentReleaseStatus, 0) | ||
|
||
env, err := godotenv.Read(filepath.Join(deploy.DefaultManifestPath, ComponentName, ".env")) | ||
|
||
if err != nil { | ||
fmt.Print("godotenv", err) | ||
return nil, err | ||
} | ||
if env != nil { | ||
componentVersion, err = semver.Parse(env["UPSTREAM_RELEASE_VERSION"]) | ||
|
||
if err != nil { | ||
fmt.Print("getEnv error", err) | ||
return nil, err | ||
} | ||
repositoryURL = env["REPOSITORY_URL"] | ||
} | ||
componentReleaseStatus := status.ComponentReleaseStatus{ | ||
Name: status.Platform(ComponentName), | ||
DisplayName: CodeflareOperator, | ||
Version: version.OperatorVersion{Version: componentVersion}, | ||
RepoURL: repositoryURL} | ||
|
||
fmt.Print("release object", componentReleaseStatus) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be removed |
||
upstreamReleases = append(upstreamReleases, componentReleaseStatus) | ||
return upstreamReleases, nil | ||
} | ||
|
||
func (c *CodeFlare) ReconcileComponent(ctx context.Context, | ||
cli client.Client, | ||
l logr.Logger, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import ( | |
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" | ||
) | ||
|
||
|
@@ -86,6 +87,7 @@ type ComponentInterface interface { | |
owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec, platform cluster.Platform, currentComponentStatus bool) error | ||
Cleanup(ctx context.Context, cli client.Client, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec) error | ||
GetComponentName() string | ||
GetComponentStatus() ([]status.ComponentReleaseStatus, error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be better to pass a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking a little bit more, it may even be moved in the |
||
GetManagementState() operatorv1.ManagementState | ||
OverrideManifests(ctx context.Context, platform cluster.Platform) error | ||
UpdatePrometheusConfig(cli client.Client, logger logr.Logger, enable bool, component string) error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
ComponentStatus
is meant to hold more information that the release status so I would not conflate different kind of information into aReleaseStaus
struct as it would be misleading.I would also recommend not to use a map as:
ComponentStatus
should be symmetric to thespec. Components
in term of naming