Merge pull request #8581 from ywk253100/190806_retention_disable_chart

Comment the related code for chart retention
This commit is contained in:
Wenkai Yin(尹文开) 2019-08-07 11:04:43 +08:00 committed by GitHub
commit a00b1aab8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 57 deletions

View File

@ -118,6 +118,7 @@ func (bc *basicClient) GetCandidates(repository *res.Repository) ([]*res.Candida
} }
candidates = append(candidates, candidate) candidates = append(candidates, candidate)
} }
/*
case res.Chart: case res.Chart:
charts, err := bc.coreClient.ListAllCharts(repository.Namespace, repository.Name) charts, err := bc.coreClient.ListAllCharts(repository.Namespace, repository.Name)
if err != nil { if err != nil {
@ -135,11 +136,12 @@ func (bc *basicClient) GetCandidates(repository *res.Repository) ([]*res.Candida
Tag: chart.Name, Tag: chart.Name,
Labels: labels, Labels: labels,
CreationTime: chart.Created.Unix(), CreationTime: chart.Created.Unix(),
PushedTime: time.Now().Unix() - (int64)((rand.Int31n(5)+5)*24*3600), PushedTime: ,
PulledTime: time.Now().Unix() - (int64)((rand.Int31n(4))*24*3600), PulledTime: ,
} }
candidates = append(candidates, candidate) candidates = append(candidates, candidate)
} }
*/
default: default:
return nil, fmt.Errorf("unsupported repository kind: %s", repository.Kind) 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 { switch repo.Kind {
case res.Image: case res.Image:
return bc.coreClient.DeleteImageRepository(repo.Namespace, repo.Name) return bc.coreClient.DeleteImageRepository(repo.Namespace, repo.Name)
/*
case res.Chart: case res.Chart:
return bc.coreClient.DeleteChartRepository(repo.Namespace, repo.Name) return bc.coreClient.DeleteChartRepository(repo.Namespace, repo.Name)
*/
default: default:
return fmt.Errorf("unsupported repository kind: %s", repo.Kind) return fmt.Errorf("unsupported repository kind: %s", repo.Kind)
} }
@ -169,8 +173,10 @@ func (bc *basicClient) Delete(candidate *res.Candidate) error {
switch candidate.Kind { switch candidate.Kind {
case res.Image: case res.Image:
return bc.coreClient.DeleteImage(candidate.Namespace, candidate.Repository, candidate.Tag) return bc.coreClient.DeleteImage(candidate.Namespace, candidate.Repository, candidate.Tag)
/*
case res.Chart: case res.Chart:
return bc.coreClient.DeleteChart(candidate.Namespace, candidate.Repository, candidate.Tag) return bc.coreClient.DeleteChart(candidate.Namespace, candidate.Repository, candidate.Tag)
*/
default: default:
return fmt.Errorf("unsupported candidate kind: %s", candidate.Kind) return fmt.Errorf("unsupported candidate kind: %s", candidate.Kind)
} }

View File

@ -91,6 +91,7 @@ func (c *clientTestSuite) TestGetCandidates() {
assert.Equal(c.T(), "hello-world", candidates[0].Repository) assert.Equal(c.T(), "hello-world", candidates[0].Repository)
assert.Equal(c.T(), "latest", candidates[0].Tag) assert.Equal(c.T(), "latest", candidates[0].Tag)
/*
// chart repository // chart repository
repository.Kind = res.Chart repository.Kind = res.Chart
repository.Namespace = "goharbor" repository.Namespace = "goharbor"
@ -101,6 +102,7 @@ func (c *clientTestSuite) TestGetCandidates() {
assert.Equal(c.T(), res.Chart, candidates[0].Kind) assert.Equal(c.T(), res.Chart, candidates[0].Kind)
assert.Equal(c.T(), "goharbor", candidates[0].Namespace) assert.Equal(c.T(), "goharbor", candidates[0].Namespace)
assert.Equal(c.T(), "1.0", candidates[0].Tag) assert.Equal(c.T(), "1.0", candidates[0].Tag)
*/
} }
func (c *clientTestSuite) TestDelete() { func (c *clientTestSuite) TestDelete() {
@ -118,10 +120,12 @@ func (c *clientTestSuite) TestDelete() {
err = client.Delete(candidate) err = client.Delete(candidate)
require.Nil(c.T(), err) require.Nil(c.T(), err)
/*
// chart // chart
candidate.Kind = res.Chart candidate.Kind = res.Chart
err = client.Delete(candidate) err = client.Delete(candidate)
require.Nil(c.T(), err) require.Nil(c.T(), err)
*/
// unsupported type // unsupported type
candidate.Kind = "unsupported" candidate.Kind = "unsupported"

View File

@ -338,10 +338,12 @@ func getProjects(projectMgr project.Manager) ([]*res.Candidate, error) {
func getRepositories(projectMgr project.Manager, repositoryMgr repository.Manager, func getRepositories(projectMgr project.Manager, repositoryMgr repository.Manager,
projectID int64, chartServerEnabled bool) ([]*res.Candidate, error) { projectID int64, chartServerEnabled bool) ([]*res.Candidate, error) {
var candidates []*res.Candidate var candidates []*res.Candidate
/*
pro, err := projectMgr.Get(projectID) pro, err := projectMgr.Get(projectID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
*/
// get image repositories // get image repositories
imageRepositories, err := repositoryMgr.ListImageRepositories(projectID) imageRepositories, err := repositoryMgr.ListImageRepositories(projectID)
if err != nil { if err != nil {
@ -355,6 +357,8 @@ func getRepositories(projectMgr project.Manager, repositoryMgr repository.Manage
Kind: "image", Kind: "image",
}) })
} }
// currently, doesn't support retention for chart
/*
if chartServerEnabled { if chartServerEnabled {
// get chart repositories when chart server is enabled // get chart repositories when chart server is enabled
chartRepositories, err := repositoryMgr.ListChartRepositories(projectID) chartRepositories, err := repositoryMgr.ListChartRepositories(projectID)
@ -369,6 +373,7 @@ func getRepositories(projectMgr project.Manager, repositoryMgr repository.Manage
}) })
} }
} }
*/
return candidates, nil return candidates, nil
} }

View File

@ -192,7 +192,7 @@ func (l *launchTestSuite) TestGetProjects() {
func (l *launchTestSuite) TestGetRepositories() { func (l *launchTestSuite) TestGetRepositories() {
repositories, err := getRepositories(l.projectMgr, l.repositoryMgr, 1, true) repositories, err := getRepositories(l.projectMgr, l.repositoryMgr, 1, true)
require.Nil(l.T(), err) 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(), "library", repositories[0].Namespace)
assert.Equal(l.T(), "image", repositories[0].Repository) assert.Equal(l.T(), "image", repositories[0].Repository)
assert.Equal(l.T(), "image", repositories[0].Kind) assert.Equal(l.T(), "image", repositories[0].Kind)
@ -274,7 +274,7 @@ func (l *launchTestSuite) TestLaunch() {
} }
n, err = launcher.Launch(ply, 1, false) n, err = launcher.Launch(ply, 1, false)
require.Nil(l.T(), err) require.Nil(l.T(), err)
assert.Equal(l.T(), int64(3), n) assert.Equal(l.T(), int64(2), n)
} }
func (l *launchTestSuite) TestStop() { func (l *launchTestSuite) TestStop() {