🐛 Fix a bug.

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

54
main.go
View File

@ -27,6 +27,11 @@ func main() {
case "restart":
action = restart
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
}
}
@ -43,24 +48,28 @@ func main() {
Action: action,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "cluster",
Usage: "cluster name",
EnvVars: []string{"PLUGIN_CLUSTER"},
Required: true,
Name: "cluster",
Usage: "cluster name",
EnvVars: []string{"PLUGIN_CLUSTER"},
},
&cli.StringFlag{
Name: "kind",
Usage: "workload type",
EnvVars: []string{"PLUGIN_KIND"},
Required: true,
Name: "kind",
Usage: "workload type",
EnvVars: []string{"PLUGIN_KIND"},
},
&cli.StringFlag{
Name: "name",
Usage: "workload name",
EnvVars: []string{"PLUGIN_NAME"},
Required: true,
Name: "name",
Usage: "workload name",
EnvVars: []string{"PLUGIN_NAME"},
},
&cli.StringFlag{
Name: "namespace",
Usage: "workload namespace",
EnvVars: []string{"PLUGIN_NAMESPACE"},
Required: true,
Name: "namespace",
Usage: "workload namespace",
EnvVars: []string{"PLUGIN_NAMESPACE"},
},
&cli.StringFlag{
Name: "image",
@ -73,19 +82,22 @@ func main() {
EnvVars: []string{"PLUGIN_TAG"},
},
&cli.StringFlag{
Name: "kuboard_uri",
Usage: "kuboard uri",
EnvVars: []string{"PLUGIN_KUBOARD_URI"},
Required: true,
Name: "kuboard_uri",
Usage: "kuboard uri",
EnvVars: []string{"PLUGIN_KUBOARD_URI"},
},
&cli.StringFlag{
Name: "kuboard_username",
Usage: "kuboard username",
EnvVars: []string{"PLUGIN_KUBOARD_USERNAME"},
Required: true,
Name: "kuboard_username",
Usage: "kuboard username",
EnvVars: []string{"PLUGIN_KUBOARD_USERNAME"},
},
&cli.StringFlag{
Name: "kuboard_key",
Usage: "kuboard access key",
EnvVars: []string{"PLUGIN_KUBOARD_KEY"},
Required: true,
Name: "kuboard_key",
Usage: "kuboard access key",
EnvVars: []string{"PLUGIN_KUBOARD_KEY"},
},
},
}