Documentation ¶
Index ¶
- Constants
- func ToTagSelectorExtras(untagged bool) string
- type Client
- type ErrRetentionDoesNotExist
- type ErrRetentionInternalErrors
- type ErrRetentionNoPermission
- type ErrRetentionNotProvided
- type ErrRetentionUnauthorized
- type PolicyTemplate
- type RESTClient
- func (c *RESTClient) DisableRetentionPolicy(ctx context.Context, ret *modelv2.RetentionPolicy) error
- func (c *RESTClient) GetRetentionPolicyByID(ctx context.Context, id int64) (*modelv2.RetentionPolicy, error)
- func (c *RESTClient) GetRetentionPolicyByProject(ctx context.Context, project *modelv2.Project) (*modelv2.RetentionPolicy, error)
- func (c *RESTClient) NewRetentionPolicy(ctx context.Context, ret *modelv2.RetentionPolicy) error
- func (c *RESTClient) UpdateRetentionPolicy(ctx context.Context, ret *modelv2.RetentionPolicy) error
- type ScopeSelector
- type TagSelector
Constants ¶
const ( // AlgorithmOr is the default algorithm when operating on harbor retention rules AlgorithmOr string = "or" // Key for defining matching repositories ScopeSelectorRepoMatches ScopeSelector = "repoMatches" // Key for defining excluded repositories ScopeSelectorRepoExcludes ScopeSelector = "repoExcludes" // Key for defining matching tag expressions TagSelectorMatches TagSelector = "matches" // Key for defining excluded tag expressions TagSelectorExcludes TagSelector = "excludes" // The kind of the retention selector, _always_ defaults to 'doublestar' SelectorTypeDefault string = "doublestar" // Retain the most recently pushed n artifacts - count PolicyTemplateLatestPushedArtifacts PolicyTemplate = "latestPushedK" // Retain the most recently pulled n artifacts - count PolicyTemplateLatestPulledArtifacts PolicyTemplate = "latestPulledN" // Retain the artifacts pushed within the last n days PolicyTemplateDaysSinceLastPush PolicyTemplate = "nDaysSinceLastPush" // Retain the artifacts pulled within the last n days PolicyTemplateDaysSinceLastPull PolicyTemplate = "nDaysSinceLastPull" // Retain always PolicyTemplateRetainAlways PolicyTemplate = "always" )
const ( // ErrRetentionNoPermissionMsg is the error message for ErrRetentionNoPermission error. ErrRetentionNoPermissionMsg = "user does not have permission to the retention" // ErrRetentionInternalErrorsMsg is the error message for ErrRetentionInternalErrors error. ErrRetentionInternalErrorsMsg = "unexpected internal errors" // ErrRetentionDoesNotExistMsg is the error message for ErrRetentionDoesNotExist error. ErrRetentionDoesNotExistMsg = "retention policy does not exist" // ErrRetentionNotProvidedMsg is the error message for ErrRetentionNotProvided error. ErrRetentionNotProvidedMsg = "no retention policy provided" )ErrRetentionUnauthorizedMsg = "unauthorized"
Variables ¶
This section is empty.
Functions ¶
func ToTagSelectorExtras ¶
ToTagSelectorExtras converts a boolean to the representative string value used by Harbor. Represents the functionality of the 'untagged artifacts' checkbox when editing tag retention rules in the Harbor UI.
Types ¶
type Client ¶
type Client interface { NewRetentionPolicy(ctx context.Context, ret *modelv2.RetentionPolicy) error GetRetentionPolicyByProject(ctx context.Context, project *modelv2.Project) (*modelv2.RetentionPolicy, error) GetRetentionPolicyByID(ctx context.Context, id int64) (*modelv2.RetentionPolicy, error) DisableRetentionPolicy(ctx context.Context, ret *modelv2.RetentionPolicy) error UpdateRetentionPolicy(ctx context.Context, ret *modelv2.RetentionPolicy) error }
type ErrRetentionDoesNotExist ¶
type ErrRetentionDoesNotExist struct{}
ErrRetentionDoesNotExist describes the absence of a retention policy.
func (*ErrRetentionDoesNotExist) Error ¶
func (e *ErrRetentionDoesNotExist) Error() string
Error returns the error message.
type ErrRetentionInternalErrors ¶
type ErrRetentionInternalErrors struct{}
ErrRetentionInternalErrors describes server-side internal errors.
func (*ErrRetentionInternalErrors) Error ¶
func (e *ErrRetentionInternalErrors) Error() string
Error returns the error message.
type ErrRetentionNoPermission ¶
type ErrRetentionNoPermission struct{}
ErrRetentionNoPermission describes a request error without permission.
func (*ErrRetentionNoPermission) Error ¶
func (e *ErrRetentionNoPermission) Error() string
Error returns the error message.
type ErrRetentionNotProvided ¶
type ErrRetentionNotProvided struct{}
ErrRetentionNotProvided describes a missing retention instance
func (*ErrRetentionNotProvided) Error ¶
func (e *ErrRetentionNotProvided) Error() string
Error returns the error message.
type ErrRetentionUnauthorized ¶
type ErrRetentionUnauthorized struct{}
ErrRetentionUnauthorized describes an unauthorized request.
func (*ErrRetentionUnauthorized) Error ¶
func (e *ErrRetentionUnauthorized) Error() string
Error returns the error message.
type PolicyTemplate ¶
type PolicyTemplate string
PolicyTemplate defines the possible values used for the policy matching mechanism.
func (PolicyTemplate) String ¶
func (p PolicyTemplate) String() string
type RESTClient ¶
type RESTClient struct { // The swagger client LegacyClient *client.Harbor V2Client *v2client.Harbor // AuthInfo contains the auth information that is provided on API calls. AuthInfo runtime.ClientAuthInfoWriter }
RESTClient is a subclient for handling retention related actions.
func NewClient ¶
func NewClient(legacyClient *client.Harbor, v2Client *v2client.Harbor, authInfo runtime.ClientAuthInfoWriter) *RESTClient
func (*RESTClient) DisableRetentionPolicy ¶
func (c *RESTClient) DisableRetentionPolicy(ctx context.Context, ret *modelv2.RetentionPolicy) error
DisableRetentionPolicy replaces the rules of a retention policy with an empty set of rules. As of Harbor v2.2.1, the swagger specifications do not contain a DELETE route for retention policies, but instead PUT a retention policy with a dummy retention rule. This function provides the same functionality as "Action -> Delete" when editing retention rules in the GUI. TODO: replace this method with a new one 'DeleteRetentionPolicy' once the delete route for the retention API [^1] has been released. [^1]: https://github.com/goharbor/harbor/pull/14747/commits/81e5aa715b98b39fbf729048c34fe46c3af31505
func (*RESTClient) GetRetentionPolicyByID ¶
func (c *RESTClient) GetRetentionPolicyByID(ctx context.Context, id int64) (*modelv2.RetentionPolicy, error)
GetRetentionPolicyByID returns a retention policy identified by it's id.
func (*RESTClient) GetRetentionPolicyByProject ¶
func (c *RESTClient) GetRetentionPolicyByProject(ctx context.Context, project *modelv2.Project) (*modelv2.RetentionPolicy, error)
GetRetentionPolicyByProject returns a retention policy that is fetched by the metadata value contained in a project's metadata.
func (*RESTClient) NewRetentionPolicy ¶
func (c *RESTClient) NewRetentionPolicy(ctx context.Context, ret *modelv2.RetentionPolicy) error
NewRetentionPolicy creates a new tag retention policy for a project.
func (*RESTClient) UpdateRetentionPolicy ¶
func (c *RESTClient) UpdateRetentionPolicy(ctx context.Context, ret *modelv2.RetentionPolicy) error
UpdateRetentionPolicy updates the specified retention policy ret.
type ScopeSelector ¶
type ScopeSelector string
ScopeSelector is the retention selector decoration used for operations on retention objects.
func (ScopeSelector) String ¶
func (r ScopeSelector) String() string
type TagSelector ¶
type TagSelector string
TagSelector defines the possible values used for the tag matching mechanism. Valid values are: "matches, excludes".
func (TagSelector) String ¶
func (t TagSelector) String() string
String returns the string value of a TagSelector.