@@ -20,9 +20,9 @@ import (
2020 "github.com/eclipse-che/che-operator/pkg/common/infrastructure"
2121 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2222 "k8s.io/apimachinery/pkg/runtime"
23+ ctrl "sigs.k8s.io/controller-runtime"
2324
2425 util "github.com/eclipse-che/che-operator/pkg/common/utils"
25- "github.com/sirupsen/logrus"
2626 appsv1 "k8s.io/api/apps/v1"
2727)
2828
@@ -52,17 +52,23 @@ var (
5252 defaultDevfileRegistryExternalDevfileRegistries string
5353
5454 initialized = false
55+
56+ log = ctrl .Log .WithName ("defaults" )
5557)
5658
5759func InitializeForTesting (operatorDeploymentFilePath string ) {
5860 operatorDeployment := & appsv1.Deployment {}
5961 if err := util .ReadObjectInto (operatorDeploymentFilePath , operatorDeployment ); err != nil {
60- logrus .Fatalf ("Failed to read operator deployment from '%s', cause: %v" , operatorDeploymentFilePath , err )
62+ log .Error (err , "Error reading operator deployment" )
63+ os .Exit (1 )
6164 }
6265
6366 for _ , container := range operatorDeployment .Spec .Template .Spec .Containers {
6467 for _ , env := range container .Env {
65- os .Setenv (env .Name , env .Value )
68+ err := os .Setenv (env .Name , env .Value )
69+ if err != nil {
70+ log .Error (err , "Error setting env variable" , "name" , env .Name )
71+ }
6672 }
6773 }
6874
@@ -109,191 +115,192 @@ func Initialize() {
109115func ensureEnv (name string ) string {
110116 value := os .Getenv (name )
111117 if value == "" {
112- logrus .Fatalf ("Failed to initialize default value: '%s'. Environment variable not found." , name )
118+ log .Error (fmt .Errorf ("environment variable %s not set" , name ), "unable to determine required environment variable" )
119+ os .Exit (1 )
113120 }
114121
115122 return value
116123}
117124
118125func GetCheServerImage (checluster interface {}) string {
119126 if ! initialized {
120- logrus . Fatalf ( "Operator defaults are not initialized." )
127+ Initialize ( )
121128 }
122129
123130 return PatchDefaultImageName (checluster , defaultCheServerImage )
124131}
125132
126133func GetCheTLSSecretsCreationJobImage () string {
127134 if ! initialized {
128- logrus . Fatalf ( "Operator defaults are not initialized." )
135+ Initialize ( )
129136 }
130137
131138 return defaultCheTLSSecretsCreationJobImage
132139}
133140
134141func GetCheVersion () string {
135142 if ! initialized {
136- logrus . Fatalf ( "Operator defaults are not initialized." )
143+ Initialize ( )
137144 }
138145
139146 return defaultCheVersion
140147}
141148
142149func GetDashboardImage (checluster interface {}) string {
143150 if ! initialized {
144- logrus . Fatalf ( "Operator defaults are not initialized." )
151+ Initialize ( )
145152 }
146153
147154 return PatchDefaultImageName (checluster , defaultDashboardImage )
148155}
149156
150157func GetPluginRegistryImage (checluster interface {}) string {
151158 if ! initialized {
152- logrus . Fatalf ( "Operator defaults are not initialized." )
159+ Initialize ( )
153160 }
154161
155162 return PatchDefaultImageName (checluster , defaultPluginRegistryImage )
156163}
157164
158165func GetGatewayImage (checluster interface {}) string {
159166 if ! initialized {
160- logrus . Fatalf ( "Operator defaults are not initialized." )
167+ Initialize ( )
161168 }
162169
163170 return PatchDefaultImageName (checluster , defaultSingleHostGatewayImage )
164171}
165172
166173func GetGatewayConfigSidecarImage (checluster interface {}) string {
167174 if ! initialized {
168- logrus . Fatalf ( "Operator defaults are not initialized." )
175+ Initialize ( )
169176 }
170177
171178 return PatchDefaultImageName (checluster , defaultSingleHostGatewayConfigSidecarImage )
172179}
173180
174181func GetGatewayKubernetesAuthenticationSidecarImage (checluster interface {}) string {
175182 if ! initialized {
176- logrus . Fatalf ( "Operator defaults are not initialized." )
183+ Initialize ( )
177184 }
178185
179186 return PatchDefaultImageName (checluster , defaultGatewayKubernetesAuthenticationSidecarImage )
180187}
181188
182189func GetGatewayKubernetesAuthorizationSidecarImage (checluster interface {}) string {
183190 if ! initialized {
184- logrus . Fatalf ( "Operator defaults are not initialized." )
191+ Initialize ( )
185192 }
186193
187194 return PatchDefaultImageName (checluster , defaultGatewayKubernetesAuthorizationSidecarImage )
188195}
189196
190197func GetGatewayOpenShiftAuthenticationSidecarImage (checluster interface {}) string {
191198 if ! initialized {
192- logrus . Fatalf ( "Operator defaults are not initialized." )
199+ Initialize ( )
193200 }
194201
195202 return PatchDefaultImageName (checluster , defaultGatewayOpenShiftAuthenticationSidecarImage )
196203}
197204
198205func GetGatewayOpenShiftAuthorizationSidecarImage (checluster interface {}) string {
199206 if ! initialized {
200- logrus . Fatalf ( "Operator defaults are not initialized." )
207+ Initialize ( )
201208 }
202209
203210 return PatchDefaultImageName (checluster , defaultGatewayOpenShiftAuthorizationSidecarImage )
204211}
205212
206213func GetCheFlavor () string {
207214 if ! initialized {
208- logrus . Fatalf ( "Operator defaults are not initialized." )
215+ Initialize ( )
209216 }
210217
211218 return defaultCheFlavor
212219}
213220
214221func GetConsoleLinkName () string {
215222 if ! initialized {
216- logrus . Fatalf ( "Operator defaults are not initialized." )
223+ Initialize ( )
217224 }
218225
219226 return defaultConsoleLinkName
220227}
221228
222229func GetConsoleLinkDisplayName () string {
223230 if ! initialized {
224- logrus . Fatalf ( "Operator defaults are not initialized." )
231+ Initialize ( )
225232 }
226233
227234 return defaultConsoleLinkDisplayName
228235}
229236
230237func GetConsoleLinkSection () string {
231238 if ! initialized {
232- logrus . Fatalf ( "Operator defaults are not initialized." )
239+ Initialize ( )
233240 }
234241
235242 return defaultConsoleLinkSection
236243}
237244
238245func GetConsoleLinkImage () string {
239246 if ! initialized {
240- logrus . Fatalf ( "Operator defaults are not initialized." )
247+ Initialize ( )
241248 }
242249
243250 return defaultsConsoleLinkImage
244251}
245252
246253func GetDevfileRegistryExternalDevfileRegistries () string {
247254 if ! initialized {
248- logrus . Fatalf ( "Operator defaults are not initialized." )
255+ Initialize ( )
249256 }
250257
251258 return defaultDevfileRegistryExternalDevfileRegistries
252259}
253260
254261func GetPluginRegistryOpenVSXURL () string {
255262 if ! initialized {
256- logrus . Fatalf ( "Operator defaults are not initialized." )
263+ Initialize ( )
257264 }
258265
259266 return defaultPluginRegistryOpenVSXURL
260267}
261268
262269func GetDashboardHeaderMessageText () string {
263270 if ! initialized {
264- logrus . Fatalf ( "Operator defaults are not initialized." )
271+ Initialize ( )
265272 }
266273
267274 return defaultDashboardHeaderMessageText
268275}
269276
270277func GetDevEnvironmentsDefaultEditor () string {
271278 if ! initialized {
272- logrus . Fatalf ( "Operator defaults are not initialized." )
279+ Initialize ( )
273280 }
274281
275282 return defaultDevEnvironmentsDefaultEditor
276283}
277284
278285func GetDevEnvironmentsDefaultComponents () string {
279286 if ! initialized {
280- logrus . Fatalf ( "Operator defaults are not initialized." )
287+ Initialize ( )
281288 }
282289
283290 return defaultDevEnvironmentsDefaultComponents
284291}
285292
286293func GetDevEnvironmentsContainerSecurityContext () string {
287294 if ! initialized {
288- logrus . Fatalf ( "Operator defaults are not initialized." )
295+ Initialize ( )
289296 }
290297
291298 return defaultDevEnvironmentsContainerSecurityContext
292299}
293300
294301func GetDevEnvironmentsDisableContainerBuildCapabilities () string {
295302 if ! initialized {
296- logrus . Fatalf ( "Operator defaults are not initialized." )
303+ Initialize ( )
297304 }
298305
299306 return defaultDevEnvironmentsDisableContainerBuildCapabilities
0 commit comments