@@ -9,58 +9,62 @@ import (
99)
1010
1111type config struct {
12- Addr string
13- PublicURL string
14- SlackClientID string
15- SlackClientSecret string
16- SlackSigningSecret string
17- OAuthStateSecret string
18- SlackAPIBaseURL string
19- SlackBotScopes []string
20- PresetID string
21- BackendBaseURL string
22- BackendFastAPIBaseURL string
23- BackendInternalToken string
24- SpritzBaseURL string
25- SpritzServiceToken string
26- PrincipalID string
27- HTTPTimeout time.Duration
28- DedupeTTL time.Duration
29- ProcessingTimeout time.Duration
30- SessionRetryInterval time.Duration
31- StatusMessageDelay time.Duration
32- RecoveryTimeout time.Duration
33- PromptRetryInitial time.Duration
34- PromptRetryMax time.Duration
35- PromptRetryTimeout time.Duration
12+ Addr string
13+ PublicURL string
14+ BrowserAuthHeaderID string
15+ BrowserAuthHeaderEmail string
16+ SlackClientID string
17+ SlackClientSecret string
18+ SlackSigningSecret string
19+ OAuthStateSecret string
20+ SlackAPIBaseURL string
21+ SlackBotScopes []string
22+ PresetID string
23+ BackendBaseURL string
24+ BackendFastAPIBaseURL string
25+ BackendInternalToken string
26+ SpritzBaseURL string
27+ SpritzServiceToken string
28+ PrincipalID string
29+ HTTPTimeout time.Duration
30+ DedupeTTL time.Duration
31+ ProcessingTimeout time.Duration
32+ SessionRetryInterval time.Duration
33+ StatusMessageDelay time.Duration
34+ RecoveryTimeout time.Duration
35+ PromptRetryInitial time.Duration
36+ PromptRetryMax time.Duration
37+ PromptRetryTimeout time.Duration
3638}
3739
3840func loadConfig () (config , error ) {
3941 cfg := config {
40- Addr : envOrDefault ("SPRITZ_SLACK_GATEWAY_ADDR" , ":8080" ),
41- PublicURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_GATEWAY_PUBLIC_URL" )), "/" ),
42- SlackClientID : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_CLIENT_ID" )),
43- SlackClientSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_CLIENT_SECRET" )),
44- SlackSigningSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SIGNING_SECRET" )),
45- OAuthStateSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_OAUTH_STATE_SECRET" )),
46- SlackAPIBaseURL : strings .TrimRight (envOrDefault ("SPRITZ_SLACK_API_BASE_URL" , "https://slack.com/api" ), "/" ),
47- SlackBotScopes : splitCSV (envOrDefault ("SPRITZ_SLACK_BOT_SCOPES" , "app_mentions:read,channels:history,chat:write,im:history,mpim:history" )),
48- PresetID : strings .TrimSpace (envOrDefault ("SPRITZ_SLACK_PRESET_ID" , defaultSlackPresetID )),
49- BackendBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_BASE_URL" )), "/" ),
50- BackendFastAPIBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_FASTAPI_BASE_URL" )), "/" ),
51- BackendInternalToken : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_INTERNAL_TOKEN" )),
52- SpritzBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SPRITZ_BASE_URL" )), "/" ),
53- SpritzServiceToken : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SPRITZ_SERVICE_TOKEN" )),
54- PrincipalID : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_PRINCIPAL_ID" )),
55- HTTPTimeout : parseDurationEnv ("SPRITZ_SLACK_HTTP_TIMEOUT" , 15 * time .Second ),
56- DedupeTTL : parseDurationEnv ("SPRITZ_SLACK_DEDUPE_TTL" , 10 * time .Minute ),
57- ProcessingTimeout : parseDurationEnv ("SPRITZ_SLACK_PROCESSING_TIMEOUT" , 120 * time .Second ),
58- SessionRetryInterval : parseDurationEnv ("SPRITZ_SLACK_SESSION_RETRY_INTERVAL" , time .Second ),
59- StatusMessageDelay : parseDurationEnv ("SPRITZ_SLACK_STATUS_MESSAGE_DELAY" , 5 * time .Second ),
60- RecoveryTimeout : parseDurationEnv ("SPRITZ_SLACK_RECOVERY_TIMEOUT" , 120 * time .Second ),
61- PromptRetryInitial : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_INITIAL" , 250 * time .Millisecond ),
62- PromptRetryMax : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_MAX" , 2 * time .Second ),
63- PromptRetryTimeout : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_TIMEOUT" , 8 * time .Second ),
42+ Addr : envOrDefault ("SPRITZ_SLACK_GATEWAY_ADDR" , ":8080" ),
43+ PublicURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_GATEWAY_PUBLIC_URL" )), "/" ),
44+ BrowserAuthHeaderID : envOrDefault ("SPRITZ_AUTH_HEADER_ID" , "X-Spritz-User-Id" ),
45+ BrowserAuthHeaderEmail : envOrDefault ("SPRITZ_AUTH_HEADER_EMAIL" , "X-Spritz-User-Email" ),
46+ SlackClientID : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_CLIENT_ID" )),
47+ SlackClientSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_CLIENT_SECRET" )),
48+ SlackSigningSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SIGNING_SECRET" )),
49+ OAuthStateSecret : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_OAUTH_STATE_SECRET" )),
50+ SlackAPIBaseURL : strings .TrimRight (envOrDefault ("SPRITZ_SLACK_API_BASE_URL" , "https://slack.com/api" ), "/" ),
51+ SlackBotScopes : splitCSV (envOrDefault ("SPRITZ_SLACK_BOT_SCOPES" , "app_mentions:read,channels:history,chat:write,im:history,mpim:history" )),
52+ PresetID : strings .TrimSpace (envOrDefault ("SPRITZ_SLACK_PRESET_ID" , defaultSlackPresetID )),
53+ BackendBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_BASE_URL" )), "/" ),
54+ BackendFastAPIBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_FASTAPI_BASE_URL" )), "/" ),
55+ BackendInternalToken : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_BACKEND_INTERNAL_TOKEN" )),
56+ SpritzBaseURL : strings .TrimRight (strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SPRITZ_BASE_URL" )), "/" ),
57+ SpritzServiceToken : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_SPRITZ_SERVICE_TOKEN" )),
58+ PrincipalID : strings .TrimSpace (os .Getenv ("SPRITZ_SLACK_PRINCIPAL_ID" )),
59+ HTTPTimeout : parseDurationEnv ("SPRITZ_SLACK_HTTP_TIMEOUT" , 15 * time .Second ),
60+ DedupeTTL : parseDurationEnv ("SPRITZ_SLACK_DEDUPE_TTL" , 10 * time .Minute ),
61+ ProcessingTimeout : parseDurationEnv ("SPRITZ_SLACK_PROCESSING_TIMEOUT" , 120 * time .Second ),
62+ SessionRetryInterval : parseDurationEnv ("SPRITZ_SLACK_SESSION_RETRY_INTERVAL" , time .Second ),
63+ StatusMessageDelay : parseDurationEnv ("SPRITZ_SLACK_STATUS_MESSAGE_DELAY" , 5 * time .Second ),
64+ RecoveryTimeout : parseDurationEnv ("SPRITZ_SLACK_RECOVERY_TIMEOUT" , 120 * time .Second ),
65+ PromptRetryInitial : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_INITIAL" , 250 * time .Millisecond ),
66+ PromptRetryMax : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_MAX" , 2 * time .Second ),
67+ PromptRetryTimeout : parseDurationEnv ("SPRITZ_SLACK_PROMPT_RETRY_TIMEOUT" , 8 * time .Second ),
6468 }
6569
6670 if cfg .PublicURL == "" {
0 commit comments