mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-01 04:21:36 +01:00
Merge pull request #8581 from ywk253100/190806_retention_disable_chart
Comment the related code for chart retention
This commit is contained in:
commit
a00b1aab8d
@ -118,6 +118,7 @@ func (bc *basicClient) GetCandidates(repository *res.Repository) ([]*res.Candida
|
||||
}
|
||||
candidates = append(candidates, candidate)
|
||||
}
|
||||
/*
|
||||
case res.Chart:
|
||||
charts, err := bc.coreClient.ListAllCharts(repository.Namespace, repository.Name)
|
||||
if err != nil {
|
||||
@ -135,11 +136,12 @@ func (bc *basicClient) GetCandidates(repository *res.Repository) ([]*res.Candida
|
||||
Tag: chart.Name,
|
||||
Labels: labels,
|
||||
CreationTime: chart.Created.Unix(),
|
||||
PushedTime: time.Now().Unix() - (int64)((rand.Int31n(5)+5)*24*3600),
|
||||
PulledTime: time.Now().Unix() - (int64)((rand.Int31n(4))*24*3600),
|
||||
PushedTime: ,
|
||||
PulledTime: ,
|
||||
}
|
||||
candidates = append(candidates, candidate)
|
||||
}
|
||||
*/
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported repository kind: %s", repository.Kind)
|
||||
}
|
||||
@ -154,8 +156,10 @@ func (bc *basicClient) DeleteRepository(repo *res.Repository) error {
|
||||
switch repo.Kind {
|
||||
case res.Image:
|
||||
return bc.coreClient.DeleteImageRepository(repo.Namespace, repo.Name)
|
||||
/*
|
||||
case res.Chart:
|
||||
return bc.coreClient.DeleteChartRepository(repo.Namespace, repo.Name)
|
||||
*/
|
||||
default:
|
||||
return fmt.Errorf("unsupported repository kind: %s", repo.Kind)
|
||||
}
|
||||
@ -169,8 +173,10 @@ func (bc *basicClient) Delete(candidate *res.Candidate) error {
|
||||
switch candidate.Kind {
|
||||
case res.Image:
|
||||
return bc.coreClient.DeleteImage(candidate.Namespace, candidate.Repository, candidate.Tag)
|
||||
/*
|
||||
case res.Chart:
|
||||
return bc.coreClient.DeleteChart(candidate.Namespace, candidate.Repository, candidate.Tag)
|
||||
*/
|
||||
default:
|
||||
return fmt.Errorf("unsupported candidate kind: %s", candidate.Kind)
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ func (c *clientTestSuite) TestGetCandidates() {
|
||||
assert.Equal(c.T(), "hello-world", candidates[0].Repository)
|
||||
assert.Equal(c.T(), "latest", candidates[0].Tag)
|
||||
|
||||
/*
|
||||
// chart repository
|
||||
repository.Kind = res.Chart
|
||||
repository.Namespace = "goharbor"
|
||||
@ -101,6 +102,7 @@ func (c *clientTestSuite) TestGetCandidates() {
|
||||
assert.Equal(c.T(), res.Chart, candidates[0].Kind)
|
||||
assert.Equal(c.T(), "goharbor", candidates[0].Namespace)
|
||||
assert.Equal(c.T(), "1.0", candidates[0].Tag)
|
||||
*/
|
||||
}
|
||||
|
||||
func (c *clientTestSuite) TestDelete() {
|
||||
@ -118,10 +120,12 @@ func (c *clientTestSuite) TestDelete() {
|
||||
err = client.Delete(candidate)
|
||||
require.Nil(c.T(), err)
|
||||
|
||||
/*
|
||||
// chart
|
||||
candidate.Kind = res.Chart
|
||||
err = client.Delete(candidate)
|
||||
require.Nil(c.T(), err)
|
||||
*/
|
||||
|
||||
// unsupported type
|
||||
candidate.Kind = "unsupported"
|
||||
|
@ -338,10 +338,12 @@ func getProjects(projectMgr project.Manager) ([]*res.Candidate, error) {
|
||||
func getRepositories(projectMgr project.Manager, repositoryMgr repository.Manager,
|
||||
projectID int64, chartServerEnabled bool) ([]*res.Candidate, error) {
|
||||
var candidates []*res.Candidate
|
||||
/*
|
||||
pro, err := projectMgr.Get(projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
*/
|
||||
// get image repositories
|
||||
imageRepositories, err := repositoryMgr.ListImageRepositories(projectID)
|
||||
if err != nil {
|
||||
@ -355,6 +357,8 @@ func getRepositories(projectMgr project.Manager, repositoryMgr repository.Manage
|
||||
Kind: "image",
|
||||
})
|
||||
}
|
||||
// currently, doesn't support retention for chart
|
||||
/*
|
||||
if chartServerEnabled {
|
||||
// get chart repositories when chart server is enabled
|
||||
chartRepositories, err := repositoryMgr.ListChartRepositories(projectID)
|
||||
@ -369,6 +373,7 @@ func getRepositories(projectMgr project.Manager, repositoryMgr repository.Manage
|
||||
})
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return candidates, nil
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ func (l *launchTestSuite) TestGetProjects() {
|
||||
func (l *launchTestSuite) TestGetRepositories() {
|
||||
repositories, err := getRepositories(l.projectMgr, l.repositoryMgr, 1, true)
|
||||
require.Nil(l.T(), err)
|
||||
assert.Equal(l.T(), 3, len(repositories))
|
||||
assert.Equal(l.T(), 2, len(repositories))
|
||||
assert.Equal(l.T(), "library", repositories[0].Namespace)
|
||||
assert.Equal(l.T(), "image", repositories[0].Repository)
|
||||
assert.Equal(l.T(), "image", repositories[0].Kind)
|
||||
@ -274,7 +274,7 @@ func (l *launchTestSuite) TestLaunch() {
|
||||
}
|
||||
n, err = launcher.Launch(ply, 1, false)
|
||||
require.Nil(l.T(), err)
|
||||
assert.Equal(l.T(), int64(3), n)
|
||||
assert.Equal(l.T(), int64(2), n)
|
||||
}
|
||||
|
||||
func (l *launchTestSuite) TestStop() {
|
||||
|
Loading…
Reference in New Issue
Block a user