Skip to content

Commit

Permalink
Set secret token in CreateHook only if non-empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
chhsia0 committed Aug 25, 2020
1 parent fdc0060 commit ef3531e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scm/driver/gitlab/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ func (s *repositoryService) ListStatus(ctx context.Context, repo, ref string, op
func (s *repositoryService) CreateHook(ctx context.Context, repo string, input *scm.HookInput) (*scm.Hook, *scm.Response, error) {
params := url.Values{}
params.Set("url", input.Target)
params.Set("token", input.Secret)
// Earlier versions of gitlab returns an error if the token was an empty string, so we only set the
// token value if non-empty.
if input.Secret != "" {
params.Set("token", input.Secret)
}
params.Set("enable_ssl_verification", strconv.FormatBool(!input.SkipVerify))
for k, v := range convertFromHookEvents(input.Events) {
params.Set(k, strconv.FormatBool(v))
Expand Down

0 comments on commit ef3531e

Please sign in to comment.