diff --git a/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml b/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml index 5838346790b..78d57ab326a 100644 --- a/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml +++ b/config/crd/bases/datasciencecluster.opendatahub.io_datascienceclusters.yaml @@ -657,8 +657,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -673,8 +671,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -689,8 +685,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -705,8 +699,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -721,8 +713,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -737,8 +727,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -755,8 +743,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -771,8 +757,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -787,8 +771,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -803,8 +785,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: @@ -819,8 +799,6 @@ spec: properties: displayname: type: string - name: - type: string repourl: type: string version: diff --git a/controllers/status/status.go b/controllers/status/status.go index 01cae2a5eff..2a7f09c5356 100644 --- a/controllers/status/status.go +++ b/controllers/status/status.go @@ -19,14 +19,14 @@ limitations under the License. package status import ( + "os" "path/filepath" "github.com/blang/semver/v4" conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1" "github.com/operator-framework/api/pkg/lib/version" + "gopkg.in/yaml.v2" corev1 "k8s.io/api/core/v1" - - "github.com/opendatahub-io/opendatahub-operator/v2/pkg/common" ) // These constants represent the overall Phase as used by .Status.Phase. @@ -218,7 +218,6 @@ func RemoveComponentCondition(conditions *[]conditionsv1.Condition, component st // +k8s:deepcopy-gen=true type ComponentReleaseStatus struct { - Name string `json:"name,omitempty"` DisplayName string `json:"displayname,omitempty"` Version version.OperatorVersion `json:"version,omitempty"` RepoURL string `json:"repourl,omitempty"` @@ -300,35 +299,52 @@ type ComponentsStatus struct { Workbenches *WorkbenchesStatus `json:"workbenches,omitempty"` } +// +k8s:deepcopy-gen=true +type ReleaseFileMeta struct { + Releases []ComponentReleaseStatusMeta `json:"releases,omitempty"` +} + +// +k8s:deepcopy-gen=true +type ComponentReleaseStatusMeta struct { + DisplayName string `yaml:"displayname,omitempty"` + Version string `yaml:"version,omitempty"` + RepoURL string `yaml:"repourl,omitempty"` +} + // GetReleaseVersion read .env file and parse env variables delimiter by "=". // If version is not set or set to "", return empty {}. func GetReleaseVersion(defaultManifestPath string, componentName string) ComponentStatus { var componentVersion semver.Version - var repositoryURL string - var displayName string - - env, err := common.ParseParams(filepath.Join(defaultManifestPath, componentName, ".env")) + var releaseInfo ReleaseFileMeta + var releaseStatus ComponentReleaseStatus + componentReleaseStatus := make([]ComponentReleaseStatus, 0) + yamlData, err := os.ReadFile(filepath.Join(defaultManifestPath, componentName, "releases.yaml")) if err != nil { return ComponentStatus{} } - componentVersion, err = semver.Parse(env["RHOAI_RELEASE_VERSION"]) - + err = yaml.Unmarshal(yamlData, &releaseInfo) if err != nil { return ComponentStatus{} } - repositoryURL = env["REPOSITORY_URL"] - displayName = env["DISPLAY_NAME"] + for _, release := range releaseInfo.Releases { + componentVersion, err = semver.Parse(release.Version) - return ComponentStatus{ - Releases: []ComponentReleaseStatus{{ - Name: componentName, - DisplayName: displayName, + if err != nil { + return ComponentStatus{} + } + + releaseStatus = ComponentReleaseStatus{ + DisplayName: release.DisplayName, Version: version.OperatorVersion{Version: componentVersion}, - RepoURL: repositoryURL, - }, - }, + RepoURL: release.RepoURL, + } + componentReleaseStatus = append(componentReleaseStatus, releaseStatus) + } + + return ComponentStatus{ + Releases: componentReleaseStatus, } } diff --git a/controllers/status/zz_generated.deepcopy.go b/controllers/status/zz_generated.deepcopy.go index fa400fcc7eb..ddbf90d7e93 100644 --- a/controllers/status/zz_generated.deepcopy.go +++ b/controllers/status/zz_generated.deepcopy.go @@ -54,6 +54,21 @@ func (in *ComponentReleaseStatus) DeepCopy() *ComponentReleaseStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComponentReleaseStatusMeta) DeepCopyInto(out *ComponentReleaseStatusMeta) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentReleaseStatusMeta. +func (in *ComponentReleaseStatusMeta) DeepCopy() *ComponentReleaseStatusMeta { + if in == nil { + return nil + } + out := new(ComponentReleaseStatusMeta) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ComponentStatus) DeepCopyInto(out *ComponentStatus) { *out = *in @@ -258,6 +273,26 @@ func (in *RayStatus) DeepCopy() *RayStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ReleaseFileMeta) DeepCopyInto(out *ReleaseFileMeta) { + *out = *in + if in.Releases != nil { + in, out := &in.Releases, &out.Releases + *out = make([]ComponentReleaseStatusMeta, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReleaseFileMeta. +func (in *ReleaseFileMeta) DeepCopy() *ReleaseFileMeta { + if in == nil { + return nil + } + out := new(ReleaseFileMeta) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TrainingOperatorStatus) DeepCopyInto(out *TrainingOperatorStatus) { *out = *in