working commit
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ mstored$(EXEEXT): $(mstored_SOURCES) $(EXTRA_mstored_SOURCES)
|
||||
env CGO_ENABLED=1 $(GO) build $(GOFLAGS) -o mstored$(EXEEXT) $(mstored_SOURCES)
|
||||
|
||||
run: $(mstored_SOURCES)
|
||||
cd cmd/mstored && env CGO_ENABLED=1 $(GO) run .
|
||||
cd cmd/mstored && env CGO_ENABLED=1 $(GO) run . -daemon=false
|
||||
|
||||
CWD=$(shell pwd)
|
||||
|
||||
|
||||
+1
-1
@@ -977,7 +977,7 @@ mstored$(EXEEXT): $(mstored_SOURCES) $(EXTRA_mstored_SOURCES)
|
||||
env CGO_ENABLED=1 $(GO) build $(GOFLAGS) -o mstored$(EXEEXT) $(mstored_SOURCES)
|
||||
|
||||
run: $(mstored_SOURCES)
|
||||
cd cmd/mstored && env CGO_ENABLED=1 $(GO) run .
|
||||
cd cmd/mstored && env CGO_ENABLED=1 $(GO) run . -daemon=false
|
||||
|
||||
format:
|
||||
@dirs=$$($(FIND) $(CWD) -name '*.go' | $(XARGS) -n1 dirname | $(SORT) | $(UNIQ)); \
|
||||
|
||||
@@ -109,20 +109,23 @@ func (conf *Config) ReadOptions() error {
|
||||
|
||||
// TODO: make local scope of flags
|
||||
|
||||
//flag.Int64Var(&conf.Service.Port, "port", conf.Service.Port, "listen port")
|
||||
//flag.BoolVar(&conf.AsDaemon, "daemon", conf.AsDaemon, "run as daemon")
|
||||
flagSet := flag.NewFlagSet(exename, flag.ExitOnError)
|
||||
flagSet.Int64Var(&conf.Service.Port, "port", conf.Service.Port, "listen port")
|
||||
flagSet.BoolVar(&conf.AsDaemon, "daemon", conf.AsDaemon, "run as daemon")
|
||||
|
||||
help := func() {
|
||||
fmt.Println("")
|
||||
fmt.Printf("Usage: %s [option]\n", exename)
|
||||
fmt.Println("")
|
||||
fmt.Println("Options:")
|
||||
flag.PrintDefaults()
|
||||
flagSet.PrintDefaults()
|
||||
fmt.Println("")
|
||||
}
|
||||
flag.Usage = help
|
||||
flag.Parse()
|
||||
|
||||
flagSet.Usage = help
|
||||
args := flag.Args()
|
||||
if len(args) > 1 {
|
||||
flagSet.Parse(args)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
+1
-4
@@ -32,12 +32,9 @@ type Grant struct {
|
||||
}
|
||||
|
||||
const (
|
||||
// Accounts
|
||||
// Accounts, grants
|
||||
RightReadAccounts = "readAccounts" // GetAccount, ListAccounts
|
||||
RightWriteAccounts = "writeAccounts" // CreateAccount, UpdateAccount, DeleteAccount
|
||||
// Frants
|
||||
RightReadGrants = "readGrants" // Like account operation
|
||||
RightWriteGrants = "writeGrants"
|
||||
// Files
|
||||
RightWriteFiles = "writeFiles" // FileInfo, GetFile, ListFiles
|
||||
RightReadFiles = "readFiles" // PutFile, DeleteFile
|
||||
|
||||
@@ -29,7 +29,7 @@ func (hand *Handler) CreateGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteGrants, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -62,7 +62,7 @@ func (hand *Handler) GetGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadGrants, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -95,7 +95,7 @@ func (hand *Handler) ListGrants(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadGrants, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -128,7 +128,7 @@ func (hand *Handler) UpdateGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteGrants, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
@@ -161,7 +161,7 @@ func (hand *Handler) DeleteGrant(rctx *router.Context) {
|
||||
}
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteGrants, "")
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteAccounts, "")
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Operation error: %v", err)
|
||||
hand.SendError(rctx, err)
|
||||
|
||||
+3
-3
@@ -148,11 +148,11 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Grants
|
||||
// Images
|
||||
grantDescr = &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightReadGrants,
|
||||
Right: descr.RightReadImages,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
@@ -166,7 +166,7 @@ func (db *Database) WriteInituser(ctx context.Context) error {
|
||||
grantDescr = &descr.Grant{
|
||||
ID: auxuuid.NewUUID(),
|
||||
AccountID: accountDescr.ID,
|
||||
Right: descr.RightWriteGrants,
|
||||
Right: descr.RightWriteImages,
|
||||
Pattern: ".*",
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func xxxTestFileLife(t *testing.T) {
|
||||
func TestFileLife(t *testing.T) {
|
||||
var srvport int64 = 10250
|
||||
srvdir := t.TempDir()
|
||||
srvaddr := fmt.Sprintf("mstore:mstore@127.0.0.1:%d", srvport)
|
||||
|
||||
+1
-2
@@ -23,7 +23,7 @@ import (
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
func xxxTestImageLife(t *testing.T) {
|
||||
func TestImageLife(t *testing.T) {
|
||||
var srvport int64 = 10250
|
||||
srvdir := t.TempDir()
|
||||
srvaddr := fmt.Sprintf("mstore:mstore@127.0.0.1:%d", srvport)
|
||||
@@ -103,5 +103,4 @@ func xxxTestImageLife(t *testing.T) {
|
||||
err := cli.DeleteImage(ctx, srvaddr+"/foo/test:123")
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user