@@ -110,7 +110,7 @@ export class ConfigService {
110
110
111
111
this . kubectl . updateKuberoConfig ( namespace , kuberoes ) ;
112
112
this . kubectl . updateKuberoSecret ( namespace , config . secrets ) ;
113
- this . setEnv ( config . secrets ) ;
113
+ this . setSecretEnv ( config . secrets ) ;
114
114
115
115
const m = {
116
116
name : 'updateSettings' ,
@@ -129,7 +129,7 @@ export class ConfigService {
129
129
return kuberoes ;
130
130
}
131
131
132
- private setEnv ( secrets : any ) {
132
+ private setSecretEnv ( secrets : any ) {
133
133
/*
134
134
for (const key in secrets) {
135
135
process.env[key] = secrets[key]
@@ -153,11 +153,32 @@ export class ConfigService {
153
153
process . env . OAUTH2_CLIENT_SECRET = secrets . OAUTH2_CLIENT_SECRET ;
154
154
}
155
155
156
+ private setEnvVar ( key : string , value : string ) : void {
157
+ if ( process . env [ key ] == undefined || process . env [ key ] == '' ) {
158
+ // Only set the environment variable if it is not already set or empty
159
+ process . env [ key ] = value ;
160
+ //this.logger.warn(`DEPRECATED v3.x.0: Environment variable ${key} set to ${value}. Use configmap instead.`);
161
+ }
162
+ }
163
+
164
+ private loadDeprecatedVarsToEnv ( config : IKuberoConfig ) : void {
165
+ // Update environment variables based on the config
166
+ this . setEnvVar ( 'KUBERO_READONLY' , config . kubero ?. readonly ? 'true' : 'false' ) ;
167
+ this . setEnvVar ( 'KUBERO_CONSOLE_ENABLED' , config . kubero ?. console ?. enabled ? 'true' : 'false' ) ;
168
+ this . setEnvVar ( 'KUBERO_ADMIN_DISABLED' , config . kubero ?. admin ?. disabled ? 'true' : 'false' ) ;
169
+ this . setEnvVar ( 'KUBERO_BANNER_SHOW' , config . kubero ?. banner ?. show ? 'true' : 'false' ) ;
170
+ this . setEnvVar ( 'KUBERO_BANNER_MESSAGE' , config . kubero ?. banner ?. message || 'Welcome to Kubero!' ) ;
171
+ this . setEnvVar ( 'KUBERO_BANNER_BGCOLOR' , config . kubero ?. banner ?. bgcolor || '#8560a963' ) ;
172
+ this . setEnvVar ( 'KUBERO_BANNER_FONTCOLOR' , config . kubero ?. banner ?. fontcolor || '#00000087' ) ;
173
+ this . setEnvVar ( 'KUBERO_TEMPLATES_ENABLED' , config . templates ?. enabled ? 'true' : 'false' ) ;
174
+ }
175
+
156
176
private reloadRunningConfig ( ) : void {
157
177
this . readConfig ( )
158
178
. then ( ( config ) => {
159
179
this . logger . debug ( 'Kubero config loaded' ) ;
160
180
this . runningConfig = config ;
181
+ this . loadDeprecatedVarsToEnv ( config ) ;
161
182
} )
162
183
. catch ( ( error ) => {
163
184
this . logger . error ( 'Error reading kuberoes config' ) ;
@@ -168,8 +189,10 @@ export class ConfigService {
168
189
private async readConfig ( ) : Promise < IKuberoConfig > {
169
190
if ( process . env . NODE_ENV === 'production' ) {
170
191
const kuberoCRD = await this . readConfigFromKubernetes ( ) ;
192
+ this . logger . debug ( 'Kubero config loaded from Kubernetes' ) ;
171
193
return kuberoCRD . kubero . config ;
172
194
} else {
195
+ this . logger . debug ( 'Kubero config loaded from filesystem (dev mode)' ) ;
173
196
return this . readConfigFromFS ( ) ;
174
197
}
175
198
}
@@ -244,7 +267,11 @@ export class ConfigService {
244
267
}
245
268
246
269
public checkAdminDisabled ( ) : boolean {
247
- return this . runningConfig . kubero . admin ?. disabled || false ;
270
+ if ( process . env . KUBERO_ADMIN_DISABLED === 'true' ) {
271
+ this . logger . warn ( 'Admin is disabled' ) ;
272
+ return true ;
273
+ }
274
+ return false ;
248
275
}
249
276
250
277
public async validateKubeconfig (
@@ -339,18 +366,32 @@ export class ConfigService {
339
366
}
340
367
341
368
getTemplateEnabled ( ) {
342
- return this . runningConfig . templates ?. enabled || false ;
369
+ if ( process . env . KUBERO_TEMPLATES_ENABLED == undefined ) {
370
+ return false ;
371
+ }
372
+ if ( process . env . KUBERO_TEMPLATES_ENABLED == 'true' ) {
373
+ return true ;
374
+ }
375
+ return false ;
343
376
}
344
377
345
378
public async getTemplateConfig ( ) {
346
379
return this . runningConfig . templates ;
347
380
}
348
381
349
- getConsoleEnabled ( ) {
350
- if ( this . runningConfig . kubero ?. console ?. enabled == undefined ) {
382
+ getConsoleEnabled ( ) : boolean {
383
+ if ( process . env . KUBERO_CONSOLE_ENABLED == undefined ) {
384
+ this . logger . warn (
385
+ 'KUBERO_CONSOLE_ENABLED is not set, defaulting to false' ,
386
+ ) ;
351
387
return false ;
352
388
}
353
- return this . runningConfig . kubero ?. console ?. enabled ;
389
+ if ( process . env . KUBERO_CONSOLE_ENABLED == 'true' ) {
390
+ this . logger . debug ( 'KUBERO_CONSOLE_ENABLED is set to true' ) ;
391
+ return true ;
392
+ }
393
+ this . logger . debug ( 'KUBERO_CONSOLE_ENABLED is set to false' ) ;
394
+ return false ;
354
395
}
355
396
356
397
setMetricsStatus ( status : boolean ) {
0 commit comments