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,28 +118,30 @@ func (bc *basicClient) GetCandidates(repository *res.Repository) ([]*res.Candida
|
|||||||
}
|
}
|
||||||
candidates = append(candidates, candidate)
|
candidates = append(candidates, candidate)
|
||||||
}
|
}
|
||||||
case res.Chart:
|
/*
|
||||||
charts, err := bc.coreClient.ListAllCharts(repository.Namespace, repository.Name)
|
case res.Chart:
|
||||||
if err != nil {
|
charts, err := bc.coreClient.ListAllCharts(repository.Namespace, repository.Name)
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
for _, chart := range charts {
|
|
||||||
labels := make([]string, 0)
|
|
||||||
for _, label := range chart.Labels {
|
|
||||||
labels = append(labels, label.Name)
|
|
||||||
}
|
}
|
||||||
candidate := &res.Candidate{
|
for _, chart := range charts {
|
||||||
Kind: res.Chart,
|
labels := make([]string, 0)
|
||||||
Namespace: repository.Namespace,
|
for _, label := range chart.Labels {
|
||||||
Repository: repository.Name,
|
labels = append(labels, label.Name)
|
||||||
Tag: chart.Name,
|
}
|
||||||
Labels: labels,
|
candidate := &res.Candidate{
|
||||||
CreationTime: chart.Created.Unix(),
|
Kind: res.Chart,
|
||||||
PushedTime: time.Now().Unix() - (int64)((rand.Int31n(5)+5)*24*3600),
|
Namespace: repository.Namespace,
|
||||||
PulledTime: time.Now().Unix() - (int64)((rand.Int31n(4))*24*3600),
|
Repository: repository.Name,
|
||||||
|
Tag: chart.Name,
|
||||||
|
Labels: labels,
|
||||||
|
CreationTime: chart.Created.Unix(),
|
||||||
|
PushedTime: ,
|
||||||
|
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:
|
/*
|
||||||
return bc.coreClient.DeleteChartRepository(repo.Namespace, repo.Name)
|
case res.Chart:
|
||||||
|
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:
|
/*
|
||||||
return bc.coreClient.DeleteChart(candidate.Namespace, candidate.Repository, candidate.Tag)
|
case res.Chart:
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
@ -91,16 +91,18 @@ 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
|
/*
|
||||||
repository.Kind = res.Chart
|
// chart repository
|
||||||
repository.Namespace = "goharbor"
|
repository.Kind = res.Chart
|
||||||
repository.Name = "harbor"
|
repository.Namespace = "goharbor"
|
||||||
candidates, err = client.GetCandidates(repository)
|
repository.Name = "harbor"
|
||||||
require.Nil(c.T(), err)
|
candidates, err = client.GetCandidates(repository)
|
||||||
assert.Equal(c.T(), 1, len(candidates))
|
require.Nil(c.T(), err)
|
||||||
assert.Equal(c.T(), res.Chart, candidates[0].Kind)
|
assert.Equal(c.T(), 1, len(candidates))
|
||||||
assert.Equal(c.T(), "goharbor", candidates[0].Namespace)
|
assert.Equal(c.T(), res.Chart, candidates[0].Kind)
|
||||||
assert.Equal(c.T(), "1.0", candidates[0].Tag)
|
assert.Equal(c.T(), "goharbor", candidates[0].Namespace)
|
||||||
|
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
|
/*
|
||||||
candidate.Kind = res.Chart
|
// chart
|
||||||
err = client.Delete(candidate)
|
candidate.Kind = res.Chart
|
||||||
require.Nil(c.T(), err)
|
err = client.Delete(candidate)
|
||||||
|
require.Nil(c.T(), err)
|
||||||
|
*/
|
||||||
|
|
||||||
// unsupported type
|
// unsupported type
|
||||||
candidate.Kind = "unsupported"
|
candidate.Kind = "unsupported"
|
||||||
|
@ -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)
|
/*
|
||||||
if err != nil {
|
pro, err := projectMgr.Get(projectID)
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
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,20 +357,23 @@ func getRepositories(projectMgr project.Manager, repositoryMgr repository.Manage
|
|||||||
Kind: "image",
|
Kind: "image",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if chartServerEnabled {
|
// currently, doesn't support retention for chart
|
||||||
// get chart repositories when chart server is enabled
|
/*
|
||||||
chartRepositories, err := repositoryMgr.ListChartRepositories(projectID)
|
if chartServerEnabled {
|
||||||
if err != nil {
|
// get chart repositories when chart server is enabled
|
||||||
return nil, err
|
chartRepositories, err := repositoryMgr.ListChartRepositories(projectID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, r := range chartRepositories {
|
||||||
|
candidates = append(candidates, &res.Candidate{
|
||||||
|
Namespace: pro.Name,
|
||||||
|
Repository: r.Name,
|
||||||
|
Kind: "chart",
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for _, r := range chartRepositories {
|
*/
|
||||||
candidates = append(candidates, &res.Candidate{
|
|
||||||
Namespace: pro.Name,
|
|
||||||
Repository: r.Name,
|
|
||||||
Kind: "chart",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return candidates, nil
|
return candidates, nil
|
||||||
}
|
}
|
||||||
|
@ -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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user