[CurveAdm] Add debug mode issues 252 题目申请

题目思路 [CurveAdm] Add debug mode

1. debug

Add a debug setting item to the [default] ,such as KEY_DEBUG = “debug”

const (
	KEY_LOG_LEVEL    = "log_level"
	KEY_SUDO_ALIAS   = "sudo_alias"
	KEY_TIMEOUT      = "timeout"
	KEY_AUTO_UPGRADE = "auto_upgrade"
	KEY_SSH_RETRIES  = "retries"
	KEY_SSH_TIMEOUT  = "timeout"

	WITHOUT_SUDO = " "
)

then add a case in the switch

		switch k {
		// log_level
		case KEY_LOG_LEVEL:
			if !SUPPORT_LOG_LEVEL[v.(string)] {
				return errno.ERR_UNSUPPORT_CURVEADM_LOG_LEVEL.
					F("%s: %s", KEY_LOG_LEVEL, v.(string))
			}
			cfg.LogLevel = v.(string)

		// sudo_alias
		case KEY_SUDO_ALIAS:
			cfg.SudoAlias = v.(string)

		// timeout
		case KEY_TIMEOUT:
			num, err := requirePositiveInt(KEY_TIMEOUT, v)
			if err != nil {
				return err
			}
			cfg.Timeout = num

		case KEY_AUTO_UPGRADE:
			yes, err := requirePositiveBool(KEY_AUTO_UPGRADE, v)
			if err != nil {
				return err
			}
			cfg.AutoUpgrade = yes

		default:
			return errno.ERR_UNSUPPORT_CURVEADM_CONFIGURE_ITEM.
				F("%s: %s", k, v)
		}

Then make the similar modifications to this file.

2. remove

Based on the following code, we know that we need to make remove false

func (s *CreateContainer) Execute(ctx *context.Context) error {
	cli := ctx.Module().DockerCli().CreateContainer(s.Image, s.Command)
        
       .......        

	if s.Remove {
		cli.AddOption("--rm")
	}
}

So we need to modify two codes below: