mirror of
https://github.com/thegeeklab/drone-github-comment.git
synced 2024-11-21 18:20:40 +00:00
chore: use required cli flags instead of manual validation (#108)
This commit is contained in:
parent
5ce87cc2ed
commit
24542f9e4a
@ -3,7 +3,7 @@ properties:
|
||||
api_key:
|
||||
description: Personal Access token to access the GitHub API.
|
||||
type: string
|
||||
required: false
|
||||
required: true
|
||||
|
||||
base_url:
|
||||
description: API URL. Only need to be changed for GitHub enterprise in most cases
|
||||
@ -17,9 +17,9 @@ properties:
|
||||
required: false
|
||||
|
||||
message:
|
||||
description: File or string that contains the comment text.
|
||||
description: Path to file or string that contains the comment text.
|
||||
type: string
|
||||
required: false
|
||||
required: true
|
||||
|
||||
update:
|
||||
description: Enables update of an existing comment that matches the key.
|
||||
|
@ -14,6 +14,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
Usage: "personal access token access github api",
|
||||
Destination: &settings.APIKey,
|
||||
Category: category,
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "base-url",
|
||||
@ -36,6 +37,7 @@ func settingsFlags(settings *plugin.Settings, category string) []cli.Flag {
|
||||
Usage: "file or string that holds the comment text",
|
||||
Destination: &settings.Message,
|
||||
Category: category,
|
||||
Required: true,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "update",
|
||||
|
@ -47,7 +47,7 @@ func (cc *commentClient) issueComment() error {
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add or update comment: %w", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -34,13 +34,6 @@ func (p *Plugin) Validate() error {
|
||||
return fmt.Errorf("github comment plugin is only available for pull requests")
|
||||
}
|
||||
|
||||
if p.settings.APIKey == "" {
|
||||
return fmt.Errorf("no api key provided")
|
||||
}
|
||||
|
||||
if p.settings.Message == "" {
|
||||
return fmt.Errorf("no message provides")
|
||||
}
|
||||
if p.settings.Message != "" {
|
||||
if p.settings.Message, p.settings.IsFile, err = readStringOrFile(p.settings.Message); err != nil {
|
||||
return fmt.Errorf("error while reading %s: %w", p.settings.Message, err)
|
||||
|
Loading…
Reference in New Issue
Block a user