mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-01 04:21:36 +01:00
Merge pull request #8529 from bitsf/tag_retention_disable_rule
add disable rule feature for tag retention
This commit is contained in:
commit
92c2cfa35a
@ -65,6 +65,36 @@ func (s *ControllerTestSuite) TestPolicy() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ID: 2,
|
||||||
|
Priority: 1,
|
||||||
|
Template: "recentXdays",
|
||||||
|
Disabled: true,
|
||||||
|
Parameters: rule.Parameters{
|
||||||
|
"num": 3,
|
||||||
|
},
|
||||||
|
TagSelectors: []*rule.Selector{
|
||||||
|
{
|
||||||
|
Kind: "label",
|
||||||
|
Decoration: "with",
|
||||||
|
Pattern: "latest",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Kind: "regularExpression",
|
||||||
|
Decoration: "matches",
|
||||||
|
Pattern: "release-[\\d\\.]+",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ScopeSelectors: map[string][]*rule.Selector{
|
||||||
|
"repository": {
|
||||||
|
{
|
||||||
|
Kind: "regularExpression",
|
||||||
|
Decoration: "matches",
|
||||||
|
Pattern: ".+",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Trigger: &policy.Trigger{
|
Trigger: &policy.Trigger{
|
||||||
Kind: "Schedule",
|
Kind: "Schedule",
|
||||||
|
@ -124,6 +124,10 @@ func (l *launcher) Launch(ply *policy.Metadata, executionID int64, isDryRun bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, rule := range ply.Rules {
|
for _, rule := range ply.Rules {
|
||||||
|
if rule.Disabled {
|
||||||
|
log.Infof("Policy %d rule %d %s is disabled", ply.ID, rule.ID, rule.Template)
|
||||||
|
continue
|
||||||
|
}
|
||||||
projectCandidates := allProjects
|
projectCandidates := allProjects
|
||||||
switch level {
|
switch level {
|
||||||
case "system":
|
case "system":
|
||||||
|
@ -251,6 +251,25 @@ func (l *launchTestSuite) TestLaunch() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Disabled: true,
|
||||||
|
ScopeSelectors: map[string][]*rule.Selector{
|
||||||
|
"project": {
|
||||||
|
{
|
||||||
|
Kind: "doublestar",
|
||||||
|
Decoration: "nsMatches",
|
||||||
|
Pattern: "library1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
{
|
||||||
|
Kind: "doublestar",
|
||||||
|
Decoration: "repoMatches",
|
||||||
|
Pattern: "**",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
n, err = launcher.Launch(ply, 1, false)
|
n, err = launcher.Launch(ply, 1, false)
|
||||||
|
@ -22,6 +22,9 @@ type Metadata struct {
|
|||||||
// Priority of rule when doing calculating
|
// Priority of rule when doing calculating
|
||||||
Priority int `json:"priority" valid:"Required"`
|
Priority int `json:"priority" valid:"Required"`
|
||||||
|
|
||||||
|
// Disabled rule
|
||||||
|
Disabled bool `json:"disabled"`
|
||||||
|
|
||||||
// Action of the rule performs
|
// Action of the rule performs
|
||||||
// "retain"
|
// "retain"
|
||||||
Action string `json:"action" valid:"Required"`
|
Action string `json:"action" valid:"Required"`
|
||||||
|
Loading…
Reference in New Issue
Block a user