From 86b6e66d6d95c66c226c46b037439dc36b95c73e Mon Sep 17 00:00:00 2001 From: FengyunPan2 Date: Mon, 27 May 2019 16:19:46 +0800 Subject: [PATCH] Don't return error when repos have no chart Fix #632 I build a chartmuseum service which has no charts, then add the chartmuseum repo into kubeapps. But I get a 'error' pod, that is unfriendly. I think it is better to add log for it. Signed-off-by: FengyunPan2 --- cmd/chart-repo/utils.go | 3 ++- cmd/chart-repo/utils_test.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/chart-repo/utils.go b/cmd/chart-repo/utils.go index 969eae11f..2f563dd70 100644 --- a/cmd/chart-repo/utils.go +++ b/cmd/chart-repo/utils.go @@ -99,7 +99,8 @@ func syncRepo(dbSession datastore.Session, repoName, repoURL string, authorizati charts := chartsFromIndex(index, r) if len(charts) == 0 { - return errors.New("no charts in repository index") + log.Warnf("The repository %s has no charts.", repoName) + return nil } err = importCharts(dbSession, charts) if err != nil { diff --git a/cmd/chart-repo/utils_test.go b/cmd/chart-repo/utils_test.go index e70ba4c97..894ebd6de 100644 --- a/cmd/chart-repo/utils_test.go +++ b/cmd/chart-repo/utils_test.go @@ -587,5 +587,5 @@ func Test_emptyChartRepo(t *testing.T) { m := mock.Mock{} dbSession := mockstore.NewMockSession(&m) err := syncRepo(dbSession, "testRepo", "https://my.examplerepo.com", "") - assert.ExistsErr(t, err, "Failed Request") + assert.NoErr(t, err) }