Files
mtusi2026lab4/cmd/s3init/main.go
T

31 lines
591 B
Go

package main
import (
"context"
"fmt"
"messenger/internal/platform/config"
"messenger/internal/platform/s3store"
"os"
"time"
)
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, "bucket bootstrap failed:", err)
os.Exit(1)
}
}
func run() error {
cfg, err := config.LoadS3(os.LookupEnv)
if err != nil {
return err
}
s, err := s3store.New(cfg.Endpoint, cfg.Region, cfg.Bucket, cfg.AccessKey, cfg.SecretKey)
if err != nil {
return err
}
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
return s.Bootstrap(ctx)
}