feat: complete OCI registry implementation with docker push/pull support
A lightweight OCI (Open Container Initiative) registry implementation written in Go.
This commit is contained in:
49
internal/cmd/cmd.go
Normal file
49
internal/cmd/cmd.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"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"
|
||||
"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
|
||||
)
|
||||
|
||||
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 err = api.Init(cmd.Context(), opt.GlobalAddress, db.Default, store.Default); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
<-cmd.Context().Done()
|
||||
|
||||
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.Execute()
|
||||
}
|
||||
Reference in New Issue
Block a user