8
8
"path/filepath"
9
9
"strings"
10
10
11
+ "github.com/blang/semver/v4"
11
12
"github.com/go-logr/logr"
13
+ "github.com/joho/godotenv"
12
14
operatorv1 "github.com/openshift/api/operator/v1"
13
15
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
16
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -17,6 +19,7 @@ import (
17
19
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
18
20
infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1"
19
21
"github.com/opendatahub-io/opendatahub-operator/v2/components"
22
+ "github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
20
23
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
21
24
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
22
25
)
@@ -111,6 +114,37 @@ func (k *Kserve) GetComponentName() string {
111
114
return ComponentName
112
115
}
113
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
+ fmt .Print ("godotenv" , err )
126
+ return nil , err
127
+ }
128
+ if env != nil {
129
+ componentVersion , err = semver .Parse (env ["UPSTREAM_RELEASE_VERSION" ])
130
+
131
+ if err != nil {
132
+ fmt .Print ("getEnv error" , err )
133
+ return nil , err
134
+ }
135
+ repositoryURL = env ["REPOSITORY_URL" ]
136
+ }
137
+ componentReleaseStatus := status.ComponentReleaseStatus {
138
+ Name : status .Platform (ComponentName ),
139
+ DisplayName : ComponentName ,
140
+ Version : componentVersion ,
141
+ RepoURL : repositoryURL }
142
+
143
+ fmt .Print ("release object" , componentReleaseStatus )
144
+ upstreamReleases = append (upstreamReleases , componentReleaseStatus )
145
+ return upstreamReleases , nil
146
+ }
147
+
114
148
func (k * Kserve ) ReconcileComponent (ctx context.Context , cli client.Client ,
115
149
l logr.Logger , owner metav1.Object , dscispec * dsciv1.DSCInitializationSpec , platform cluster.Platform , _ bool ) error {
116
150
enabled := k .GetManagementState () == operatorv1 .Managed
0 commit comments