Skip to content

Commit 956a7bd

Browse files
comment readKeySecret logic
1 parent 2f72442 commit 956a7bd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,16 @@ func (h *Handler) prepareMux() *http.ServeMux {
187187
}
188188

189189
func readKeySecret() (string, string) {
190+
// We initialize keys & secrets from environment variables
190191
key := os.Getenv("LIVEKIT_KEY")
191192
secret := os.Getenv("LIVEKIT_SECRET")
193+
// We initialize potential key & secret path from environment variables
192194
key_path := os.Getenv("LIVEKIT_KEY_FROM_FILE")
193195
secret_path := os.Getenv("LIVEKIT_SECRET_FROM_FILE")
194196
key_secret_path := os.Getenv("LIVEKIT_KEY_FILE")
197+
198+
// If key_secret_path is set we read the file and split it into two parts
199+
// It takes over any other initialization
195200
if key_secret_path != "" {
196201
if keySecretBytes, err := os.ReadFile(key_secret_path); err != nil {
197202
log.Fatal(err)
@@ -204,6 +209,8 @@ func readKeySecret() (string, string) {
204209
secret = key_secrets[1]
205210
}
206211
} else {
212+
// If key_secret_path, we try to read the key and secret from files
213+
// If those files are not set, we return the key & secret from the environment variables
207214
if key_path != "" {
208215
if keyBytes, err := os.ReadFile(key_path); err != nil {
209216
log.Fatal(err)

0 commit comments

Comments
 (0)