@@ -8,14 +8,18 @@ import (
8
8
"path/filepath"
9
9
"strings"
10
10
11
+ "github.com/blang/semver/v4"
12
+ "github.com/joho/godotenv"
11
13
operatorv1 "github.com/openshift/api/operator/v1"
14
+ "github.com/operator-framework/api/pkg/lib/version"
12
15
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13
16
"sigs.k8s.io/controller-runtime/pkg/client"
14
17
logf "sigs.k8s.io/controller-runtime/pkg/log"
15
18
16
19
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
17
20
infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1"
18
21
"github.com/opendatahub-io/opendatahub-operator/v2/components"
22
+ "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
19
23
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
20
24
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
21
25
)
@@ -110,6 +114,33 @@ func (k *Kserve) GetComponentName() string {
110
114
return ComponentName
111
115
}
112
116
117
+ func (k * Kserve ) GetComponentStatus () ([]status.ComponentReleaseStatus , error ) {
118
+ var componentVersion semver.Version
119
+ var repositoryURL string
120
+ var upstreamReleases = make ([]status.ComponentReleaseStatus , 0 )
121
+
122
+ env , err := godotenv .Read (filepath .Join (deploy .DefaultManifestPath , ComponentName , ".env" ))
123
+
124
+ if err != nil {
125
+ return nil , err
126
+ }
127
+ if env != nil {
128
+ componentVersion , err = semver .Parse (env ["UPSTREAM_RELEASE_VERSION" ])
129
+
130
+ if err != nil {
131
+ return nil , err
132
+ }
133
+ repositoryURL = env ["REPOSITORY_URL" ]
134
+ }
135
+ componentReleaseStatus := status.ComponentReleaseStatus {
136
+ Name : status .Platform (ComponentName ),
137
+ DisplayName : ComponentName ,
138
+ Version : version.OperatorVersion {Version : componentVersion },
139
+ RepoURL : repositoryURL }
140
+ upstreamReleases = append (upstreamReleases , componentReleaseStatus )
141
+ return upstreamReleases , nil
142
+ }
143
+
113
144
func (k * Kserve ) ReconcileComponent (ctx context.Context , cli client.Client ,
114
145
owner metav1.Object , dscispec * dsciv1.DSCInitializationSpec , platform cluster.Platform , _ bool ) error {
115
146
l := logf .FromContext (ctx )
0 commit comments