mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-15 11:21:49 +01:00
prevent retained tag with same digest deleted by other tag
Signed-off-by: Ziming Zhang <zziming@vmware.com> Change-Id: I6a69b405b454ca0350677204e06bfa2b24616b33
This commit is contained in:
parent
3f5ecd1f9c
commit
063f2bfee9
@ -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(),
|
||||
|
@ -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"},
|
||||
},
|
||||
|
@ -72,6 +72,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 +86,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 == "" {
|
||||
panic("Lack Digest of Candidate")
|
||||
}
|
||||
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