2020-09-19 22:00:34 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-09-20 20:04:09 +00:00
|
|
|
"github.com/thegeeklab/drone-github-comment/plugin"
|
2021-06-13 16:21:20 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2020-09-19 22:00:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// settingsFlags has the cli.Flags for the plugin.Settings.
|
2022-05-29 20:04:57 +00:00
|
|
|
func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
2020-09-19 22:00:34 +00:00
|
|
|
return []cli.Flag{
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "api-key",
|
|
|
|
EnvVars: []string{"PLUGIN_API_KEY", "GITHUB_COMMENT_API_KEY"},
|
2022-05-29 20:06:59 +00:00
|
|
|
Usage: "personal access token access github api",
|
2020-09-19 22:00:34 +00:00
|
|
|
Destination: &settings.APIKey,
|
2022-05-29 20:04:57 +00:00
|
|
|
Category: category,
|
2022-05-29 20:18:37 +00:00
|
|
|
Required: true,
|
2020-09-19 22:00:34 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "base-url",
|
|
|
|
EnvVars: []string{"PLUGIN_BASE_URL", "GITHUB_COMMENT_BASE_URL"},
|
2022-05-29 20:06:59 +00:00
|
|
|
Usage: "api url",
|
2021-09-12 13:16:43 +00:00
|
|
|
Value: "https://api.github.com/",
|
2020-09-19 22:00:34 +00:00
|
|
|
Destination: &settings.BaseURL,
|
2022-05-29 20:04:57 +00:00
|
|
|
Category: category,
|
2020-09-19 22:00:34 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "key",
|
|
|
|
EnvVars: []string{"PLUGIN_KEY", "GITHUB_COMMENT_KEY"},
|
2022-05-29 20:06:59 +00:00
|
|
|
Usage: "unique identifier to assign to comment",
|
2020-09-19 22:00:34 +00:00
|
|
|
Destination: &settings.Key,
|
2022-05-29 20:04:57 +00:00
|
|
|
Category: category,
|
2020-09-19 22:00:34 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
Name: "message",
|
|
|
|
EnvVars: []string{"PLUGIN_MESSAGE", "GITHUB_COMMENT_MESSAGE"},
|
2022-05-29 20:06:59 +00:00
|
|
|
Usage: "file or string that holds the comment text",
|
2020-09-19 22:00:34 +00:00
|
|
|
Destination: &settings.Message,
|
2022-05-29 20:04:57 +00:00
|
|
|
Category: category,
|
2022-05-29 20:18:37 +00:00
|
|
|
Required: true,
|
2020-09-19 22:00:34 +00:00
|
|
|
},
|
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "update",
|
|
|
|
EnvVars: []string{"PLUGIN_UPDATE", "GITHUB_COMMENT_UPDATE"},
|
2022-05-29 20:06:59 +00:00
|
|
|
Usage: "update existing comment that matches the key",
|
|
|
|
Value: false,
|
2020-09-19 22:00:34 +00:00
|
|
|
Destination: &settings.Update,
|
2022-05-29 20:04:57 +00:00
|
|
|
Category: category,
|
2020-09-19 22:00:34 +00:00
|
|
|
},
|
2021-06-13 16:21:20 +00:00
|
|
|
&cli.BoolFlag{
|
|
|
|
Name: "skip-missing",
|
|
|
|
EnvVars: []string{"PLUGIN_SKIP_MISSING", "GITHUB_COMMENT_SKIP_MISSING"},
|
2022-05-29 20:06:59 +00:00
|
|
|
Usage: "skip creation of comment if message file does not exist",
|
2021-09-12 13:16:43 +00:00
|
|
|
Value: false,
|
2021-06-13 16:21:20 +00:00
|
|
|
Destination: &settings.SkipMissing,
|
2022-05-29 20:04:57 +00:00
|
|
|
Category: category,
|
2021-06-13 16:21:20 +00:00
|
|
|
},
|
2020-09-19 22:00:34 +00:00
|
|
|
}
|
|
|
|
}
|