working commit

This commit is contained in:
2026-06-09 14:10:53 +02:00
parent ee30858d11
commit 6e92720e69
26 changed files with 339 additions and 165 deletions
+3 -6
View File
@@ -126,17 +126,14 @@ run:
env CGO_ENABLED=1 $(GO) run $(GOFLAGS) ./cmd/mbased/... --daemon=false
distclean-local: clean
rm -rf autom4te.cache
distclean-local:
rm -rf tmp/
clean-local:
rm -f */*/*~
rm -f */*~
rm -f *~
$(FIND) . -name "*~" | $(XARGS) rm -v
rm -f cmd/mbaseadmin/mbaseadmin
rm -f cmd/mbasectl/mbasectl
rm -f cmd/mbased/mbased
rm -f cmd/mbasedump/mbasedump
rm -rf autom4te.cache
rm -rf tmp/
+4 -6
View File
@@ -225,6 +225,7 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FIND = @FIND@
GO = @GO@
HAVE_GO = @HAVE_GO@
INSTALL = @INSTALL@
@@ -921,19 +922,16 @@ run:
test -z $(DESTDIR)$(SRV_DATADIR) || $(MKDIR_P) $(DESTDIR)$(SRV_DATADIR)
env CGO_ENABLED=1 $(GO) run $(GOFLAGS) ./cmd/mbased/... --daemon=false
distclean-local: clean
rm -rf autom4te.cache
distclean-local:
rm -rf tmp/
clean-local:
rm -f */*/*~
rm -f */*~
rm -f *~
$(FIND) . -name "*~" | $(XARGS) rm -v
rm -f cmd/mbaseadmin/mbaseadmin
rm -f cmd/mbasectl/mbasectl
rm -f cmd/mbased/mbased
rm -f cmd/mbasedump/mbasedump
rm -rf autom4te.cache
rm -rf tmp/
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
+17 -18
View File
@@ -20,24 +20,20 @@ const (
pidFilename = "mbased.pid"
)
var (
buildVersion = "NONE"
)
type Networks struct {
Enabled []string `json:"enabled" yaml:"enabled"`
Disabled []string `json:"disabled" yaml:"disabled"`
}
type ServiceConfig struct {
type Service struct {
Portnum uint32 `json:"port" yaml:"port"`
Address string `json:"address" yaml:"address"`
Protocol string `json:"protocol" yaml:"protocol"`
}
type Config struct {
PackageVersion string `json:"packageVersion" yaml:"packageVersion"`
Service ServiceConfig `json:"service" yaml:"service"`
Version string `json:"version" yaml:"version"`
Service Service `json:"service" yaml:"service"`
Networks Networks `json:"networks" yaml:"networks"`
Hostname string `json:"hostname" yaml:"hostname"`
Debug bool `json:"debug" yaml:"debug"`
@@ -45,7 +41,9 @@ type Config struct {
LogPath string `json:"logfile" yaml:"logfile"`
RunPath string `json:"runfile" yaml:"runfile"`
DataDir string `json:"datadir" yaml:"datadir"`
Daemon bool `json:"daemon" yaml:"daemon"`
AsDaemon bool `json:"asDaemon" yaml:"asDaemon"`
RunUser string `json:"runUser" yaml:"runUser"`
LogLimit int64 `json:"logLimit" yaml:"logLimit"`
}
var (
@@ -54,28 +52,29 @@ var (
)
const (
defaultServiceAddress = "0.0.0.0"
defaultServiceAddress = "[::]"
defaultServiceProtocol = "tcp"
)
func NewConfig() *Config {
conf := &Config{
Service: ServiceConfig{
Service: Service{
Portnum: client.DefaultPort,
Address: defaultServiceAddress,
Protocol: defaultServiceProtocol,
},
DataDir: datadirPath,
Debug: false,
Hostname: defaultHostname,
Build: buildVersion,
Daemon: true,
PackageVersion: packageVersion,
Networks: Networks{
Enabled: defaultEnabledNetworks,
Disabled: defaultDisabledNetworks,
},
DataDir: datadirPath,
Debug: false,
Hostname: defaultHostname,
Build: packageVersion,
AsDaemon: true,
Version: packageVersion,
LogLimit: 1024 * 1024 * 10, // 10 Mb
RunUser: "daemon",
}
conf.LogPath = filepath.Join(logdirPath, logFilename)
conf.RunPath = filepath.Join(rundirPath, pidFilename)
@@ -106,7 +105,7 @@ func (conf *Config) ReadOpts() error {
exeName := filepath.Base(os.Args[0])
flag.BoolVar(&conf.Daemon, "daemon", conf.Daemon, "run as daemon")
flag.BoolVar(&conf.AsDaemon, "asDaemon", conf.AsDaemon, "run as daemon")
flag.BoolVar(&conf.Debug, "debug", conf.Debug, "on debug mode")
help := func() {
-29
View File
@@ -10,34 +10,6 @@ import (
_ "github.com/mattn/go-sqlite3"
)
const schema = `
--- DROP TABLE IF EXISTS account;
CREATE TABLE IF NOT EXISTS account (
id TEXT NOT NULL,
username TEXT NOT NULL,
passhash TEXT NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
disabled BOOL
);
CREATE UNIQUE INDEX IF NOT EXISTS account_index01
ON account(id);
CREATE UNIQUE INDEX IF NOT EXISTS account_index02
ON account(username);
--- DROP TABLE IF EXISTS grant;
CREATE TABLE IF NOT EXISTS grant (
id TEXT NOT NULL,
account_id TEXT NOT NULL,
operation TEXT NOT NULL,
created_at TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS grant_index01
ON grant(account_id);
CREATE UNIQUE INDEX IF NOT EXISTS grant_index02
ON grant(account_id, operation);
`
type Database struct {
datapath string
db *sqlx.DB
@@ -61,7 +33,6 @@ func (db *Database) OpenDatabase() error {
if err != nil {
return err
}
err = db.db.Ping()
if err != nil {
return err
+8 -8
View File
@@ -8,9 +8,9 @@ import (
func (db *Database) InsertGrant(ctx context.Context, grant *descr.Grant) error {
var err error
request := `INSERT INTO grant(id, account_id, operation, created_at)
request := `INSERT INTO grant(id, account_id, grantname, created_at)
VALUES ($1, $2, $3, $4)`
_, err = db.db.Exec(request, grant.ID, grant.AccountID, grant.Operation, grant.CreatedAt)
_, err = db.db.Exec(request, grant.ID, grant.AccountID, grant.Grantname, grant.CreatedAt)
if err != nil {
return err
}
@@ -39,12 +39,12 @@ func (db *Database) ListGrants(ctx context.Context) ([]descr.Grant, error) {
return res, err
}
func (db *Database) GetGrant(ctx context.Context, accountID, operation string) (bool, *descr.Grant, error) {
func (db *Database) GetGrant(ctx context.Context, accountID, grantname string) (bool, *descr.Grant, error) {
var err error
res := &descr.Grant{}
request := `SELECT * FROM grant WHERE account_id = $1 AND operation = $2 LIMIT 1`
request := `SELECT * FROM grant WHERE account_id = $1 AND grantname = $2 LIMIT 1`
dbRes := make([]descr.Grant, 0)
err = db.db.Select(&dbRes, request, accountID, operation)
err = db.db.Select(&dbRes, request, accountID, grantname)
if err != nil {
return false, res, err
}
@@ -56,10 +56,10 @@ func (db *Database) GetGrant(ctx context.Context, accountID, operation string) (
return true, res, err
}
func (db *Database) DeleteGrantByAccountID(ctx context.Context, grantID, operation string) error {
func (db *Database) DeleteGrantByAccountID(ctx context.Context, grantID, grantname string) error {
var err error
request := `DELETE FROM grant WHERE account_id = $1 AND operation = $2`
_, err = db.db.Exec(request, grantID, operation)
request := `DELETE FROM grant WHERE account_id = $1 AND grantname = $2`
_, err = db.db.Exec(request, grantID, grantname)
if err != nil {
return err
}
+29
View File
@@ -0,0 +1,29 @@
package maindb
const schema = `
--- DROP TABLE IF EXISTS account;
CREATE TABLE IF NOT EXISTS account (
id TEXT NOT NULL,
username TEXT NOT NULL,
passhash TEXT NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
disabled BOOL
);
CREATE UNIQUE INDEX IF NOT EXISTS account_index01
ON account(id);
CREATE UNIQUE INDEX IF NOT EXISTS account_index02
ON account(username);
--- DROP TABLE IF EXISTS grant;
CREATE TABLE IF NOT EXISTS grant (
id TEXT NOT NULL,
account_id TEXT NOT NULL,
grantname TEXT NOT NULL,
created_at TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS grant_index01
ON grant(account_id);
CREATE UNIQUE INDEX IF NOT EXISTS grant_index02
ON grant(account_id, grantname);
`
+1 -1
View File
@@ -221,7 +221,7 @@ func (oper *Operator) ListAccounts(ctx context.Context, accountID string, params
}
for _, grantDescrs := range grantDescrs {
grantShortDescrs := &mbctl.GrantShortDescr{
Operation: grantDescrs.Operation,
Grantname: grantDescrs.Grantname,
CreatedAt: grantDescrs.CreatedAt,
}
accountShortDescr.Grants = append(accountShortDescr.Grants, grantShortDescrs)
+1 -1
View File
@@ -54,7 +54,7 @@ func (oper *Operator) SeedAccount(ctx context.Context) (string, error) {
for _, grantType := range grantTypes {
grantDescr := &descr.Grant{
AccountID: accountDescr.ID,
Operation: grantType,
Grantname: grantType,
CreatedAt: now,
}
err = oper.db.InsertGrant(ctx, grantDescr)
+1 -1
View File
@@ -96,7 +96,7 @@ func (oper *Operator) RestoreDump(ctx context.Context, accountID string, params
}
}
for _, grant := range dump.Grants {
oper.log.Infof("Insert grant %s for account %d", grant.Operation, grant.AccountID)
oper.log.Infof("Insert grant %s for account %d", grant.Grantname, grant.AccountID)
err = oper.db.InsertGrant(ctx, &grant)
if err != nil {
oper.log.Errorf("Insert account error: %v", err)
+7 -7
View File
@@ -31,7 +31,7 @@ func (oper *Operator) SetGrant(ctx context.Context, accountID string, params *mb
}
var grantOk bool
for _, grantType := range grantTypes {
if grantType == params.Operation {
if grantType == params.Grantname {
grantOk = true
break
}
@@ -60,12 +60,12 @@ func (oper *Operator) SetGrant(ctx context.Context, accountID string, params *mb
return res, err
}
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Operation)
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Grantname)
if err != nil {
return res, err
}
if grantExists {
err := fmt.Errorf("Grant %s for the user already exists", params.Operation)
err := fmt.Errorf("Grant %s for the user already exists", params.Grantname)
return res, err
}
now := time.Now().Format(time.RFC3339)
@@ -73,7 +73,7 @@ func (oper *Operator) SetGrant(ctx context.Context, accountID string, params *mb
ID: auxuuid.NewUUID(),
AccountID: accountDescr.ID,
CreatedAt: now,
Operation: params.Operation,
Grantname: params.Grantname,
}
err = oper.db.InsertGrant(ctx, grantDescr)
if err != nil {
@@ -103,7 +103,7 @@ func (oper *Operator) DeleteGrant(ctx context.Context, accountID string, params
}
var grantOk bool
for _, grantType := range grantTypes {
if grantType == params.Operation {
if grantType == params.Grantname {
grantOk = true
break
}
@@ -132,7 +132,7 @@ func (oper *Operator) DeleteGrant(ctx context.Context, accountID string, params
return res, err
}
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Operation)
grantExists, _, err = oper.db.GetGrant(ctx, accountDescr.ID, params.Grantname)
if err != nil {
return res, err
}
@@ -140,7 +140,7 @@ func (oper *Operator) DeleteGrant(ctx context.Context, accountID string, params
err := fmt.Errorf("Requested grant for the user not found")
return res, err
}
err = oper.db.DeleteGrantByAccountID(ctx, accountDescr.ID, params.Operation)
err = oper.db.DeleteGrantByAccountID(ctx, accountDescr.ID, params.Grantname)
if err != nil {
return res, err
}
+73 -10
View File
@@ -1,6 +1,7 @@
package server
import (
"fmt"
"io/ioutil"
"os"
"os/signal"
@@ -37,6 +38,7 @@ type Server struct {
x509key []byte
state descr.Server
sfile string
logf *os.File
}
func NewServer() (*Server, error) {
@@ -117,26 +119,88 @@ func (srv *Server) Build() error {
var err error
srv.log.Infof("Build server")
currUser, err := user.Current()
if err != nil {
err = fmt.Errorf("Error getting current user: %v\n", err)
return err
}
cuid64, err := strconv.ParseInt(currUser.Uid, 10, 64)
if err != nil {
return err
}
cgid64, err := strconv.ParseInt(currUser.Gid, 10, 64)
if err != nil {
return err
}
euid := int(cuid64)
egid := int(cgid64)
if cuid64 == 0 {
usr, err := user.Lookup(srv.conf.RunUser)
if err != nil {
return err
}
uid64, err := strconv.ParseInt(usr.Uid, 10, 64)
if err != nil {
return err
}
gid64, err := strconv.ParseInt(usr.Gid, 10, 64)
if err != nil {
return err
}
euid = int(uid64)
egid = int(gid64)
}
// Mkdir log and data dir
srv.log.Infof("Create %s dir", srv.conf.DataDir)
datadir := srv.conf.DataDir
srv.log.Infof("Create %s dir", datadir)
err = os.MkdirAll(srv.conf.DataDir, 0750)
if err != nil {
return err
}
if srv.conf.Daemon {
logDir := filepath.Dir(srv.conf.LogPath)
srv.log.Infof("Create %s dir", logDir)
err = os.MkdirAll(logDir, 0750)
err = os.Chown(datadir, euid, egid)
if err != nil {
return err
}
runDir := filepath.Dir(srv.conf.RunPath)
srv.log.Infof("Create %s dir", runDir)
err = os.MkdirAll(runDir, 0750)
if srv.conf.AsDaemon {
logdir := filepath.Dir(srv.conf.LogPath)
//srv.logg.Infof("Creating log directory %s", logdir)
err = os.MkdirAll(logdir, 0750)
if err != nil {
return err
}
err = os.Chown(logdir, euid, egid)
if err != nil {
return err
}
rundir := filepath.Dir(srv.conf.RunPath)
//srv.logg.Infof("Creating run directory %s", rundir)
err = os.MkdirAll(rundir, 0750)
if err != nil {
return err
}
err = os.Chown(rundir, euid, egid)
if err != nil {
return err
}
// Redirect stderr and stout
logFile, err := os.OpenFile(srv.conf.LogPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0640)
if err != nil {
return err
}
err = syscall.Dup2(int(logFile.Fd()), int(os.Stdout.Fd()))
if err != nil {
return err
}
err = syscall.Dup2(int(logFile.Fd()), int(os.Stderr.Fd()))
if err != nil {
return err
}
srv.logf = logFile
}
// Create X509 certs
srv.x509cert, srv.x509key, err = aux509.CreateX509SelfSignedCert(srv.conf.Hostname)
if err != nil {
@@ -305,13 +369,12 @@ func (srv *Server) PseudoFork() error {
func (srv *Server) Daemonize() error {
var err error
if srv.conf.Daemon {
if srv.conf.AsDaemon {
// Restart process process
err = srv.PseudoFork()
if err != nil {
return err
}
// Redirect stdin
nullFile, err := os.OpenFile("/dev/null", os.O_RDWR, 0)
if err != nil {
+3 -3
View File
@@ -13,14 +13,14 @@ import (
func (util *Util) DeleteGrant(cmd *cobra.Command, args []string) {
util.deleteGrantParams.Username = args[0]
util.deleteGrantParams.Operation = args[1]
util.deleteGrantParams.Grantname = args[1]
res, err := util.deleteGrant(&util.deleteGrantParams)
printResponse(res, err)
}
type DeleteGrantParams struct {
Username string
Operation string
Grantname string
}
type DeleteGrantResult struct{}
@@ -30,7 +30,7 @@ func (util *Util) deleteGrant(params *DeleteGrantParams) (*DeleteGrantResult, er
ctx := context.Background()
operParams := &mbctl.DeleteGrantParams{
Username: params.Username,
Operation: params.Operation,
Grantname: params.Grantname,
}
_, err = util.oper.DeleteGrant(ctx, util.operID, operParams)
if err != nil {
+3 -3
View File
@@ -13,14 +13,14 @@ import (
func (util *Util) SetGrant(cmd *cobra.Command, args []string) {
util.setGrantParams.Username = args[0]
util.setGrantParams.Operation = args[1]
util.setGrantParams.Grantname = args[1]
res, err := util.setGrant(&util.setGrantParams)
printResponse(res, err)
}
type SetGrantParams struct {
Username string
Operation string
Grantname string
}
type SetGrantResult struct {
GrantID string `json:"grantId"`
@@ -32,7 +32,7 @@ func (util *Util) setGrant(params *SetGrantParams) (*SetGrantResult, error) {
ctx := context.Background()
operParams := &mbctl.SetGrantParams{
Username: params.Username,
Operation: params.Operation,
Grantname: params.Grantname,
}
operRes, err := util.oper.SetGrant(ctx, util.operID, operParams)
if err != nil {
+19
View File
@@ -0,0 +1,19 @@
package main
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestCert(t *testing.T) {
var err error
util := NewUtil()
err = util.Build()
require.NoError(t, err)
args := []string{"seed"}
err = util.Exec(args)
require.NoError(t, err)
}
-23
View File
@@ -1,23 +0,0 @@
/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
package account
import (
"github.com/spf13/cobra"
)
func (util *Util) CreateGrant(cmd *cobra.Command, args []string) {
//util.createGrantParams.Filename = args[0]
res, err := util.createGrant(util.createGrantParams)
printResponse(res, err)
}
type createGrantParams struct{}
type createGrantResult struct{}
func (util *Util) createGrant(params createGrantParams) (createGrantResult, error) {
var err error
res := createGrantResult{}
return res, err
}
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
package account
package grant
import (
"github.com/spf13/cobra"
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
package account
package grant
import (
"fmt"
+50
View File
@@ -0,0 +1,50 @@
/*
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
*/
package grant
import (
"context"
"mbase/pkg/client"
"mbase/pkg/mbctl"
"github.com/spf13/cobra"
)
func (util *Util) SetGrant(cmd *cobra.Command, args []string) {
util.setGrantParams.Username = args[0]
util.setGrantParams.Grantname = args[1]
res, err := util.setGrant(util.setGrantParams)
printResponse(res, err)
}
type SetGrantParams struct {
Username string
Grantname string
}
type SetGrantResult struct {
GrantID string
}
func (util *Util) setGrant(params SetGrantParams) (SetGrantResult, error) {
var err error
res := SetGrantResult{}
grpcConn, cli, err := client.NewClient(&util.access)
if err != nil {
return res, err
}
defer grpcConn.Close()
operParams := &mbctl.SetGrantParams{
Username: params.Username,
Grantname: params.Grantname,
}
ctx := context.Background()
operRes, err := cli.SetGrant(ctx, operParams)
if err != nil {
return res, err
}
res.GrantID = operRes.GrantID
return res, err
}
+25 -6
View File
@@ -4,13 +4,24 @@
package grant
import (
"mbase/pkg/client"
"github.com/spf13/cobra"
)
type CommonParams struct {
Hostname string
Port uint32
Username string
Password string
}
type Util struct {
rootCmd *cobra.Command
createGrantParams createGrantParams
setGrantParams SetGrantParams
deleteGrantParams deleteGrantParams
commonParams CommonParams
access client.Access
}
func NewUtil() *Util {
@@ -29,13 +40,13 @@ func (util *Util) BuildCmds() *cobra.Command {
}
rootCmd.CompletionOptions.DisableDefaultCmd = true
var createGrantCmd = &cobra.Command{
Use: "create name|id password",
Short: "Create grant",
var setGrantCmd = &cobra.Command{
Use: "set name|id grant",
Short: "Set grant",
Args: cobra.ExactArgs(2),
Run: util.CreateGrant,
Run: util.SetGrant,
}
rootCmd.AddCommand(createGrantCmd)
rootCmd.AddCommand(setGrantCmd)
var deleteGrantCmd = &cobra.Command{
Use: "delete name|id grant",
@@ -49,3 +60,11 @@ func (util *Util) BuildCmds() *cobra.Command {
return util.rootCmd
}
func (util *Util) SetAccess(cmd *cobra.Command, args []string) {
util.access = client.Access{
Hostname: util.commonParams.Hostname,
Port: util.commonParams.Port,
Username: util.commonParams.Username,
Password: util.commonParams.Password,
}
}
+2 -2
View File
@@ -35,7 +35,7 @@ func (util *Util) Build() error {
rootCmd.CompletionOptions.DisableDefaultCmd = true
var dumpDatabaseCmd = &cobra.Command{
Use: "dump [filename|-]",
Use: "dump filename|-",
Short: "Dump application database",
Args: cobra.ExactArgs(1),
Run: util.DumpDatabase,
@@ -43,7 +43,7 @@ func (util *Util) Build() error {
rootCmd.AddCommand(dumpDatabaseCmd)
var restoreDatabaseCmd = &cobra.Command{
Use: "restore [] [filename|-]",
Use: "restore filename|-",
Short: "Restore application database",
Args: cobra.ExactArgs(1),
Run: util.RestoreDatabase,
Vendored
+52
View File
@@ -662,6 +662,7 @@ build_os
build_vendor
build_cpu
build
FIND
XARGS
CPIO
PODMAN
@@ -3646,6 +3647,57 @@ fi
test -n "$XARGS" && break
done
for ac_prog in find false
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_path_FIND+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) case $FIND in
[\\/]* | ?:[\\/]*)
ac_cv_path_FIND="$FIND" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
case $as_dir in #(((
'') as_dir=./ ;;
*/) ;;
*) as_dir=$as_dir/ ;;
esac
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
ac_cv_path_FIND="$as_dir$ac_word$ac_exec_ext"
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac ;;
esac
fi
FIND=$ac_cv_path_FIND
if test -n "$FIND"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FIND" >&5
printf "%s\n" "$FIND" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
test -n "$FIND" && break
done
for ac_prog in protoc false
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
+1
View File
@@ -23,6 +23,7 @@ AC_PATH_PROGS([PROTOC],[protoc true])
AC_PATH_PROGS([PODMAN],[podman true])
AC_PATH_PROGS([CPIO],[cpio false])
AC_PATH_PROGS([XARGS],[xargs false])
AC_PATH_PROGS([FIND],[find false])
AC_PATH_PROGS([PROTOC],[protoc false])
+4 -5
View File
@@ -8,12 +8,11 @@ import (
)
func TestCert(t *testing.T) {
{
//caCert, caKey, err := CreateX509SelfSignedCert("test1")
//require.NoError(t, err)
//fmt.Println(string(caCert))
//fmt.Println(string(caKey))
caCert, caKey, err := CreateX509SelfSignedCert("test1")
require.NoError(t, err)
fmt.Println(string(caCert))
fmt.Println(string(caKey))
}
{
caCert, caKey, err := CreateX509CACert("test1")
+1 -1
View File
@@ -23,7 +23,7 @@ type Account struct {
type Grant struct {
ID string `json:"id" yaml:"id" db:"id"`
AccountID string `json:"accountID" yaml:"accountID" db:"account_id"`
Operation string `json:"operation" yaml:"operation" db:"operation"`
Grantname string `json:"grantname" yaml:"grantname" db:"grantname"`
CreatedAt string `json:"createdAt" yaml:"createdAt" db:"created_at"`
}
+16 -16
View File
@@ -193,7 +193,7 @@ type SetGrantParams struct {
state protoimpl.MessageState `protogen:"open.v1"`
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
AccountID string `protobuf:"bytes,2,opt,name=accountID,proto3" json:"accountID,omitempty"`
Operation string `protobuf:"bytes,3,opt,name=operation,proto3" json:"operation,omitempty"`
Grantname string `protobuf:"bytes,3,opt,name=grantname,proto3" json:"grantname,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -242,9 +242,9 @@ func (x *SetGrantParams) GetAccountID() string {
return ""
}
func (x *SetGrantParams) GetOperation() string {
func (x *SetGrantParams) GetGrantname() string {
if x != nil {
return x.Operation
return x.Grantname
}
return ""
}
@@ -297,7 +297,7 @@ type DeleteGrantParams struct {
state protoimpl.MessageState `protogen:"open.v1"`
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
AccountID string `protobuf:"bytes,2,opt,name=accountID,proto3" json:"accountID,omitempty"`
Operation string `protobuf:"bytes,3,opt,name=operation,proto3" json:"operation,omitempty"`
Grantname string `protobuf:"bytes,3,opt,name=grantname,proto3" json:"grantname,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -346,9 +346,9 @@ func (x *DeleteGrantParams) GetAccountID() string {
return ""
}
func (x *DeleteGrantParams) GetOperation() string {
func (x *DeleteGrantParams) GetGrantname() string {
if x != nil {
return x.Operation
return x.Grantname
}
return ""
}
@@ -915,7 +915,7 @@ func (x *AccountShortDescr) GetGrants() []*GrantShortDescr {
type GrantShortDescr struct {
state protoimpl.MessageState `protogen:"open.v1"`
Operation string `protobuf:"bytes,1,opt,name=operation,proto3" json:"operation,omitempty"`
Grantname string `protobuf:"bytes,1,opt,name=grantname,proto3" json:"grantname,omitempty"`
CreatedAt string `protobuf:"bytes,2,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -951,9 +951,9 @@ func (*GrantShortDescr) Descriptor() ([]byte, []int) {
return file_mbctl_proto_rawDescGZIP(), []int{19}
}
func (x *GrantShortDescr) GetOperation() string {
func (x *GrantShortDescr) GetGrantname() string {
if x != nil {
return x.Operation
return x.Grantname
}
return ""
}
@@ -1064,9 +1064,9 @@ var file_mbctl_proto_rawDesc = string([]byte{
0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2a, 0x0a, 0x0e, 0x73, 0x65, 0x74, 0x47, 0x72, 0x61, 0x6e,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x72, 0x61, 0x6e, 0x74,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x72, 0x61, 0x6e,
0x74, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x2a, 0x0a, 0x0e, 0x73, 0x65, 0x74, 0x47, 0x72, 0x61, 0x6e,
0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74,
0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x49,
0x44, 0x22, 0x6b, 0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74,
@@ -1074,8 +1074,8 @@ var file_mbctl_proto_rawDesc = string([]byte{
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61,
0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x44,
0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x13,
0x12, 0x1c, 0x0a, 0x09, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x13,
0x0a, 0x11, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73,
0x75, 0x6c, 0x74, 0x22, 0x4d, 0x0a, 0x13, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73,
@@ -1127,8 +1127,8 @@ var file_mbctl_proto_rawDesc = string([]byte{
0x6f, 0x6c, 0x2e, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x44, 0x65, 0x73,
0x63, 0x72, 0x52, 0x06, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x22, 0x4d, 0x0a, 0x0f, 0x67, 0x72,
0x61, 0x6e, 0x74, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x44, 0x65, 0x73, 0x63, 0x72, 0x12, 0x1c, 0x0a,
0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x63,
0x09, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x09, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63,
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x10, 0x0a, 0x0e, 0x67, 0x65, 0x74,
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x2a, 0x0a, 0x0e, 0x67,
+3 -3
View File
@@ -35,7 +35,7 @@ message restoreDumpResult {
message setGrantParams {
string username = 1;
string accountID = 2;
string operation = 3;
string grantname = 3;
}
message setGrantResult {
string grantID = 1;
@@ -44,7 +44,7 @@ message setGrantResult {
message deleteGrantParams {
string username = 1;
string accountID = 2;
string operation = 3;
string grantname = 3;
}
message deleteGrantResult {}
@@ -89,7 +89,7 @@ message accountShortDescr {
}
message grantShortDescr {
string operation = 1;
string grantname = 1;
string createdAt = 2;
}