-
Notifications
You must be signed in to change notification settings - Fork 131
feat(bitbucketdatacenter): allow service accounts to not require user setup #2726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -276,9 +276,6 @@ func removeLastSegment(urlStr string) string { | |||||||
| } | ||||||||
|
|
||||||||
| func (v *Provider) SetClient(ctx context.Context, run *params.Run, event *info.Event, repo *v1alpha1.Repository, _ *events.EventEmitter) error { | ||||||||
| if event.Provider.User == "" { | ||||||||
| return fmt.Errorf("no spec.git_provider.user has been set in the repo crd") | ||||||||
| } | ||||||||
| if event.Provider.Token == "" { | ||||||||
| return fmt.Errorf("no spec.git_provider.secret has been set in the repo crd") | ||||||||
| } | ||||||||
|
|
@@ -317,14 +314,23 @@ func (v *Provider) SetClient(ctx context.Context, run *params.Run, event *info.E | |||||||
| v.run = run | ||||||||
| v.repo = repo | ||||||||
| v.triggerEvent = event.EventType | ||||||||
| _, resp, err := v.Client().Users.FindLogin(ctx, event.Provider.User) | ||||||||
|
|
||||||||
| var resp *scm.Response | ||||||||
| var err error | ||||||||
|
zakisk marked this conversation as resolved.
|
||||||||
| // we only need a valid token to access rest api | ||||||||
| _, resp, err = v.Client().Users.Find(ctx) | ||||||||
| if resp != nil && resp.Status == http.StatusUnauthorized { | ||||||||
| return fmt.Errorf("cannot get user %s with token: %w", event.Provider.User, err) | ||||||||
| return fmt.Errorf("token validation failed: unauthorized") | ||||||||
| } | ||||||||
| if resp != nil && resp.Status == http.StatusInternalServerError { | ||||||||
| return fmt.Errorf("token validation failed: Internal Server Error") | ||||||||
| } | ||||||||
|
Comment on lines
+325
to
327
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is very less likely to happen...
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you assume... I know well enough the bitbucket when we do upgrades, sometimes plugins have strange behaviors during the upgrade requiring further reboots of the BB DC. |
||||||||
| if err != nil { | ||||||||
| return fmt.Errorf("cannot get user %s: %w", event.Provider.User, err) | ||||||||
| return fmt.Errorf("token validation failed: http status: %d : %w", resp.Status, err) | ||||||||
| } | ||||||||
|
zakisk marked this conversation as resolved.
|
||||||||
|
|
||||||||
| // the token must have admin permissions at project or repository level | ||||||||
|
|
||||||||
| return nil | ||||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of removing info about access token, you should specify both that PaC supports both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just matched the docs from Bitbucket, since personal, project or repository tokens are all called HTTP access tokens now.
So I am not removing info, just matching the same docs and added to the warning for the case of personal ones.