🐛 Fix a bug.

This commit is contained in:
李寻欢 2023-10-17 16:46:41 +08:00
parent 01053b2df5
commit 14250ad7ae

12
main.go
View File

@ -27,6 +27,11 @@ func main() {
case "restart": case "restart":
action = restart action = restart
case "update": case "update":
// 如果image和tag有空值报错
if os.Getenv("PLUGIN_IMAGE") == "" || os.Getenv("PLUGIN_TAG") == "" {
panic("Configuration item image or tag must not be empty")
return
}
action = update action = update
} }
} }
@ -43,21 +48,25 @@ func main() {
Action: action, Action: action,
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Required: true,
Name: "cluster", Name: "cluster",
Usage: "cluster name", Usage: "cluster name",
EnvVars: []string{"PLUGIN_CLUSTER"}, EnvVars: []string{"PLUGIN_CLUSTER"},
}, },
&cli.StringFlag{ &cli.StringFlag{
Required: true,
Name: "kind", Name: "kind",
Usage: "workload type", Usage: "workload type",
EnvVars: []string{"PLUGIN_KIND"}, EnvVars: []string{"PLUGIN_KIND"},
}, },
&cli.StringFlag{ &cli.StringFlag{
Required: true,
Name: "name", Name: "name",
Usage: "workload name", Usage: "workload name",
EnvVars: []string{"PLUGIN_NAME"}, EnvVars: []string{"PLUGIN_NAME"},
}, },
&cli.StringFlag{ &cli.StringFlag{
Required: true,
Name: "namespace", Name: "namespace",
Usage: "workload namespace", Usage: "workload namespace",
EnvVars: []string{"PLUGIN_NAMESPACE"}, EnvVars: []string{"PLUGIN_NAMESPACE"},
@ -73,16 +82,19 @@ func main() {
EnvVars: []string{"PLUGIN_TAG"}, EnvVars: []string{"PLUGIN_TAG"},
}, },
&cli.StringFlag{ &cli.StringFlag{
Required: true,
Name: "kuboard_uri", Name: "kuboard_uri",
Usage: "kuboard uri", Usage: "kuboard uri",
EnvVars: []string{"PLUGIN_KUBOARD_URI"}, EnvVars: []string{"PLUGIN_KUBOARD_URI"},
}, },
&cli.StringFlag{ &cli.StringFlag{
Required: true,
Name: "kuboard_username", Name: "kuboard_username",
Usage: "kuboard username", Usage: "kuboard username",
EnvVars: []string{"PLUGIN_KUBOARD_USERNAME"}, EnvVars: []string{"PLUGIN_KUBOARD_USERNAME"},
}, },
&cli.StringFlag{ &cli.StringFlag{
Required: true,
Name: "kuboard_key", Name: "kuboard_key",
Usage: "kuboard access key", Usage: "kuboard access key",
EnvVars: []string{"PLUGIN_KUBOARD_KEY"}, EnvVars: []string{"PLUGIN_KUBOARD_KEY"},