Documentation ¶
Index ¶
- func BitbucketHandler(r *BitbucketWebhookReceiver) http.Handler
- func GetRepoNames(bitbucketClient bitbucket.RepoClientInterface, projectKey string) ([]string, error)
- func HealthHandler() http.Handler
- type BitbucketWebhookReceiver
- type BitbucketWebhookReceiverBase
- type PipelineConfig
- type PipelineInfo
- type Pruner
- type Scheduler
- type StorageConfig
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BitbucketHandler ¶
func BitbucketHandler(r *BitbucketWebhookReceiver) http.Handler
func GetRepoNames ¶
func GetRepoNames(bitbucketClient bitbucket.RepoClientInterface, projectKey string) ([]string, error)
GetRepoNames retrieves the name of all repositories within the project identified by projectKey.
func HealthHandler ¶
Types ¶
type BitbucketWebhookReceiver ¶
type BitbucketWebhookReceiver struct { // Channel to send new runs to TriggeredPipelines chan PipelineConfig // Logger is the logger to send logging messages to. Logger logging.LeveledLoggerInterface // BitbucketClient is a client to interact with Bitbucket. BitbucketClient bitbucketInterface // WebhookSecret is the shared Bitbucket secret to validate webhook requests. WebhookSecret string BitbucketWebhookReceiverBase }
BitbucketWebhookReceiver receives webhook requests from Bitbucket.
func (*BitbucketWebhookReceiver) Handle ¶
func (s *BitbucketWebhookReceiver) Handle(w http.ResponseWriter, r *http.Request) (any, error)
Handle handles Bitbucket requests. It extracts pipeline data from the request body and sends the gained data to the scheduler.
type PipelineConfig ¶
type PipelineConfig struct { PipelineInfo PVC string PipelineSpec config.Pipeline Params []tekton.Param }
PipelineConfig holds configuration for a triggered pipeline.
type PipelineInfo ¶
type PipelineInfo struct { Project string `json:"project"` Component string `json:"component"` Repository string `json:"repository"` GitRef string `json:"gitRef"` GitFullRef string `json:"gitFullRef"` GitSHA string `json:"gitSha"` RepoBase string `json:"repoBase"` GitURI string `json:"gitURI"` Namespace string `json:"namespace"` TriggerEvent string `json:"trigger-event"` ChangeRefType string `json:"change-ref-type"` Comment string `json:"comment"` PullRequestKey int `json:"prKey"` PullRequestBase string `json:"prBase"` }
PipelineInfo holds information about a triggered pipeline.
type Pruner ¶
type Pruner struct { // TriggeredRepos receives repo names for each triggered repository. TriggeredRepos chan string // TektonClient is a client to interact with Tekton. TektonClient tektonClient.ClientInterface Logger logging.LeveledLoggerInterface // MinKeepHours specifies the minimum hours to keep a pipeline run. // This setting has precendence over MaxKeepRuns. MinKeepHours int // MaxKeepRuns is the maximum number of pipeline runs to keep. MaxKeepRuns int // contains filtered or unexported fields }
Pruner prunes pipeline runs. It's behaviour can be controlled through MinKeepHours and MaxKeepRuns. When pruning, it keeps MaxKeepRuns number of pipeline runs, however it always keeps all pipeline runs less than MinKeepHours old.
type Scheduler ¶
type Scheduler struct { // Channel to read newly received runs from TriggeredPipelines chan PipelineConfig // Channel to send triggered repos on (signalling to start pruning) TriggeredRepos chan string // Channel to send pending runs on (singalling to start watching) PendingRunRepos chan string TektonClient tektonClient.ClientInterface KubernetesClient kubernetesClient.ClientInterface Logger logging.LeveledLoggerInterface StorageConfig StorageConfig }
Scheduler creates or updates pipelines based on PipelineConfig received from the TriggeredPipelines channel. It then schedules a pipeline run connected to the pipeline. If the run cannot start immediately because of another run, the new pipeline run is created in pending status.
type StorageConfig ¶
type Watcher ¶
type Watcher struct { // PendingRunRepos receives repositories for which there is a new // pending pipeline run. PendingRunRepos chan string // Queues holds repositories for which there are pending runs. Queues map[string]bool Logger logging.LeveledLoggerInterface TektonClient tektonClient.ClientPipelineRunInterface }
Watcher watches pending pipeline run queues. Runs are queued per repository.