@@ -7,13 +7,16 @@ import (
7
7
"path/filepath"
8
8
"strings"
9
9
10
+ "github.com/blang/semver/v4"
10
11
"github.com/go-logr/logr"
12
+ "github.com/joho/godotenv"
11
13
operatorv1 "github.com/openshift/api/operator/v1"
12
14
"gopkg.in/yaml.v2"
13
15
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
16
"sigs.k8s.io/controller-runtime/pkg/client"
15
17
16
18
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
19
+ "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
17
20
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
18
21
)
19
22
@@ -80,12 +83,18 @@ type ManifestsConfig struct {
80
83
SourcePath string `json:"sourcePath,omitempty"`
81
84
}
82
85
86
+ type ComponentReleaseDetails struct {
87
+ ComponentVersion semver.Version
88
+ RepositoryURL string
89
+ }
90
+
83
91
type ComponentInterface interface {
84
92
Init (ctx context.Context , platform cluster.Platform ) error
85
- ReconcileComponent (ctx context.Context , cli client.Client ,
86
- owner metav1. Object , DSCISpec * dsciv1. DSCInitializationSpec , platform cluster.Platform , currentComponentStatus bool ) error
93
+ ReconcileComponent (ctx context.Context , cli client.Client , owner client. Object , DSCISpec * dsciv1. DSCInitializationSpec ,
94
+ platform cluster.Platform , currentComponentStatus bool ) error
87
95
Cleanup (ctx context.Context , cli client.Client , owner metav1.Object , DSCISpec * dsciv1.DSCInitializationSpec ) error
88
96
GetComponentName () string
97
+ UpdateStatus (status * status.ComponentsStatus ) error
89
98
GetManagementState () operatorv1.ManagementState
90
99
OverrideManifests (ctx context.Context , platform cluster.Platform ) error
91
100
UpdatePrometheusConfig (cli client.Client , logger logr.Logger , enable bool , component string ) error
@@ -195,3 +204,23 @@ func (c *Component) UpdatePrometheusConfig(_ client.Client, logger logr.Logger,
195
204
196
205
return err
197
206
}
207
+
208
+ func (c * Component ) GetReleaseVersion (in * status.ComponentsStatus , DefaultManifestPath string , ComponentName string ) (ComponentReleaseDetails , error ) {
209
+ var componentVersion semver.Version
210
+ var repositoryURL string
211
+
212
+ env , err := godotenv .Read (filepath .Join (DefaultManifestPath , ComponentName , ".env" ))
213
+
214
+ if err != nil {
215
+ return ComponentReleaseDetails {}, err
216
+ }
217
+
218
+ componentVersion , err = semver .Parse (env ["RHOAI_RELEASE_VERSION" ])
219
+
220
+ if err != nil {
221
+ return ComponentReleaseDetails {}, err
222
+ }
223
+ repositoryURL = env ["REPOSITORY_URL" ]
224
+
225
+ return ComponentReleaseDetails {ComponentVersion : componentVersion , RepositoryURL : repositoryURL }, nil
226
+ }
0 commit comments