mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
Merge pull request #8867 from bitsf/tag_retention_same_digest_tag
Tag retention same digest tag
This commit is contained in:
commit
9fa70db866
@ -109,6 +109,7 @@ func (bc *basicClient) GetCandidates(repository *res.Repository) ([]*res.Candida
|
||||
Namespace: repository.Namespace,
|
||||
Repository: repository.Name,
|
||||
Tag: image.Name,
|
||||
Digest: image.Digest,
|
||||
Labels: labels,
|
||||
CreationTime: image.Created.Unix(),
|
||||
PulledTime: image.PullTime.Unix(),
|
||||
|
@ -119,6 +119,7 @@ func (frc *fakeRetentionClient) GetCandidates(repo *res.Repository) ([]*res.Cand
|
||||
Repository: "harbor",
|
||||
Kind: "image",
|
||||
Tag: "latest",
|
||||
Digest: "latest",
|
||||
PushedTime: time.Now().Unix() - 11,
|
||||
PulledTime: time.Now().Unix() - 2,
|
||||
CreationTime: time.Now().Unix() - 10,
|
||||
@ -129,6 +130,7 @@ func (frc *fakeRetentionClient) GetCandidates(repo *res.Repository) ([]*res.Cand
|
||||
Repository: "harbor",
|
||||
Kind: "image",
|
||||
Tag: "dev",
|
||||
Digest: "dev",
|
||||
PushedTime: time.Now().Unix() - 10,
|
||||
PulledTime: time.Now().Unix() - 3,
|
||||
CreationTime: time.Now().Unix() - 20,
|
||||
|
@ -47,6 +47,7 @@ func (suite *TestPerformerSuite) SetupSuite() {
|
||||
Repository: "harbor",
|
||||
Kind: "image",
|
||||
Tag: "latest",
|
||||
Digest: "latest",
|
||||
PushedTime: time.Now().Unix(),
|
||||
Labels: []string{"L1", "L2"},
|
||||
},
|
||||
@ -55,6 +56,7 @@ func (suite *TestPerformerSuite) SetupSuite() {
|
||||
Repository: "harbor",
|
||||
Kind: "image",
|
||||
Tag: "dev",
|
||||
Digest: "dev",
|
||||
PushedTime: time.Now().Unix(),
|
||||
Labels: []string{"L3"},
|
||||
},
|
||||
@ -81,6 +83,7 @@ func (suite *TestPerformerSuite) TestPerform() {
|
||||
Repository: "harbor",
|
||||
Kind: "image",
|
||||
Tag: "latest",
|
||||
Digest: "latest",
|
||||
PushedTime: time.Now().Unix(),
|
||||
Labels: []string{"L1", "L2"},
|
||||
},
|
||||
|
@ -56,6 +56,7 @@ func (suite *ProcessorTestSuite) SetupSuite() {
|
||||
Repository: "harbor",
|
||||
Kind: "image",
|
||||
Tag: "latest",
|
||||
Digest: "latest",
|
||||
PushedTime: time.Now().Unix(),
|
||||
Labels: []string{"L1", "L2"},
|
||||
},
|
||||
@ -64,6 +65,7 @@ func (suite *ProcessorTestSuite) SetupSuite() {
|
||||
Repository: "harbor",
|
||||
Kind: "image",
|
||||
Tag: "dev",
|
||||
Digest: "dev",
|
||||
PushedTime: time.Now().Unix(),
|
||||
Labels: []string{"L3"},
|
||||
},
|
||||
|
@ -73,6 +73,7 @@ func (suite *TestBuilderSuite) SetupSuite() {
|
||||
Repository: "harbor",
|
||||
Kind: "image",
|
||||
Tag: "latest",
|
||||
Digest: "latest",
|
||||
PushedTime: time.Now().Unix(),
|
||||
Labels: []string{"L1", "L2"},
|
||||
},
|
||||
@ -82,6 +83,7 @@ func (suite *TestBuilderSuite) SetupSuite() {
|
||||
Repository: "harbor",
|
||||
Kind: "image",
|
||||
Tag: "dev",
|
||||
Digest: "dev",
|
||||
PushedTime: time.Now().Unix(),
|
||||
Labels: []string{"L3"},
|
||||
},
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/goharbor/harbor/src/common/utils/log"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@ -72,6 +73,8 @@ type Candidate struct {
|
||||
Kind string
|
||||
// Tag info
|
||||
Tag string
|
||||
// Digest
|
||||
Digest string
|
||||
// Pushed time in seconds
|
||||
PushedTime int64
|
||||
// Pulled time in seconds
|
||||
@ -84,7 +87,10 @@ type Candidate struct {
|
||||
|
||||
// Hash code based on the candidate info for differentiation
|
||||
func (c *Candidate) Hash() string {
|
||||
raw := fmt.Sprintf("%s:%s/%s:%s", c.Kind, c.Namespace, c.Repository, c.Tag)
|
||||
if c.Digest == "" {
|
||||
log.Errorf("Lack Digest of Candidate for %s/%s:%s", c.Namespace, c.Repository, c.Tag)
|
||||
}
|
||||
raw := fmt.Sprintf("%s:%s/%s:%s", c.Kind, c.Namespace, c.Repository, c.Digest)
|
||||
|
||||
return base64.StdEncoding.EncodeToString([]byte(raw))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user