diff --git a/_docs/data/data.yaml b/_docs/data/data.yaml index 66ac850..2d5bcf6 100644 --- a/_docs/data/data.yaml +++ b/_docs/data/data.yaml @@ -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. diff --git a/cmd/drone-github-comment/config.go b/cmd/drone-github-comment/config.go index d316608..972c6de 100644 --- a/cmd/drone-github-comment/config.go +++ b/cmd/drone-github-comment/config.go @@ -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", diff --git a/plugin/comment.go b/plugin/comment.go index 04281ae..10c8500 100644 --- a/plugin/comment.go +++ b/plugin/comment.go @@ -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 diff --git a/plugin/impl.go b/plugin/impl.go index f07c127..79ca296 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -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)