Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCallbackURLNotConfigured is returned when BITBUCKET__CALLBACK_URL is // empty and webhook management requires it. ErrCallbackURLNotConfigured = errors.New("bitbucket callback url not configured") // ErrCallbackURLInvalid is returned when the callback URL is not https or // carries a query string or fragment. ErrCallbackURLInvalid = errors.New("bitbucket callback url invalid") // ErrSecretNotConfigured is returned when WEBHOOKS__SECRET is empty and // registration requires a verifiable secret. ErrSecretNotConfigured = errors.New("webhook secret not configured") // ErrOAuthDisabled is returned when the Bitbucket OAuth service is // disabled by configuration. ErrOAuthDisabled = errors.New("bitbucket oauth disabled") // ErrOAuthNotConnected is returned when no usable OAuth token exists. ErrOAuthNotConnected = errors.New("bitbucket oauth not connected") // ErrNotBitbucketRepo is returned when a project repository URL is not a // bitbucket.org URL. ErrNotBitbucketRepo = errors.New("not a bitbucket repository") )
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Secret is the shared signing secret Bitbucket attaches to deliveries
// and the service registers on managed hooks.
Secret string
// CallbackURL is the public base URL (https scheme://host[/path], no
// query string or fragment) where Bitbucket webhooks are delivered. The
// full delivery path is appended by the management service.
CallbackURL string
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages Bitbucket repository webhooks for projects, gated on the requesting admin's OAuth token. It is fully stateless.
func NewService ¶
func NewService( config Config, client *bitbucket.Client, oauthSvc *oauth.Service, projectsSvc *projects.Service, logger *zap.Logger, ) *Service
NewService wires the management service. The Bitbucket client is the leaf pkg/bitbucket client; the OAuth service resolves the requesting admin's token; the projects service resolves slugs to repositories.
func (*Service) Register ¶
func (s *Service) Register(ctx context.Context, userID int64, projectSlug string) (*WebhookStatus, error)
Register creates the project webhook in Bitbucket, or updates the existing one when a hook already targets our callback URL. Registration fails closed on an empty secret or invalid callback URL.
func (*Service) Status ¶
func (s *Service) Status(ctx context.Context, userID int64, projectSlug string) (*WebhookStatus, error)
Status reports the live Bitbucket webhook state for a project. Local prerequisites (callback URL, OAuth connection) are reported as an unavailable status instead of errors; a missing secret never blocks status.