Bump github.com/ktrysmt/go-bitbucket from 0.9.50 to 0.9.54 (#250)

Bumps [github.com/ktrysmt/go-bitbucket](https://github.com/ktrysmt/go-bitbucket) from 0.9.50 to 0.9.54.
- [Release notes](https://github.com/ktrysmt/go-bitbucket/releases)
- [Commits](https://github.com/ktrysmt/go-bitbucket/compare/v0.9.50...v0.9.54)

---
updated-dependencies:
- dependency-name: github.com/ktrysmt/go-bitbucket
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot]
2022-10-01 09:25:51 -07:00
committed by GitHub
parent 87f90493a2
commit 1e251d5183
7 changed files with 91 additions and 9 deletions

2
go.mod
View File

@@ -8,7 +8,7 @@ require (
github.com/fatih/color v1.13.0
github.com/google/go-github/v41 v41.0.0
github.com/korovkin/limiter v0.0.0-20220422174850-01f593e64cf7
github.com/ktrysmt/go-bitbucket v0.9.50
github.com/ktrysmt/go-bitbucket v0.9.54
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.13.0

4
go.sum
View File

@@ -163,8 +163,8 @@ github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/ktrysmt/go-bitbucket v0.9.50 h1:xZcYssIrrj9KODEZFlZCu/KEsveBGRoc+i+wlSVZhFk=
github.com/ktrysmt/go-bitbucket v0.9.50/go.mod h1:aB/IUpoFE65X84soIfgUPT53bzp/jfYoffLN2mg3bFc=
github.com/ktrysmt/go-bitbucket v0.9.54 h1:QRuLyUCuxsWs+7EL5YLbvT6oijNWSmk2C4/yp1yIjM0=
github.com/ktrysmt/go-bitbucket v0.9.54/go.mod h1:aB/IUpoFE65X84soIfgUPT53bzp/jfYoffLN2mg3bFc=
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=

View File

@@ -139,6 +139,28 @@ func NewOAuthWithCode(i, s, c string) (*Client, string) {
return injectClient(a), tok.AccessToken
}
// NewOAuthWithRefreshToken obtains a new access token with a given refresh token
// and returns a *Client
func NewOAuthWithRefreshToken(i, s, rt string) (*Client, string) {
a := &auth{appID: i, secret: s}
ctx := context.Background()
conf := &oauth2.Config{
ClientID: i,
ClientSecret: s,
Endpoint: bitbucket.Endpoint,
}
tokenSource := conf.TokenSource(ctx, &oauth2.Token{
RefreshToken: rt,
})
tok, err := tokenSource.Token()
if err != nil {
log.Fatal(err)
}
a.token = *tok
return injectClient(a), tok.AccessToken
}
func NewOAuthbearerToken(t string) *Client {
a := &auth{bearerToken: t}
return injectClient(a)

View File

@@ -26,6 +26,7 @@ type Repository struct {
Language string
Is_private bool
Has_issues bool
Has_wiki bool
Mainbranch RepositoryBranch
Type string
CreatedOn string `mapstructure:"created_on"`
@@ -119,9 +120,7 @@ type PipelineVariable struct {
type PipelineKeyPair struct {
Type string
Uuid string
PublicKey string
PrivateKey string
Public_key string
}
type PipelineBuildNumber struct {
@@ -725,6 +724,17 @@ func (r *Repository) UpdatePipelineVariable(opt *RepositoryPipelineVariableOptio
return decodePipelineVariableRepository(response)
}
func (r *Repository) GetPipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions) (*PipelineKeyPair, error) {
urlStr := r.c.requestUrl("/repositories/%s/%s/pipelines_config/ssh/key_pair", rpkpo.Owner, rpkpo.RepoSlug)
response, err := r.c.execute("GET", urlStr, "")
if err != nil {
return nil, err
}
return decodePipelineKeyPairRepository(response)
}
func (r *Repository) AddPipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions) (*PipelineKeyPair, error) {
data, err := r.buildPipelineKeyPairBody(rpkpo)
if err != nil {
@@ -740,6 +750,11 @@ func (r *Repository) AddPipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions)
return decodePipelineKeyPairRepository(response)
}
func (r *Repository) DeletePipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions) (interface{}, error) {
urlStr := r.c.requestUrl("/repositories/%s/%s/pipelines_config/ssh/key_pair", rpkpo.Owner, rpkpo.RepoSlug)
return r.c.execute("DELETE", urlStr, "")
}
func (r *Repository) UpdatePipelineBuildNumber(rpbno *RepositoryPipelineBuildNumberOptions) (*PipelineBuildNumber, error) {
data, err := r.buildPipelineBuildNumberBody(rpbno)
if err != nil {
@@ -1535,7 +1550,7 @@ func decodeEnvironments(response string) (*Environments, error) {
if errs == nil {
errs = err
} else {
errs = fmt.Errorf("%w; environment %d: %w", errs, idx, err)
errs = fmt.Errorf("%w; environment %d: %v", errs, idx, err)
}
} else {
environmentsArray = append(environmentsArray, environment)
@@ -1612,7 +1627,7 @@ func decodeDeploymentVariables(response string) (*DeploymentVariables, error) {
if errs == nil {
errs = err
} else {
errs = fmt.Errorf("%w; deployment variable %d: %w", errs, idx, err)
errs = fmt.Errorf("%w; deployment variable %d: %v", errs, idx, err)
}
} else {
variablesArray = append(variablesArray, variable)

View File

@@ -0,0 +1,22 @@
package bitbucket
const (
RepoPushEvent string = "repo:push"
RepoForkEvent string = "repo:fork"
RepoUpdatedEvent string = "repo:updated"
RepoCommitCommentCreatedEvent string = "repo:commit_comment_created"
RepoCommitStatusCreatedEvent string = "repo:commit_status_created"
RepoCommitStatusUpdatedEvent string = "repo:commit_status_updated"
IssueCreatedEvent string = "issue:created"
IssueUpdatedEvent string = "issue:updated"
IssueCommentCreatedEvent string = "issue:comment_created"
PullRequestCreatedEvent string = "pullrequest:created"
PullRequestUpdatedEvent string = "pullrequest:updated"
PullRequestApprovedEvent string = "pullrequest:approved"
PullRequestUnapprovedEvent string = "pullrequest:unapproved"
PullRequestMergedEvent string = "pullrequest:fulfilled"
PullRequestDeclinedEvent string = "pullrequest:rejected"
PullRequestCommentCreatedEvent string = "pullrequest:comment_created"
PullRequestCommentUpdatedEvent string = "pullrequest:comment_updated"
PullRequestCommentDeletedEvent string = "pullrequest:comment_deleted"
)

View File

@@ -36,6 +36,19 @@ func decodeWebhook(response interface{}) (*Webhook, error) {
return webhook, nil
}
func decodeWebhooks(response interface{}) ([]Webhook, error) {
webhooks := make([]Webhook, 0)
resMap := response.(map[string]interface{})
for _, v := range resMap["values"].([]interface{}) {
wh, err := decodeWebhook(v)
if err != nil {
return nil, err
}
webhooks = append(webhooks, *wh)
}
return webhooks, nil
}
func (r *Webhooks) buildWebhooksBody(ro *WebhooksOptions) (string, error) {
body := map[string]interface{}{}
@@ -59,6 +72,16 @@ func (r *Webhooks) buildWebhooksBody(ro *WebhooksOptions) (string, error) {
return string(data), nil
}
func (r *Webhooks) List(ro *WebhooksOptions) ([]Webhook, error) {
urlStr := r.c.requestUrl("/repositories/%s/%s/hooks/", ro.Owner, ro.RepoSlug)
res, err := r.c.executePaginated("GET", urlStr, "")
if err != nil {
return nil, err
}
return decodeWebhooks(res)
}
// Deprecate Gets for List call
func (r *Webhooks) Gets(ro *WebhooksOptions) (interface{}, error) {
urlStr := r.c.requestUrl("/repositories/%s/%s/hooks/", ro.Owner, ro.RepoSlug)
return r.c.executePaginated("GET", urlStr, "")

2
vendor/modules.txt vendored
View File

@@ -46,7 +46,7 @@ github.com/inconshreveable/mousetrap
# github.com/korovkin/limiter v0.0.0-20220422174850-01f593e64cf7
## explicit; go 1.17
github.com/korovkin/limiter
# github.com/ktrysmt/go-bitbucket v0.9.50
# github.com/ktrysmt/go-bitbucket v0.9.54
## explicit; go 1.14
github.com/ktrysmt/go-bitbucket
# github.com/magiconair/properties v1.8.6