artifacts

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadProjects

func ReadProjects(ctx context.Context, client *gitlab.Client, opts Options) <-chan pooling.PoolerFunc

ReadProjects reads all projects from gitlab api and send them into the output channel. The output channel is closed once all projects were sent into it.

func Run

func Run(ctx context.Context, client *gitlab.Client, opts Options) error

Run retrieves gitlab projects and filters the one not appropriate with options (paths regexps).

For every appropriate project, it will retrieve jobs and delete outdated artifacts according to input option threshold.

Types

type Artifact

type Artifact struct {
	Size int
}

Artifact represents a simplified view of a gitlab artifact.

type Job

type Job struct {
	Artifacts         []Artifact `builder:"append"`
	ArtifactsExpireAt time.Time
	ID                int
	ProjectID         int
}

Job is a simplified view of a gitlab job with only useful information for artifacts deletion feature.

func (Job) DeleteArtifacts

func (j Job) DeleteArtifacts(ctx context.Context, client *gitlab.Client) pooling.PoolerFunc

DeleteArtifacts returns a pooling PoolerFunc to be executed in a specific pool to delete job's artifacts.

If a specific job doesn't have artifacts, then nothing will be done in the returned function.

func (Job) NeedCleanup

func (j Job) NeedCleanup(thresholdSize int, thresholdTime time.Time) bool

NeedCleanup returns truthy if the job needs to be cleaned up.

type Options

type Options struct {
	DryRun            bool
	PathRegexps       []*regexp.Regexp `builder:"append"`
	Paths             []string         `builder:"append" validate:"required,dive,required"`
	ThresholdSize     int              `                 validate:"required,gt=0"`
	ThresholdDuration time.Duration    `                 validate:"required,gt=0"`
	ThresholdTime     time.Time
}

Options is the struct containing all available options in artifacts command.

func (*Options) EnsureDefaults

func (c *Options) EnsureDefaults() error

EnsureDefaults ensures that all options in CleanOpts are valid or valued with their default values.

type Project

type Project struct {
	ID                int
	PathWithNamespace string
}

Project is a simplified view of a gitlab project with only useful information used during artifacts command.

func (Project) CleanArtifacts

func (p Project) CleanArtifacts(ctx context.Context, client *gitlab.Client, opts Options) pooling.PoolerFunc

CleanArtifacts returns the function to clean artifacts a specific project.

This function retrieves all project's jobs and send them into pooling PoolerFunc input channel.

Jump to

Keyboard shortcuts

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