Skip to content

Commit

Permalink
Sync from server repo (88b0283)
Browse files Browse the repository at this point in the history
  • Loading branch information
roypaulin committed Nov 16, 2023
1 parent 9c50b53 commit bda295c
Show file tree
Hide file tree
Showing 82 changed files with 756 additions and 550 deletions.
4 changes: 2 additions & 2 deletions commands/cluster_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (

type ClusterCommand interface {
CommandType() string
Parse(argv []string, log vlog.Printer) error
Parse(argv []string, logger vlog.Printer) error

/* TODO: Analyze information about the state of
* the cluster. The information could be
* cached in a config file or constructed through
* cluster discovery.
*/
Analyze(log vlog.Printer) error
Analyze(logger vlog.Printer) error
Run(vcc vclusterops.VClusterCommands) error
PrintUsage(string)
}
10 changes: 5 additions & 5 deletions commands/cluster_command_launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ const defaultLogPath = "/opt/vertica/log/vcluster.log"
func MakeClusterCommandLauncher() (ClusterCommandLauncher, vclusterops.VClusterCommands) {
// setup logs for command launcher initialization
userCommandString := os.Args[1]
log := vlog.Printer{ForCli: true}
logger := vlog.Printer{ForCli: true}
logPath := parseLogPathArg(os.Args, defaultLogPath)
log.SetupOrDie(logPath)
logger.SetupOrDie(logPath)
vcc := vclusterops.VClusterCommands{
Log: log.WithName(userCommandString),
Log: logger.WithName(userCommandString),
}
vcc.Log.Info("New vcluster command initialization")
newLauncher := ClusterCommandLauncher{}
Expand Down Expand Up @@ -175,14 +175,14 @@ func (c ClusterCommandLauncher) Run(inputArgv []string, vcc vclusterops.VCluster
}

func identifySubcommand(commands map[string]ClusterCommand, userCommandString string,
log vlog.Printer) (ClusterCommand, error) {
logger vlog.Printer) (ClusterCommand, error) {
command, ok := commands[userCommandString]
if !ok {
return nil, fmt.Errorf("unrecognized command '%s'",
userCommandString)
}

log.Log.Info("Recognized command", "cmd", userCommandString)
logger.Log.Info("Recognized command", "cmd", userCommandString)
return command, nil
}

Expand Down
10 changes: 5 additions & 5 deletions commands/cmd_add_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ func (c *CmdAddNode) CommandType() string {
return "db_add_node"
}

func (c *CmdAddNode) Parse(inputArgv []string, log vlog.Printer) error {
func (c *CmdAddNode) Parse(inputArgv []string, logger vlog.Printer) error {
c.argv = inputArgv
err := c.ValidateParseArgv(c.CommandType(), log)
err := c.ValidateParseArgv(c.CommandType(), logger)
if err != nil {
return err
}
Expand All @@ -105,11 +105,11 @@ func (c *CmdAddNode) Parse(inputArgv []string, log vlog.Printer) error {
if !util.IsOptionSet(c.parser, "eon-mode") {
c.CmdBase.isEon = nil
}
return c.validateParse(log)
return c.validateParse(logger)
}

func (c *CmdAddNode) validateParse(log vlog.Printer) error {
log.Info("Called validateParse()")
func (c *CmdAddNode) validateParse(logger vlog.Printer) error {
logger.Info("Called validateParse()")

err := c.parseNewHostList()
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions commands/cmd_add_subcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ func (c *CmdAddSubcluster) CommandType() string {
return "db_add_subcluster"
}

func (c *CmdAddSubcluster) Parse(inputArgv []string, log vlog.Printer) error {
func (c *CmdAddSubcluster) Parse(inputArgv []string, logger vlog.Printer) error {
c.argv = inputArgv
err := c.ValidateParseArgv(c.CommandType(), log)
err := c.ValidateParseArgv(c.CommandType(), logger)
if err != nil {
return err
}
Expand All @@ -110,17 +110,17 @@ func (c *CmdAddSubcluster) Parse(inputArgv []string, log vlog.Printer) error {
c.addSubclusterOptions.ConfigDirectory = nil
}

return c.validateParse(log)
return c.validateParse(logger)
}

// all validations of the arguments should go in here
func (c *CmdAddSubcluster) validateParse(log vlog.Printer) error {
log.Info("Called validateParse()")
func (c *CmdAddSubcluster) validateParse(logger vlog.Printer) error {
logger.Info("Called validateParse()")
return c.ValidateParseBaseOptions(&c.addSubclusterOptions.DatabaseOptions)
}

func (c *CmdAddSubcluster) Analyze(log vlog.Printer) error {
log.Info("Called method Analyze()")
func (c *CmdAddSubcluster) Analyze(logger vlog.Printer) error {
logger.Info("Called method Analyze()")
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions commands/cmd_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ func (c *CmdBase) ParseArgv() error {
}

// validate and parse argv
func (c *CmdBase) ValidateParseArgv(commandType string, log vlog.Printer) error {
log.LogArgParse(&c.argv)
func (c *CmdBase) ValidateParseArgv(commandType string, logger vlog.Printer) error {
logger.LogArgParse(&c.argv)
return c.ValidateParseArgvHelper(commandType)
}

// validate and parse masked argv
// Some database actions, such as createDB and reviveDB, need to mask sensitive parameters in the log
func (c *CmdBase) ValidateParseMaskedArgv(commandType string, log vlog.Printer) error {
log.LogMaskedArgParse(c.argv)
func (c *CmdBase) ValidateParseMaskedArgv(commandType string, logger vlog.Printer) error {
logger.LogMaskedArgParse(c.argv)
return c.ValidateParseArgvHelper(commandType)
}

Expand Down
10 changes: 5 additions & 5 deletions commands/cmd_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func (c *CmdConfig) CommandType() string {
return "config"
}

func (c *CmdConfig) Parse(inputArgv []string, log vlog.Printer) error {
log.LogArgParse(&inputArgv)
func (c *CmdConfig) Parse(inputArgv []string, logger vlog.Printer) error {
logger.LogArgParse(&inputArgv)

if c.parser == nil {
return fmt.Errorf("unexpected nil - the parser was nil")
Expand All @@ -68,11 +68,11 @@ func (c *CmdConfig) Parse(inputArgv []string, log vlog.Printer) error {
return err
}

return c.validateParse(log)
return c.validateParse(logger)
}

func (c *CmdConfig) validateParse(log vlog.Printer) error {
log.Info("Called validateParse()")
func (c *CmdConfig) validateParse(logger vlog.Printer) error {
logger.Info("Called validateParse()")
// if directory is not provided, then use the current directory
return c.validateDirectory()
}
Expand Down
14 changes: 7 additions & 7 deletions commands/cmd_create_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ func (c *CmdCreateDB) CommandType() string {
return "create_db"
}

func (c *CmdCreateDB) Parse(inputArgv []string, log vlog.Printer) error {
func (c *CmdCreateDB) Parse(inputArgv []string, logger vlog.Printer) error {
c.argv = inputArgv
err := c.ValidateParseMaskedArgv(c.CommandType(), log)
err := c.ValidateParseMaskedArgv(c.CommandType(), logger)
if err != nil {
return err
}
Expand All @@ -139,12 +139,12 @@ func (c *CmdCreateDB) Parse(inputArgv []string, log vlog.Printer) error {
c.createDBOptions.IsEon = vstruct.False
}

return c.validateParse(log)
return c.validateParse(logger)
}

// all validations of the arguments should go in here
func (c *CmdCreateDB) validateParse(log vlog.Printer) error {
log.Info("Called validateParse()")
func (c *CmdCreateDB) validateParse(logger vlog.Printer) error {
logger.Info("Called validateParse()")

// parse raw host str input into a []string of createDBOptions
err := c.createDBOptions.ParseHostList(*c.hostListStr)
Expand All @@ -166,8 +166,8 @@ func (c *CmdCreateDB) validateParse(log vlog.Printer) error {
return nil
}

func (c *CmdCreateDB) Analyze(log vlog.Printer) error {
log.Info("Called method Analyze()")
func (c *CmdCreateDB) Analyze(logger vlog.Printer) error {
logger.Info("Called method Analyze()")
return nil
}

Expand Down
12 changes: 6 additions & 6 deletions commands/cmd_drop_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func (c *CmdDropDB) CommandType() string {
return "drop_db"
}

func (c *CmdDropDB) Parse(inputArgv []string, log vlog.Printer) error {
func (c *CmdDropDB) Parse(inputArgv []string, logger vlog.Printer) error {
c.argv = inputArgv
err := c.ValidateParseArgv(c.CommandType(), log)
err := c.ValidateParseArgv(c.CommandType(), logger)
if err != nil {
return err
}
Expand All @@ -64,14 +64,14 @@ func (c *CmdDropDB) Parse(inputArgv []string, log vlog.Printer) error {
c.CmdBase.ipv6 = nil
}

return c.validateParse(log)
return c.validateParse(logger)
}

func (c *CmdDropDB) validateParse(log vlog.Printer) error {
func (c *CmdDropDB) validateParse(logger vlog.Printer) error {
if !util.IsOptionSet(c.parser, "password") {
c.dropDBOptions.Password = nil
}
log.Info("Called validateParse()")
logger.Info("Called validateParse()")
return c.ValidateParseBaseOptions(&c.dropDBOptions.DatabaseOptions)
}

Expand All @@ -88,6 +88,6 @@ func (c *CmdDropDB) Run(vcc vclusterops.VClusterCommands) error {
return err
}

vcc.Log.PrintInfo("Successfully dropped database %s\n", *c.dropDBOptions.DBName)
vcc.Log.PrintInfo("Successfully dropped database %s", *c.dropDBOptions.DBName)
return nil
}
10 changes: 5 additions & 5 deletions commands/cmd_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (c CmdHelp) CommandType() string {
return "help"
}

func (c *CmdHelp) Parse(inputArgv []string, log vlog.Printer) error {
log.LogArgParse(&inputArgv)
func (c *CmdHelp) Parse(inputArgv []string, logger vlog.Printer) error {
logger.LogArgParse(&inputArgv)

if c.parser == nil {
return fmt.Errorf("unexpected nil - the parser was nil")
Expand All @@ -61,11 +61,11 @@ func (c *CmdHelp) Parse(inputArgv []string, log vlog.Printer) error {
return err
}

return c.validateParse(log)
return c.validateParse(logger)
}

func (c *CmdHelp) validateParse(log vlog.Printer) error {
log.Info("Called validateParse()")
func (c *CmdHelp) validateParse(logger vlog.Printer) error {
logger.Info("Called validateParse()")
return nil
}

Expand Down
14 changes: 7 additions & 7 deletions commands/cmd_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func (c *CmdInit) CommandType() string {
return "init"
}

func (c *CmdInit) Parse(inputArgv []string, log vlog.Printer) error {
log.LogArgParse(&inputArgv)
func (c *CmdInit) Parse(inputArgv []string, logger vlog.Printer) error {
logger.LogArgParse(&inputArgv)

if c.parser == nil {
return fmt.Errorf("unexpected nil - the parser was nil")
Expand All @@ -71,11 +71,11 @@ func (c *CmdInit) Parse(inputArgv []string, log vlog.Printer) error {
return err
}

return c.validateParse(log)
return c.validateParse(logger)
}

func (c *CmdInit) validateParse(log vlog.Printer) error {
log.Info("Called validateParse()")
func (c *CmdInit) validateParse(logger vlog.Printer) error {
logger.Info("Called validateParse()")

// if directory is not provided, then use the current directory
err := c.validateDirectory()
Expand All @@ -91,8 +91,8 @@ func (c *CmdInit) validateParse(log vlog.Printer) error {
return nil
}

func (c *CmdInit) Analyze(log vlog.Printer) error {
log.Info("Called method Analyze()")
func (c *CmdInit) Analyze(logger vlog.Printer) error {
logger.Info("Called method Analyze()")
return nil
}

Expand Down
10 changes: 5 additions & 5 deletions commands/cmd_list_all_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (c *CmdListAllNodes) CommandType() string {
return "list_allnodes"
}

func (c *CmdListAllNodes) Parse(inputArgv []string, log vlog.Printer) error {
func (c *CmdListAllNodes) Parse(inputArgv []string, logger vlog.Printer) error {
c.argv = inputArgv
err := c.ValidateParseArgv(c.CommandType(), log)
err := c.ValidateParseArgv(c.CommandType(), logger)
if err != nil {
return err
}
Expand All @@ -53,11 +53,11 @@ func (c *CmdListAllNodes) Parse(inputArgv []string, log vlog.Printer) error {
c.fetchNodeStateOptions.Password = nil
}

return c.validateParse(log)
return c.validateParse(logger)
}

func (c *CmdListAllNodes) validateParse(log vlog.Printer) error {
log.Info("Called validateParse()")
func (c *CmdListAllNodes) validateParse(logger vlog.Printer) error {
logger.Info("Called validateParse()")

// parse raw host str input into a []string
err := c.parseHostList(&c.fetchNodeStateOptions.DatabaseOptions)
Expand Down
12 changes: 6 additions & 6 deletions commands/cmd_re_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ func (c *CmdReIP) CommandType() string {
return "re_ip"
}

func (c *CmdReIP) Parse(inputArgv []string, log vlog.Printer) error {
log.LogArgParse(&inputArgv)
func (c *CmdReIP) Parse(inputArgv []string, logger vlog.Printer) error {
logger.LogArgParse(&inputArgv)

if c.parser == nil {
return fmt.Errorf("unexpected nil - the parser was nil")
}

c.argv = inputArgv
err := c.ValidateParseArgv(c.CommandType(), log)
err := c.ValidateParseArgv(c.CommandType(), logger)
if err != nil {
return err
}

return c.validateParse(log)
return c.validateParse(logger)
}

func (c *CmdReIP) validateParse(log vlog.Printer) error {
log.Info("Called validateParse()")
func (c *CmdReIP) validateParse(logger vlog.Printer) error {
logger.Info("Called validateParse()")

// parse raw host str input into a []string
err := c.parseHostList(&c.reIPOptions.DatabaseOptions)
Expand Down
10 changes: 5 additions & 5 deletions commands/cmd_remove_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ func (c *CmdRemoveNode) CommandType() string {
return "db_remove_node"
}

func (c *CmdRemoveNode) Parse(inputArgv []string, log vlog.Printer) error {
func (c *CmdRemoveNode) Parse(inputArgv []string, logger vlog.Printer) error {
c.argv = inputArgv
err := c.ValidateParseArgv(c.CommandType(), log)
err := c.ValidateParseArgv(c.CommandType(), logger)
if err != nil {
return err
}
Expand All @@ -89,11 +89,11 @@ func (c *CmdRemoveNode) Parse(inputArgv []string, log vlog.Printer) error {
if !util.IsOptionSet(c.parser, "password") {
c.removeNodeOptions.Password = nil
}
return c.validateParse(log)
return c.validateParse(logger)
}

func (c *CmdRemoveNode) validateParse(log vlog.Printer) error {
log.Info("Called validateParse()")
func (c *CmdRemoveNode) validateParse(logger vlog.Printer) error {
logger.Info("Called validateParse()")

err := c.removeNodeOptions.ParseHostToRemoveList(*c.hostToRemoveListStr)
if err != nil {
Expand Down
Loading

0 comments on commit bda295c

Please sign in to comment.