working commit
This commit is contained in:
+2
-5
@@ -113,10 +113,9 @@ if SYSTEMD
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
format:
|
||||
for dir in $$(find app pkg cmd -type d); do \
|
||||
(cd $$dir && $(GO) fmt .); \
|
||||
@for dir in $$(find app pkg cmd -type d); do \
|
||||
(cd $$dir && echo "====$$dir====" && $(GO) fmt .); \
|
||||
done
|
||||
|
||||
run:
|
||||
@@ -137,8 +136,6 @@ clean-local:
|
||||
rm -f cmd/mbasectl/mbasectl
|
||||
rm -f cmd/mbased/mbased
|
||||
rm -f cmd/mbasedump/mbasedump
|
||||
rm -f cmd/mbaselocal/mbaselocal
|
||||
rm -f cmd/mbaserestore/mbaserestore
|
||||
rm -rf autom4te.cache
|
||||
rm -rf tmp/
|
||||
|
||||
|
||||
+2
-4
@@ -910,8 +910,8 @@ install-data-local:
|
||||
@LINUX_OS_TRUE@@SYSTEMD_TRUE@ $(INSTALL_DATA) initrc/mbased.service $(DESTDIR)$(LINUX_SYSTEMDDIR)
|
||||
|
||||
format:
|
||||
for dir in $$(find app pkg cmd -type d); do \
|
||||
(cd $$dir && $(GO) fmt .); \
|
||||
@for dir in $$(find app pkg cmd -type d); do \
|
||||
(cd $$dir && echo "====$$dir====" && $(GO) fmt .); \
|
||||
done
|
||||
|
||||
run:
|
||||
@@ -931,8 +931,6 @@ clean-local:
|
||||
rm -f cmd/mbasectl/mbasectl
|
||||
rm -f cmd/mbased/mbased
|
||||
rm -f cmd/mbasedump/mbasedump
|
||||
rm -f cmd/mbaselocal/mbaselocal
|
||||
rm -f cmd/mbaserestore/mbaserestore
|
||||
rm -rf autom4te.cache
|
||||
rm -rf tmp/
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/auxuuid"
|
||||
"mbase/pkg/auxpwd"
|
||||
"mbase/pkg/auxuuid"
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/mbctl"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/auxuuid"
|
||||
"mbase/pkg/auxpwd"
|
||||
"mbase/pkg/auxuuid"
|
||||
"mbase/pkg/descr"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/auxuuid"
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/mbctl"
|
||||
)
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
|
||||
"mbase/app/config"
|
||||
"mbase/app/maindb"
|
||||
"mbase/pkg/descr"
|
||||
"mbase/app/operator"
|
||||
"mbase/pkg/aux509"
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/logger"
|
||||
"mbase/pkg/netacl"
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ func (util *Util) createAccount(params createAccountParams) (createAccountResult
|
||||
*/
|
||||
return res, err
|
||||
}
|
||||
|
||||
/*
|
||||
func (util *Util) CreateAccount(ctx context.Context, operID string) (*mbctl.CreateAccountResult, error) {
|
||||
var err error
|
||||
|
||||
@@ -7,15 +7,21 @@ import (
|
||||
"mbase/app/operator"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultHostname = "localhost:1025"
|
||||
)
|
||||
|
||||
type Util struct {
|
||||
oper *operator.Logic
|
||||
rootCmd *cobra.Command
|
||||
subCmd *cobra.Command
|
||||
createAccountParams createAccountParams
|
||||
listAccountsParams listAccountsParams
|
||||
updateAccountParams updateAccountParams
|
||||
deleteAccountParams deleteAccountParams
|
||||
commonParams CommonParams
|
||||
}
|
||||
|
||||
func NewUtil(oper *operator.Logic) *Util {
|
||||
@@ -24,17 +30,33 @@ func NewUtil(oper *operator.Logic) *Util {
|
||||
}
|
||||
}
|
||||
|
||||
type CommonParams struct {
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
func (util *Util) GetRooCmd() *cobra.Command {
|
||||
return util.rootCmd
|
||||
return util.subCmd
|
||||
}
|
||||
|
||||
func (util *Util) BuildCmds() *cobra.Command {
|
||||
rootCmd := &cobra.Command{
|
||||
subCmd := &cobra.Command{
|
||||
Use: "account",
|
||||
Short: "\nAccount operations",
|
||||
SilenceUsage: true,
|
||||
}
|
||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
subCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
|
||||
subCmd.PersistentFlags().StringVarP(&util.commonParams.Username, "user", "U", util.commonParams.Username, "Username")
|
||||
subCmd.PersistentFlags().StringVarP(&util.commonParams.Password, "pass", "P", util.commonParams.Password, "Password")
|
||||
subCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||
|
||||
vi := viper.New()
|
||||
vi.SetEnvPrefix("mstore")
|
||||
vi.BindEnv("user")
|
||||
vi.BindEnv("pass")
|
||||
util.commonParams.Username = vi.GetString("user")
|
||||
util.commonParams.Password = vi.GetString("pass")
|
||||
|
||||
var createAccountCmd = &cobra.Command{
|
||||
Use: "create name password ",
|
||||
@@ -42,14 +64,14 @@ func (util *Util) BuildCmds() *cobra.Command {
|
||||
Args: cobra.ExactArgs(2),
|
||||
Run: util.CreateAccount,
|
||||
}
|
||||
rootCmd.AddCommand(createAccountCmd)
|
||||
subCmd.AddCommand(createAccountCmd)
|
||||
|
||||
var listAccountsCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List accounts",
|
||||
Run: util.ListAccounts,
|
||||
}
|
||||
rootCmd.AddCommand(listAccountsCmd)
|
||||
subCmd.AddCommand(listAccountsCmd)
|
||||
|
||||
var updateAccountsCmd = &cobra.Command{
|
||||
Use: "update name|id",
|
||||
@@ -57,7 +79,7 @@ func (util *Util) BuildCmds() *cobra.Command {
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: util.UpdateAccount,
|
||||
}
|
||||
rootCmd.AddCommand(updateAccountsCmd)
|
||||
subCmd.AddCommand(updateAccountsCmd)
|
||||
|
||||
var deleteAccountCmd = &cobra.Command{
|
||||
Use: "delete name|id",
|
||||
@@ -65,8 +87,8 @@ func (util *Util) BuildCmds() *cobra.Command {
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: util.DeleteAccount,
|
||||
}
|
||||
rootCmd.AddCommand(deleteAccountCmd)
|
||||
subCmd.AddCommand(deleteAccountCmd)
|
||||
|
||||
util.rootCmd = rootCmd
|
||||
return util.rootCmd
|
||||
util.subCmd = subCmd
|
||||
return util.subCmd
|
||||
}
|
||||
|
||||
@@ -5,19 +5,20 @@ package grant
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"mbase/app/operator"
|
||||
)
|
||||
|
||||
type Util struct {
|
||||
lg *operator.Logic
|
||||
oper *operator.Logic
|
||||
rootCmd *cobra.Command
|
||||
createGrantParams createGrantParams
|
||||
deleteGrantParams deleteGrantParams
|
||||
}
|
||||
|
||||
func NewUtil() *Util {
|
||||
return &Util{}
|
||||
func NewUtil(oper *operator.Logic) *Util {
|
||||
return &Util{
|
||||
oper: oper,
|
||||
}
|
||||
}
|
||||
|
||||
func (util *Util) GetRooCmd() *cobra.Command {
|
||||
@@ -51,4 +52,3 @@ func (util *Util) BuildCmds() *cobra.Command {
|
||||
util.rootCmd = rootCmd
|
||||
return util.rootCmd
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,11 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"mbase/cmd/mbaseadmin/account"
|
||||
"mbase/app/config"
|
||||
"mbase/app/maindb"
|
||||
"mbase/app/operator"
|
||||
"mbase/cmd/mbaseadmin/account"
|
||||
"mbase/cmd/mbaseadmin/grant"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -70,6 +71,9 @@ func (util *Util) Build() error {
|
||||
accountUtil := account.NewUtil(util.lg)
|
||||
rootCmd.AddCommand(accountUtil.BuildCmds())
|
||||
|
||||
grantUtil := grant.NewUtil(util.lg)
|
||||
rootCmd.AddCommand(grantUtil.BuildCmds())
|
||||
|
||||
util.rootCmd = rootCmd
|
||||
return err
|
||||
}
|
||||
@@ -80,4 +84,3 @@ func (util *Util) Exec(args []string) error {
|
||||
err = util.rootCmd.Execute()
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -65,4 +65,3 @@ func (util *Util) BuildCmds() *cobra.Command {
|
||||
util.rootCmd = rootCmd
|
||||
return util.rootCmd
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
"mbase/app/config"
|
||||
"mbase/app/maindb"
|
||||
"mbase/pkg/descr"
|
||||
"mbase/pkg/auxtool"
|
||||
"mbase/pkg/descr"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"go.yaml.in/yaml/v4"
|
||||
@@ -80,4 +80,3 @@ func (util *Util) dumpDatabase(params dumpDatabaseParams) (dumpDatabaseResult, e
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
||||
|
||||
@@ -61,4 +61,3 @@ func (util *Util) Exec(args []string) error {
|
||||
err = util.rootCmd.Execute()
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ require (
|
||||
github.com/jmoiron/sqlx v1.4.0
|
||||
github.com/mattn/go-sqlite3 v1.14.44
|
||||
github.com/spf13/cobra v1.10.2
|
||||
github.com/spf13/viper v1.21.0
|
||||
github.com/stretchr/testify v1.11.1
|
||||
go.yaml.in/yaml/v4 v4.0.0-rc.4
|
||||
google.golang.org/grpc v1.81.1
|
||||
@@ -21,11 +22,13 @@ require (
|
||||
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.30.1 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
@@ -39,11 +42,17 @@ require (
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/quic-go/qpack v0.6.0 // indirect
|
||||
github.com/quic-go/quic-go v0.59.0 // indirect
|
||||
github.com/spf13/pflag v1.0.9 // indirect
|
||||
github.com/sagikazarmark/locafero v0.11.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
|
||||
github.com/spf13/afero v1.15.0 // indirect
|
||||
github.com/spf13/cast v1.10.0 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.2 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/arch v0.22.0 // indirect
|
||||
golang.org/x/crypto v0.48.0 // indirect
|
||||
golang.org/x/net v0.51.0 // indirect
|
||||
|
||||
@@ -14,6 +14,10 @@ github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6N
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
||||
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||
@@ -34,6 +38,8 @@ github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy0
|
||||
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
|
||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||
@@ -82,10 +88,21 @@ github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRC
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
|
||||
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
|
||||
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
|
||||
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
|
||||
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
|
||||
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
|
||||
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
|
||||
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
|
||||
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
@@ -97,6 +114,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||
|
||||
Reference in New Issue
Block a user