mirror of
https://github.com/thegeeklab/drone-github-comment.git
synced 2024-11-25 04:00:39 +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:
|
api_key:
|
||||||
description: Personal Access token to access the GitHub API.
|
description: Personal Access token to access the GitHub API.
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: true
|
||||||
|
|
||||||
base_url:
|
base_url:
|
||||||
description: API URL. Only need to be changed for GitHub enterprise in most cases
|
description: API URL. Only need to be changed for GitHub enterprise in most cases
|
||||||
@ -17,9 +17,9 @@ properties:
|
|||||||
required: false
|
required: false
|
||||||
|
|
||||||
message:
|
message:
|
||||||
description: File or string that contains the comment text.
|
description: Path to file or string that contains the comment text.
|
||||||
type: string
|
type: string
|
||||||
required: false
|
required: true
|
||||||
|
|
||||||
update:
|
update:
|
||||||
description: Enables update of an existing comment that matches the key.
|
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",
|
Usage: "personal access token access github api",
|
||||||
Destination: &settings.APIKey,
|
Destination: &settings.APIKey,
|
||||||
Category: category,
|
Category: category,
|
||||||
|
Required: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "base-url",
|
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",
|
Usage: "file or string that holds the comment text",
|
||||||
Destination: &settings.Message,
|
Destination: &settings.Message,
|
||||||
Category: category,
|
Category: category,
|
||||||
|
Required: true,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "update",
|
Name: "update",
|
||||||
|
@ -47,7 +47,7 @@ func (cc *commentClient) issueComment() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to add or update comment: %w", err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -34,13 +34,6 @@ func (p *Plugin) Validate() error {
|
|||||||
return fmt.Errorf("github comment plugin is only available for pull requests")
|
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 != "" {
|
||||||
if p.settings.Message, p.settings.IsFile, err = readStringOrFile(p.settings.Message); err != nil {
|
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)
|
return fmt.Errorf("error while reading %s: %w", p.settings.Message, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user