Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit c2f3a0a

Browse files
apiserver credential env support
Signed-off-by: greg pereira <[email protected]>
1 parent f5297e5 commit c2f3a0a

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

ui/.env.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
IL_UI_ADMIN_USERNAME=admin
22
IL_UI_ADMIN_PASSWORD=password
3-
IL_UI_API_SERVER_USERNAME=kitteh
4-
IL_UI_API_SERVER_PASSWORD=floofykittens
53
IL_UI_API_SERVER_URL=http://<IP>:8000
64
OAUTH_GITHUB_ID=<OAUTH_APP_ID>
75
OAUTH_GITHUB_SECRET=<OAUTH_APP_SECRET>
@@ -20,3 +18,7 @@ TLS_CLIENT_CERT_PATH=
2018
TLS_CLIENT_KEY_PATH=
2119
TLS_SERVER_CA_CERT_PATH=
2220
# Note, you cannot set TLS_INSECURE in this .env file, you have to pass it to the apiserver as a CLI arg
21+
22+
# API creds variables
23+
API_USER=
24+
API_PASS=

ui/apiserver/apiserver.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,15 @@ func main() {
526526
tlsServerCaCertPath := pflag.String("tls-server-ca-cert", "$HOME/server-ca-crt.pem2", "Path to the TLS server CA certificate. Defaults to 'server-ca-crt.pem2'")
527527
pflag.Parse()
528528

529-
/* Support env population with priority being:
529+
/* ENV support, most variabls take 3 options, with the following priority:
530530
1) flag
531531
2) env
532532
3) acceptable defaults
533533
*/
534534

535+
// NOTE: not all variables support all 3 methods, in which case they will be documented via comments.
536+
// With no comment, assume they support all 3.
537+
535538
// Precheck endpoint
536539
HOME := os.Getenv("HOME")
537540
if *preCheckEndpointURL == "" {
@@ -542,7 +545,8 @@ func main() {
542545
*preCheckEndpointURL = localEndpoint
543546
}
544547
}
545-
// TLS certPath
548+
549+
// TLS configurations
546550
if *tlsClientCertPath == "" {
547551
tlsClientCertPathEnvValue := os.Getenv("TLS_CLIENT_CERT_PATH")
548552
if tlsClientCertPathEnvValue != "" {
@@ -560,8 +564,27 @@ func main() {
560564
*tlsClientKeyPath = fmt.Sprintf("%s/client-tls-key.pem2", HOME)
561565
}
562566
}
567+
563568
// NOTE: TLSInsecure not settable by env, just apiserver cli flag or defaults to false
564569

570+
/* API credentials
571+
API creds support only apiserver cli flag or env, no default values.
572+
*/
573+
// API user
574+
if *apiUser == "" {
575+
apiUserEnvValue := os.Getenv("API_USER")
576+
if apiUserEnvValue != "" {
577+
*apiUser = apiUserEnvValue
578+
}
579+
}
580+
// API pass
581+
if *apiPass == "" {
582+
apiPassEnvValue := os.Getenv("API_PASS")
583+
if apiPassEnvValue != "" {
584+
*apiPass = apiPassEnvValue
585+
}
586+
}
587+
565588
logger := setupLogger(*debugFlag)
566589
defer logger.Sync()
567590

0 commit comments

Comments
 (0)