Skip to content

Commit

Permalink
Incorporated review comments. Added tests, fixed docs, utilize resty/…
Browse files Browse the repository at this point in the history
…http library for HTTP calls for BBServer
  • Loading branch information
gdasson committed Nov 3, 2023
1 parent 92fbba6 commit b633a65
Show file tree
Hide file tree
Showing 8 changed files with 431 additions and 180 deletions.
45 changes: 22 additions & 23 deletions api/v1beta1/provider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
// ProviderSpec defines the desired state of Provider
type ProviderSpec struct {
// Type of provider
// +kubebuilder:validation:Enum=slack;discord;msteams;rocket;generic;generic-hmac;github;gitlab;bitbucketserver;bitbucket;azuredevops;googlechat;webex;sentry;azureeventhub;telegram;lark;matrix;opsgenie;alertmanager;grafana;githubdispatch;
// +kubebuilder:validation:Enum=slack;discord;msteams;rocket;generic;generic-hmac;github;gitlab;bitbucket;azuredevops;googlechat;webex;sentry;azureeventhub;telegram;lark;matrix;opsgenie;alertmanager;grafana;githubdispatch;
// +required
Type string `json:"type"`

Expand Down Expand Up @@ -77,28 +77,27 @@ type ProviderSpec struct {
}

const (
GenericProvider string = "generic"
GenericHMACProvider string = "generic-hmac"
SlackProvider string = "slack"
GrafanaProvider string = "grafana"
DiscordProvider string = "discord"
MSTeamsProvider string = "msteams"
RocketProvider string = "rocket"
GitHubDispatchProvider string = "githubdispatch"
GitHubProvider string = "github"
GitLabProvider string = "gitlab"
BitbucketServerProvider string = "bitbucketserver"
BitbucketProvider string = "bitbucket"
AzureDevOpsProvider string = "azuredevops"
GoogleChatProvider string = "googlechat"
WebexProvider string = "webex"
SentryProvider string = "sentry"
AzureEventHubProvider string = "azureeventhub"
TelegramProvider string = "telegram"
LarkProvider string = "lark"
Matrix string = "matrix"
OpsgenieProvider string = "opsgenie"
AlertManagerProvider string = "alertmanager"
GenericProvider string = "generic"
GenericHMACProvider string = "generic-hmac"
SlackProvider string = "slack"
GrafanaProvider string = "grafana"
DiscordProvider string = "discord"
MSTeamsProvider string = "msteams"
RocketProvider string = "rocket"
GitHubDispatchProvider string = "githubdispatch"
GitHubProvider string = "github"
GitLabProvider string = "gitlab"
BitbucketProvider string = "bitbucket"
AzureDevOpsProvider string = "azuredevops"
GoogleChatProvider string = "googlechat"
WebexProvider string = "webex"
SentryProvider string = "sentry"
AzureEventHubProvider string = "azureeventhub"
TelegramProvider string = "telegram"
LarkProvider string = "lark"
Matrix string = "matrix"
OpsgenieProvider string = "opsgenie"
AlertManagerProvider string = "alertmanager"
)

// ProviderStatus defines the observed state of Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ spec:
- generic-hmac
- github
- gitlab
- bitbucketserver
- bitbucket
- azuredevops
- googlechat
Expand Down
35 changes: 6 additions & 29 deletions docs/spec/v1beta2/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -1514,44 +1514,21 @@ You can create the secret with `kubectl` like this:
kubectl create secret generic bitbucket-token --from-literal=token=<username>:<app-password>
```

#### BitBucketServer
#### BitBucketServer/Data Center

For bitbucketserver (a.k.a. Bitbucket Data Center), the following auth methods are available: <br /> a) Basic Auth(username/password)
<br />
When `.spec.type` is set to `bitbucket`, the following auth methods are available: <br />
a) Basic Auth(username/password) <br />
b) [HTTP access tokens](https://confluence.atlassian.com/bitbucketserver/http-access-tokens-939515499.html)

For Basic Auth(username/password), the secret should be created in following format:
For Basic Authentication, the referenced secret must contain a `username` and a `password` field

```
apiVersion: v1
data:
password: Qml0YnVja2V0QDIwMjM=
username: Zm9vYmFydXNlcg==
kind: Secret
metadata:
name: bb-server-username-password
type: Opaque
```

You may create the secret using this command as well:
You can create the secret with `kubectl` like this:

```shell
kubectl create secret generic bb-server-username-password --from-literal=username=<username> --from-literal=password=<password>
```

For HTTP access tokens, the secret should be created in following format:

```
apiVersion: v1
data:
token: QkJEQy1PREl4T0RZeE16SXlOelV5T3R0b3JNak8wNTlQMnJZVGI2RUg3bVBPTTVUbw==
kind: Secret
metadata:
name: bb-server-token
type: Opaque
```

You may create the secret using this command as well:
For HTTP access tokens, the secret can be created like this:

```shell
kubectl create secret generic bb-server-token --from-literal=token=<token>
Expand Down
18 changes: 10 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ replace github.com/fluxcd/notification-controller/api => ./api

require (
cloud.google.com/go/pubsub v1.33.0
code.gitea.io/sdk/gitea v0.15.1
code.gitea.io/sdk/gitea v0.16.0
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24
github.com/Azure/azure-amqp-common-go/v4 v4.2.0
github.com/Azure/azure-event-hubs-go/v3 v3.6.1
github.com/DataDog/datadog-api-client-go/v2 v2.15.0
github.com/PagerDuty/go-pagerduty v1.7.0
github.com/antihax/optional v1.0.0
github.com/containrrr/shoutrrr v0.8.0
github.com/fluxcd/notification-controller/api v1.1.0
github.com/fluxcd/pkg/apis/event v0.5.2
Expand All @@ -21,20 +20,20 @@ require (
github.com/fluxcd/pkg/masktoken v0.2.0
github.com/fluxcd/pkg/runtime v0.42.0
github.com/fluxcd/pkg/ssa v0.32.0
github.com/gdasson/bitbucketv1go v1.0.0
github.com/getsentry/sentry-go v0.23.0
github.com/go-logr/logr v1.2.4
github.com/go-resty/resty/v2 v2.10.0
github.com/google/go-github/v53 v53.2.0
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/ktrysmt/go-bitbucket v0.9.66
github.com/ktrysmt/go-bitbucket v0.9.68
github.com/microsoft/azure-devops-go-api/azuredevops/v6 v6.0.1
github.com/onsi/gomega v1.27.10
github.com/onsi/gomega v1.28.0
github.com/sethvargo/go-limiter v0.7.2
github.com/slok/go-http-metrics v0.10.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/whilp/git-urls v1.0.0
github.com/xanzy/go-gitlab v0.90.0
github.com/xanzy/go-gitlab v0.93.1
golang.org/x/oauth2 v0.13.0
golang.org/x/text v0.13.0
google.golang.org/api v0.138.0
Expand Down Expand Up @@ -68,13 +67,14 @@ require (
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidmz/go-pageant v1.0.2 // indirect
github.com/devigned/tab v0.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
Expand All @@ -84,6 +84,7 @@ require (
github.com/fluxcd/pkg/apis/acl v0.1.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-fed/httpsig v1.1.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
Expand Down Expand Up @@ -137,13 +138,14 @@ require (
go.opencensus.io v0.24.0 // indirect
go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.13.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
Expand Down
Loading

0 comments on commit b633a65

Please sign in to comment.