manager

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

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

func HealthHandler() http.Handler

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

Handle handles Bitbucket requests. It extracts pipeline data from the request body and sends the gained data to the scheduler.

type BitbucketWebhookReceiverBase

type BitbucketWebhookReceiverBase struct {
	// Namespace is the Kubernetes namespace in which the server runs.
	Namespace string
	// Project is the Bitbucket project to which this server corresponds.
	Project string
	// RepoBase is the common URL base of all repositories on Bitbucket.
	RepoBase string
}

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.

func (*Pruner) Run

func (p *Pruner) Run(ctx context.Context)

Run starts the pruning process by calling run. This indirection facilitates testing.

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.

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context)

Run starts the scheduling process.

type StorageConfig

type StorageConfig struct {
	Provisioner string
	ClassName   string
	Size        string
}

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.

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context)

Run starts monitoring and advancing the queues.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL