Documentation
¶
Index ¶
- Constants
- type DefaultManager
- func (d *DefaultManager) CreatePolicy(ctx context.Context, p *policy.Metadata) (int64, error)
- func (d *DefaultManager) DeletePolicy(ctx context.Context, id int64) error
- func (d *DefaultManager) GetPolicy(ctx context.Context, id int64) (*policy.Metadata, error)
- func (d *DefaultManager) ListPolicyIDs(ctx context.Context, query *q.Query) ([]int64, error)
- func (d *DefaultManager) UpdatePolicy(ctx context.Context, p *policy.Metadata) error
- type Execution
- type History
- type Job
- type Launcher
- type Manager
- type Task
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 ¶
CreatePolicy Create Policy
func (*DefaultManager) DeletePolicy ¶
func (d *DefaultManager) DeletePolicy(ctx context.Context, id int64) error
DeletePolicy Delete Policy
func (*DefaultManager) ListPolicyIDs ¶
ListPolicyIDs list policy id by query
func (*DefaultManager) UpdatePolicy ¶
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 ¶
MaxCurrency is implementation of same method in Interface.
func (*Job) ShouldRetry ¶
ShouldRetry indicates job can be retried if failed
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
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
Click to show internal directories.
Click to hide internal directories.