policy

package
v0.0.0-...-562c01e Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// AlgorithmOR for OR algorithm
	AlgorithmOR = "or"

	// TriggerKindSchedule Schedule
	TriggerKindSchedule = "Schedule"

	// TriggerSettingsCron cron
	TriggerSettingsCron = "cron"

	// TriggerSettingNextScheduledTime next_scheduled_time
	TriggerSettingNextScheduledTime = "next_scheduled_time"

	// ScopeLevelProject project
	ScopeLevelProject = "project"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder interface {
	// Builds runnable processor
	//
	//  Arguments:
	//    policy *Metadata : the simple metadata of retention policy
	//    isDryRun bool    : indicate if we need to build a processor for dry run
	//
	//  Returns:
	//    Processor : a processor implementation to process the candidates
	//    error     : common error object if any errors occurred
	Build(policy *lwp.Metadata, isDryRun bool) (alg.Processor, error)
}

Builder builds the runnable processor from the raw policy

func NewBuilder

func NewBuilder(all []*selector.Candidate) Builder

NewBuilder news a basic builder

type Metadata

type Metadata struct {
	// ID of the policy
	ID int64 `json:"id"`

	// Algorithm applied to the rules
	// "OR" / "AND"
	Algorithm string `json:"algorithm" valid:"Required;Match(or)"`

	// Rule collection
	Rules []rule.Metadata `json:"rules"`

	// Trigger about how to launch the policy
	Trigger *Trigger `json:"trigger" valid:"Required"`

	// Which scope the policy will be applied to
	Scope *Scope `json:"scope" valid:"Required"`
}

Metadata of policy

func WithNDaysSinceLastPull

func WithNDaysSinceLastPull(projID int64, n int) *Metadata

WithNDaysSinceLastPull build a retention rule to keep images n days to since last pull

func (*Metadata) Valid

func (m *Metadata) Valid(v *validation.Validation)

Valid Valid

func (*Metadata) ValidateRetentionPolicy

func (m *Metadata) ValidateRetentionPolicy() error

ValidateRetentionPolicy validate the retention policy

type Scope

type Scope struct {
	// Scope level declaration
	// 'system', 'project' and 'repository'
	Level string `json:"level" valid:"Required;Match(/^(project)$/)"`

	// The reference identity for the specified level
	// 0 for 'system', project ID for 'project' and repo ID for 'repository'
	Reference int64 `json:"ref" valid:"Required"`
}

Scope definition

type Trigger

type Trigger struct {
	// Const string to declare the trigger type
	// 'Schedule'
	Kind string `json:"kind" valid:"Required"`

	// Settings for the specified trigger
	// '[cron]="* 22 11 * * *"' for the 'Schedule'
	Settings map[string]interface{} `json:"settings" valid:"Required"`
}

Trigger of the policy

Directories

Path Synopsis
alg
or
Package lwp = lightweight policy
Package lwp = lightweight policy

Jump to

Keyboard shortcuts

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