Files
cluster/internal/cmd/cmd.go
loveuer 9780a2b028 feat: add registry config, image upload/download, and OCI format support
Backend:
- Add registry_address configuration API (GET/POST)
- Add tar image upload with OCI and Docker format support
- Add image download with streaming optimization
- Fix blob download using c.Send (Fiber v3 SendStream bug)
- Add registry_address prefix stripping for all OCI v2 endpoints
- Add AGENTS.md for project documentation

Frontend:
- Add settings store with Snackbar notifications
- Add image upload dialog with progress bar
- Add download state tracking with multi-stage feedback
- Replace alert() with MUI Snackbar messages
- Display image names without registry_address prefix

🤖 Generated with [Qoder](https://qoder.com)
2025-11-10 16:28:58 +08:00

59 lines
1.6 KiB
Go

package cmd
import (
"context"
"log"
"gitea.loveuer.com/loveuer/cluster/internal/api"
"gitea.loveuer.com/loveuer/cluster/internal/opt"
"gitea.loveuer.com/loveuer/cluster/pkg/database/db"
"gitea.loveuer.com/loveuer/cluster/pkg/store"
"gitea.loveuer.com/loveuer/cluster/pkg/tool"
"github.com/spf13/cobra"
)
func Run(ctx context.Context) error {
_cmd := &cobra.Command{
Use: "cluster",
Short: "Cluster is a lightweight OCI registry implementation written in Go using Fiber v3.",
RunE: func(cmd *cobra.Command, args []string) error {
var (
err error
stopFns = []func(context.Context) error{}
stopApi func(context.Context) error
)
if err = opt.Init(cmd.Context()); err != nil {
return err
}
if err = db.Init(cmd.Context(), opt.GlobalDataDir); err != nil {
return err
}
if err = store.Init(cmd.Context(), opt.GlobalDataDir); err != nil {
return err
}
if stopApi, err = api.Init(cmd.Context(), opt.GlobalAddress, db.Default, store.Default); err != nil {
return err
}
stopFns = append(stopFns, stopApi)
<-cmd.Context().Done()
log.Println("[W] 收到退出信号,开始退出...")
tool.MustStop(tool.Timeout(5), stopFns...)
return nil
},
}
_cmd.PersistentFlags().BoolVar(&opt.GlobalDebug, "debug", false, "Enable debug mode")
_cmd.PersistentFlags().StringVarP(&opt.GlobalAddress, "address", "A", "0.0.0.0:9119", "API server listen address")
_cmd.PersistentFlags().StringVarP(&opt.GlobalDataDir, "data-dir", "D", "./x-storage", "Data directory for storing all data")
return _cmd.ExecuteContext(ctx)
}