Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions gitlab_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@
},
UserID: pat.UserID,
}
// Set an artificial expiry date one year after creation if none is set.
// This addresses issue #178 where a token could be issued without an expiry.
// Note: As of GitLab 16.x, all tokens should have an expiry set.
if et.ExpiresAt == nil {
newDate := pat.CreatedAt.AddDate(1, 0, -2)
et.ExpiresAt = &newDate
}

Check warning on line 345 in gitlab_client.go

View check run for this annotation

Codecov / codecov/patch

gitlab_client.go#L343-L345

Added lines #L343 - L345 were not covered by tests
}
return et, err
}
Expand Down Expand Up @@ -567,11 +574,11 @@
var _ Client = new(gitlabClient)

func newGitlabClient(config *EntryConfig, httpClient *http.Client) (gc *g.Client, err error) {
if "" == strings.TrimSpace(config.BaseURL) {
if strings.TrimSpace(config.BaseURL) == "" {
err = errors.Join(err, fmt.Errorf("gitlab base url: %w", ErrInvalidValue))
}

if "" == strings.TrimSpace(config.Token) {
if strings.TrimSpace(config.Token) == "" {
err = errors.Join(err, fmt.Errorf("gitlab token: %w", ErrInvalidValue))
}

Expand Down