Documentation
¶
Index ¶
- Constants
- func GetTaskDescription(task *cirrus.GetBuildBuildTasksTask) string
- type AuthService
- func (s *AuthService) CreateForgejoClient(ctx context.Context, auth *model.ForgejoAuth) (*gitea.Client, error)
- func (s *AuthService) ExchangeCode(ctx context.Context, issuer, code string) (*model.ForgejoAuth, error)
- func (s *AuthService) GetAuthorizationURL(issuer, state string) string
- func (s *AuthService) LoginWithAccessToken(ctx context.Context, issuer, token string) (*model.ForgejoAuth, error)
- func (s *AuthService) RefreshTokenIfNeeded(ctx context.Context, auth *model.ForgejoAuth) error
- func (s *AuthService) UpdateCirrusConfig(ctx context.Context, authID int32, apiKey, ghRepo, ghOwner string) error
- type CirrusService
- func (s *CirrusService) GetBuildStatus(ctx context.Context, buildID string) (*cirrus.GetBuildResponse, error)
- func (s *CirrusService) GetRepoInfo(ctx context.Context, owner, repo string) (*cirrus.GetRepoInfoResponse, error)
- func (s *CirrusService) SubmitBuild(ctx context.Context, input cirrus.RepositoryCreateBuildInput) (*cirrus.SubmitBuildResponse, error)
- type PollerService
- type PushEvent
- type PushEventCommit
- type PushEventRepo
- type PushEventUser
- type RepoService
- func (s *RepoService) ConstructWebhookUrl(webhookToken string) string
- func (s *RepoService) DisableCirrusCI(ctx context.Context, auth *model.ForgejoAuth, owner, repo string) error
- func (s *RepoService) EnableCirrusCI(ctx context.Context, auth *model.ForgejoAuth, owner, repo string) (*model.RepoInstallation, error)
- func (s *RepoService) GetRepoStatus(ctx context.Context, authID int32, owner, repo string) (bool, *model.RepoInstallation, error)
- func (s *RepoService) ListUserRepos(ctx context.Context, auth *model.ForgejoAuth) ([]*RepoWithStatus, error)
- type RepoWithStatus
- type WebhookService
Constants ¶
const ( PollingInterval = 30 * time.Second MinWorkerInterval = 20 * time.Second MaxWorkerInterval = 30 * time.Second )
const (
CirrusAPIEndpoint = "https://api.cirrus-ci.com/graphql"
)
Variables ¶
This section is empty.
Functions ¶
func GetTaskDescription ¶
func GetTaskDescription(task *cirrus.GetBuildBuildTasksTask) string
Types ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService handles OAuth and authentication operations
func NewAuthService ¶
func NewAuthService(clientID, clientSecret, redirectURL string, forgejoAuthDal dal.ForgejoAuthDal) *AuthService
NewAuthService creates a new authentication service
func (*AuthService) CreateForgejoClient ¶
func (s *AuthService) CreateForgejoClient(ctx context.Context, auth *model.ForgejoAuth) (*gitea.Client, error)
CreateForgejoClient creates a Gitea client with automatic token refresh
func (*AuthService) ExchangeCode ¶
func (s *AuthService) ExchangeCode(ctx context.Context, issuer, code string) (*model.ForgejoAuth, error)
ExchangeCode exchanges an authorization code for tokens
func (*AuthService) GetAuthorizationURL ¶
func (s *AuthService) GetAuthorizationURL(issuer, state string) string
GetAuthorizationURL generates the OAuth authorization URL for the given issuer
func (*AuthService) LoginWithAccessToken ¶
func (s *AuthService) LoginWithAccessToken(ctx context.Context, issuer, token string) (*model.ForgejoAuth, error)
LoginWithAccessToken authenticates using an access token directly
func (*AuthService) RefreshTokenIfNeeded ¶
func (s *AuthService) RefreshTokenIfNeeded(ctx context.Context, auth *model.ForgejoAuth) error
RefreshTokenIfNeeded checks if the token needs refresh and refreshes it
func (*AuthService) UpdateCirrusConfig ¶
func (s *AuthService) UpdateCirrusConfig(ctx context.Context, authID int32, apiKey, ghRepo, ghOwner string) error
UpdateCirrusConfig updates the Cirrus CI configuration for an auth
type CirrusService ¶
type CirrusService struct {
// contains filtered or unexported fields
}
CirrusService wraps the GraphQL client for Cirrus CI operations
func NewCirrusService ¶
func NewCirrusService(apiKey string) *CirrusService
NewCirrusService creates a new Cirrus service with the given API key
func (*CirrusService) GetBuildStatus ¶
func (s *CirrusService) GetBuildStatus(ctx context.Context, buildID string) (*cirrus.GetBuildResponse, error)
GetBuildStatus queries the status of a build
func (*CirrusService) GetRepoInfo ¶
func (s *CirrusService) GetRepoInfo(ctx context.Context, owner, repo string) (*cirrus.GetRepoInfoResponse, error)
GetRepoInfo retrieves Cirrus CI repository information
func (*CirrusService) SubmitBuild ¶
func (s *CirrusService) SubmitBuild(ctx context.Context, input cirrus.RepositoryCreateBuildInput) (*cirrus.SubmitBuildResponse, error)
SubmitBuild submits a new build to Cirrus CI
type PollerService ¶
type PollerService struct {
// contains filtered or unexported fields
}
PollerService polls Cirrus CI for build status updates
func NewPollerService ¶
func NewPollerService( authService *AuthService, forgejoAuthDal dal.ForgejoAuthDal, repoInstallationDal dal.RepoInstallationDal, buildDal dal.BuildDal, ) *PollerService
NewPollerService creates a new poller service
func (*PollerService) Start ¶
func (s *PollerService) Start(ctx context.Context)
Start begins the polling loop
func (*PollerService) Stop ¶
func (s *PollerService) Stop()
Stop gracefully stops the polling service
type PushEvent ¶
type PushEvent struct {
Ref string `json:"ref"`
After string `json:"after"`
Repository *PushEventRepo `json:"repository"`
HeadCommit *PushEventCommit `json:"head_commit"`
}
PushEvent represents a Forgejo push event
type PushEventCommit ¶
type PushEventRepo ¶
type PushEventRepo struct {
Name string `json:"name"`
FullName string `json:"full_name"`
Owner *PushEventUser `json:"owner"`
}
type PushEventUser ¶
type RepoService ¶
type RepoService struct {
// contains filtered or unexported fields
}
RepoService handles repository operations
func NewRepoService ¶
func NewRepoService(baseURL string, authService *AuthService, repoInstallationDal dal.RepoInstallationDal) *RepoService
NewRepoService creates a new repository service
func (*RepoService) ConstructWebhookUrl ¶
func (s *RepoService) ConstructWebhookUrl(webhookToken string) string
func (*RepoService) DisableCirrusCI ¶
func (s *RepoService) DisableCirrusCI(ctx context.Context, auth *model.ForgejoAuth, owner, repo string) error
DisableCirrusCI disables Cirrus CI for a repository by removing the webhook
func (*RepoService) EnableCirrusCI ¶
func (s *RepoService) EnableCirrusCI(ctx context.Context, auth *model.ForgejoAuth, owner, repo string) (*model.RepoInstallation, error)
EnableCirrusCI enables Cirrus CI for a repository by creating a webhook
func (*RepoService) GetRepoStatus ¶
func (s *RepoService) GetRepoStatus(ctx context.Context, authID int32, owner, repo string) (bool, *model.RepoInstallation, error)
GetRepoStatus checks if Cirrus CI is enabled for a repository
func (*RepoService) ListUserRepos ¶
func (s *RepoService) ListUserRepos(ctx context.Context, auth *model.ForgejoAuth) ([]*RepoWithStatus, error)
ListUserRepos retrieves all repositories for a user with installation status
type RepoWithStatus ¶
type RepoWithStatus struct {
Repository *gitea.Repository
Enabled bool
}
RepoWithStatus represents a repository with its Cirrus CI installation status
type WebhookService ¶
type WebhookService struct {
// contains filtered or unexported fields
}
WebhookService handles webhook processing
func NewWebhookService ¶
func NewWebhookService( authService *AuthService, forgejoAuthDal dal.ForgejoAuthDal, repoInstallationDal dal.RepoInstallationDal, buildDal dal.BuildDal, ) *WebhookService
NewWebhookService creates a new webhook service
func (*WebhookService) HandlePushEvent ¶
func (s *WebhookService) HandlePushEvent(ctx context.Context, payload []byte, installation *model.RepoInstallation) error
HandlePushEvent processes a push webhook event
func (*WebhookService) VerifySignature ¶
func (s *WebhookService) VerifySignature(payload []byte, signature, secret string) bool
VerifySignature verifies the HMAC-SHA256 signature of a webhook payload