feat: source Garmin credentials from the profile instead of env vars
This commit is contained in:
@@ -30,11 +30,16 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
profile, err := db.GetProfile(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("load profile: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
garminClient := garmin.NewClient(garmin.Config{
|
garminClient := garmin.NewClient(garmin.Config{
|
||||||
PythonPath: cfg.GarminPythonPath,
|
PythonPath: cfg.GarminPythonPath,
|
||||||
ServerPath: cfg.GarminServerPath,
|
ServerPath: cfg.GarminServerPath,
|
||||||
GarminEmail: cfg.GarminEmail,
|
GarminEmail: profile.GarminEmail,
|
||||||
GarminPassword: cfg.GarminPassword,
|
GarminPassword: profile.GarminPassword,
|
||||||
TokenStorePath: cfg.GarminTokenStore,
|
TokenStorePath: cfg.GarminTokenStore,
|
||||||
})
|
})
|
||||||
defer garminClient.Close()
|
defer garminClient.Close()
|
||||||
@@ -42,7 +47,6 @@ func main() {
|
|||||||
syncSvc := appsync.NewService(garminClient, db, appsync.Config{
|
syncSvc := appsync.NewService(garminClient, db, appsync.Config{
|
||||||
BackfillHorizonDays: cfg.BackfillHorizonDays,
|
BackfillHorizonDays: cfg.BackfillHorizonDays,
|
||||||
MinConfidence: cfg.MinConfidence,
|
MinConfidence: cfg.MinConfidence,
|
||||||
MaxHR: cfg.MaxHR,
|
|
||||||
}, nil)
|
}, nil)
|
||||||
|
|
||||||
server := api.NewServer(db, garminClient, syncSvc)
|
server := api.NewServer(db, garminClient, syncSvc)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// Package config loads smartrund's runtime configuration from environment
|
// Package config loads smartrund's runtime infrastructure configuration
|
||||||
// variables (a single-user local app has no need for a config file/flags
|
// from environment variables (paths and process settings that don't belong
|
||||||
// beyond this).
|
// in the user-editable profile). Garmin credentials and every tunable
|
||||||
|
// analysis-engine parameter live in the profile (internal/store.Profile)
|
||||||
|
// instead -- see docs/superpowers/specs/2026-07-17-profile-taxonomy-analysis-engine-design.md.
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -10,7 +12,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config holds everything smartrund needs to start.
|
// Config holds smartrund's process-level configuration.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Addr is the HTTP listen address, e.g. ":8080".
|
// Addr is the HTTP listen address, e.g. ":8080".
|
||||||
Addr string
|
Addr string
|
||||||
@@ -21,13 +23,10 @@ type Config struct {
|
|||||||
GarminPythonPath string
|
GarminPythonPath string
|
||||||
// GarminServerPath is mcp-garmin's server.py.
|
// GarminServerPath is mcp-garmin's server.py.
|
||||||
GarminServerPath string
|
GarminServerPath string
|
||||||
GarminEmail string
|
|
||||||
GarminPassword string
|
|
||||||
// GarminTokenStore, if set, overrides mcp-garmin's default ~/.garth
|
// GarminTokenStore, if set, overrides mcp-garmin's default ~/.garth
|
||||||
// session cache location.
|
// session cache location.
|
||||||
GarminTokenStore string
|
GarminTokenStore string
|
||||||
|
|
||||||
MaxHR float64
|
|
||||||
MinConfidence float64
|
MinConfidence float64
|
||||||
BackfillHorizonDays int
|
BackfillHorizonDays int
|
||||||
IncrementalSyncEvery time.Duration
|
IncrementalSyncEvery time.Duration
|
||||||
@@ -41,10 +40,7 @@ func Load() (Config, error) {
|
|||||||
DBPath: getEnvDefault("SMARTRUN_DB_PATH", "smartrun.db"),
|
DBPath: getEnvDefault("SMARTRUN_DB_PATH", "smartrun.db"),
|
||||||
GarminPythonPath: os.Getenv("MCP_GARMIN_PYTHON"),
|
GarminPythonPath: os.Getenv("MCP_GARMIN_PYTHON"),
|
||||||
GarminServerPath: os.Getenv("MCP_GARMIN_SERVER"),
|
GarminServerPath: os.Getenv("MCP_GARMIN_SERVER"),
|
||||||
GarminEmail: os.Getenv("GARMIN_EMAIL"),
|
|
||||||
GarminPassword: os.Getenv("GARMIN_PASSWORD"),
|
|
||||||
GarminTokenStore: os.Getenv("GARMIN_TOKENSTORE"),
|
GarminTokenStore: os.Getenv("GARMIN_TOKENSTORE"),
|
||||||
MaxHR: getEnvFloat("SMARTRUN_MAX_HR", 190),
|
|
||||||
MinConfidence: getEnvFloat("SMARTRUN_MIN_CONFIDENCE", 0.6),
|
MinConfidence: getEnvFloat("SMARTRUN_MIN_CONFIDENCE", 0.6),
|
||||||
BackfillHorizonDays: getEnvInt("SMARTRUN_BACKFILL_HORIZON_DAYS", 3*365),
|
BackfillHorizonDays: getEnvInt("SMARTRUN_BACKFILL_HORIZON_DAYS", 3*365),
|
||||||
IncrementalSyncEvery: getEnvDuration("SMARTRUN_INCREMENTAL_SYNC_EVERY", 6*time.Hour),
|
IncrementalSyncEvery: getEnvDuration("SMARTRUN_INCREMENTAL_SYNC_EVERY", 6*time.Hour),
|
||||||
@@ -56,9 +52,6 @@ func Load() (Config, error) {
|
|||||||
if cfg.GarminServerPath == "" {
|
if cfg.GarminServerPath == "" {
|
||||||
return cfg, fmt.Errorf("MCP_GARMIN_SERVER is required (path to mcp-garmin's server.py)")
|
return cfg, fmt.Errorf("MCP_GARMIN_SERVER is required (path to mcp-garmin's server.py)")
|
||||||
}
|
}
|
||||||
if cfg.GarminEmail == "" || cfg.GarminPassword == "" {
|
|
||||||
return cfg, fmt.Errorf("GARMIN_EMAIL and GARMIN_PASSWORD are required")
|
|
||||||
}
|
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user