retention

package
v0.0.0-...-fba4c40 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ParamRepo ...
	ParamRepo = "repository"
	// ParamMeta ...
	ParamMeta = "liteMeta"
	// ParamDryRun ...
	ParamDryRun = "dryRun"
)
View Source
const (
	ExecutionStatusInProgress string = "InProgress"
	ExecutionStatusSucceed    string = "Succeed"
	ExecutionStatusFailed     string = "Failed"
	ExecutionStatusStopped    string = "Stopped"

	CandidateKindImage string = "image"

	ExecutionTriggerManual   string = "Manual"
	ExecutionTriggerSchedule string = "Schedule"
)

const definitions

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultManager

type DefaultManager struct {
}

DefaultManager ...

func (*DefaultManager) CreatePolicy

func (d *DefaultManager) CreatePolicy(ctx context.Context, p *policy.Metadata) (int64, error)

CreatePolicy Create Policy

func (*DefaultManager) DeletePolicy

func (d *DefaultManager) DeletePolicy(ctx context.Context, id int64) error

DeletePolicy Delete Policy

func (*DefaultManager) GetPolicy

func (d *DefaultManager) GetPolicy(ctx context.Context, id int64) (*policy.Metadata, error)

GetPolicy Get Policy

func (*DefaultManager) ListPolicyIDs

func (d *DefaultManager) ListPolicyIDs(ctx context.Context, query *q.Query) ([]int64, error)

ListPolicyIDs list policy id by query

func (*DefaultManager) UpdatePolicy

func (d *DefaultManager) UpdatePolicy(ctx context.Context, p *policy.Metadata) error

UpdatePolicy Update Policy

type Execution

type Execution struct {
	ID        int64     `json:"id"`
	PolicyID  int64     `json:"policy_id"`
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time,omitempty"`
	Status    string    `json:"status"`
	Trigger   string    `json:"trigger"`
	DryRun    bool      `json:"dry_run"`
	Operator  string    `json:"operator"`
	Type      string    `json:"-"`
}

Execution of retention

type History

type History struct {
	ID          int64 `json:"id,omitempty"`
	ExecutionID int64 `json:"execution_id"`
	Rule        struct {
		ID          int    `json:"id"`
		DisplayText string `json:"display_text"`
	} `json:"rule_id"`
	// full path: :ns/:repo:tag
	Artifact  string    `json:"tag"`
	Timestamp time.Time `json:"timestamp"`
}

History of retention

type Job

type Job struct{}

Job of running retention process

func (*Job) MaxCurrency

func (pj *Job) MaxCurrency() uint

MaxCurrency is implementation of same method in Interface.

func (*Job) MaxFails

func (pj *Job) MaxFails() uint

MaxFails of the job

func (*Job) Run

func (pj *Job) Run(ctx job.Context, params job.Parameters) error

Run the job

func (*Job) ShouldRetry

func (pj *Job) ShouldRetry() bool

ShouldRetry indicates job can be retried if failed

func (*Job) Validate

func (pj *Job) Validate(params job.Parameters) (err error)

Validate the parameters

type Launcher

type Launcher interface {
	// Launch async jobs for the retention policy
	// A separate job will be launched for each repository
	//
	//  Arguments:
	//   policy *policy.Metadata: the policy info
	//   executionID int64      : the execution ID
	//   isDryRun bool          : indicate if it is a dry run
	//
	//  Returns:
	//   int64               : the count of tasks
	//   error               : common error if any errors occurred
	Launch(ctx context.Context, policy *policy.Metadata, executionID int64, isDryRun bool) (int64, error)
	// Stop the jobs for one execution
	//
	//  Arguments:
	//   executionID int64 : the execution ID
	//
	//  Returns:
	//   error : common error if any errors occurred
	Stop(ctx context.Context, executionID int64) error
}

Launcher provides function to launch the async jobs to run retentions based on the provided policy.

func NewLauncher

func NewLauncher(projectMgr project.Manager, repositoryMgr repository.Manager,
	retentionMgr Manager, execMgr task.ExecutionManager, taskMgr task.Manager) Launcher

NewLauncher returns an instance of Launcher

type Manager

type Manager interface {
	// Create new policy and return ID
	CreatePolicy(ctx context.Context, p *policy.Metadata) (int64, error)
	// Update the existing policy
	// Full update
	UpdatePolicy(ctx context.Context, p *policy.Metadata) error
	// Delete the specified policy
	// No actual use so far
	DeletePolicy(ctx context.Context, id int64) error
	// Get the specified policy
	GetPolicy(ctx context.Context, id int64) (*policy.Metadata, error)
	// List the retention policy with query conditions
	ListPolicyIDs(ctx context.Context, query *q.Query) ([]int64, error)
}

Manager defines operations of managing policy

func NewManager

func NewManager() Manager

NewManager ...

type Task

type Task struct {
	ID             int64     `json:"id"`
	ExecutionID    int64     `json:"execution_id"`
	Repository     string    `json:"repository"`
	JobID          string    `json:"job_id"`
	Status         string    `json:"status"`
	StatusCode     int       `json:"status_code"`
	StatusRevision int64     `json:"status_revision"`
	StartTime      time.Time `json:"start_time"`
	EndTime        time.Time `json:"end_time"`
	Total          int       `json:"total"`
	Retained       int       `json:"retained"`
}

Task of retention

Directories

Path Synopsis
dao
alg
lwp
Package lwp = lightweight policy
Package lwp = lightweight policy
q

Jump to

Keyboard shortcuts

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