Verify clean clone and restrict migration and reconciliation secrets
This commit is contained in:
+25
-25
@@ -60,18 +60,6 @@ func run() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cacheURL, err := secret("CACHE_URL_FILE")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cursorKey, err := secret("CURSOR_KEY_FILE")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
key, err := base64.RawURLEncoding.DecodeString(cursorKey)
|
||||
if err != nil || len(key) != 32 {
|
||||
return fmt.Errorf("invalid cursor key")
|
||||
}
|
||||
startup, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
pool, err := database.Open(startup, databaseURL)
|
||||
@@ -82,19 +70,6 @@ func run() error {
|
||||
if len(os.Args) == 2 && os.Args[1] == "migrate" {
|
||||
return database.Migrate(startup, pool)
|
||||
}
|
||||
opts, err := redis.ParseURL(cacheURL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid cache configuration")
|
||||
}
|
||||
opts.DialTimeout = 60 * time.Millisecond
|
||||
opts.ReadTimeout = 60 * time.Millisecond
|
||||
opts.WriteTimeout = 60 * time.Millisecond
|
||||
opts.PoolTimeout = 60 * time.Millisecond
|
||||
opts.ContextTimeoutEnabled = true
|
||||
opts.MaxRetries = -1
|
||||
opts.PoolSize = 10
|
||||
cache := redis.NewClient(opts)
|
||||
defer cache.Close()
|
||||
storeAccess, err := secret("S3_ACCESS_KEY_ID_FILE")
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -110,6 +85,31 @@ func run() error {
|
||||
if len(os.Args) > 1 && os.Args[1] == "reconcile" {
|
||||
return messenger.Reconcile(pool, objects, os.Args[2:])
|
||||
}
|
||||
cacheURL, err := secret("CACHE_URL_FILE")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cursorKey, err := secret("CURSOR_KEY_FILE")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
key, err := base64.RawURLEncoding.DecodeString(cursorKey)
|
||||
if err != nil || len(key) != 32 {
|
||||
return fmt.Errorf("invalid cursor key")
|
||||
}
|
||||
opts, err := redis.ParseURL(cacheURL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid cache configuration")
|
||||
}
|
||||
opts.DialTimeout = 60 * time.Millisecond
|
||||
opts.ReadTimeout = 60 * time.Millisecond
|
||||
opts.WriteTimeout = 60 * time.Millisecond
|
||||
opts.PoolTimeout = 60 * time.Millisecond
|
||||
opts.ContextTimeoutEnabled = true
|
||||
opts.MaxRetries = -1
|
||||
opts.PoolSize = 10
|
||||
cache := redis.NewClient(opts)
|
||||
defer cache.Close()
|
||||
api := messenger.New(pool, cache, key, ttl, log)
|
||||
api.SetObjectStore(objects)
|
||||
srv := &http.Server{Addr: net.JoinHostPort(host, port), Handler: api, ReadHeaderTimeout: 3 * time.Second, ReadTimeout: 35 * time.Second, WriteTimeout: 35 * time.Second, IdleTimeout: 30 * time.Second, MaxHeaderBytes: 16 << 10}
|
||||
|
||||
Reference in New Issue
Block a user