package console import ( "log" "github.com/carlosframework/platform/internal/appconfig" ) // appRegionsOn is spec ยง5.6: the switch AND a named home. func (s *Server) appRegionsOn() bool { return s.cfg.AppRegions && s.cfg.HomeRegion != "" } // expectedSecretsFP is the fingerprint a box must publish to receive // placed instances (spec R9): the console's own CARLOS_SECRETS_PUBKEY, // the key the CLI seals config to. "" means the console cannot judge, and // then no coded region is eligible for automatic placement. func (s *Server) expectedSecretsFP() string { if s.cfg.SecretsPub == "" { return "" } fp, err := appconfig.PublicFingerprint(s.cfg.SecretsPub) if err != nil { return "" } return fp } // appRegion reads the app's stored region through the test seam when one // is set. func (s *Server) appRegion(accountID int64, app string) (string, string, error) { if s.appRegionOf != nil { return s.appRegionOf(accountID, app) } return s.store.AppRegion(accountID, app) } // logRegionConfig names, once at startup, each configuration that leaves // part of the feature off. The secrets-key line does not depend on the // switch: the guess endpoint answers with the switch off too (R9). func logRegionConfig(cfg Config) { if cfg.AppRegions && cfg.HomeRegion == "" { log.Print("console: CONSOLE_APP_REGIONS=on but CONSOLE_HOME_REGION is unset, so app regions stay off until the home is named") } if cfg.SecretsPub == "" { log.Print("console: CARLOS_SECRETS_PUBKEY is unset, so no region outside the home can be chosen automatically") } }