diff --git a/cmd/asset-syncer/server/postgresql_utils_test.go b/cmd/asset-syncer/server/postgresql_utils_test.go index e08ea6b055b..4bbc16b3178 100644 --- a/cmd/asset-syncer/server/postgresql_utils_test.go +++ b/cmd/asset-syncer/server/postgresql_utils_test.go @@ -175,7 +175,7 @@ func Test_PGinsertFiles(t *testing.T) { chartID string = repoName + "/wordpress" filesID string = chartID + "-2.1.3" ) - files := models.ChartFiles{ID: filesID, Readme: "foo", Values: "bar", Repo: &models.Repo{Namespace: namespace, Name: repoName}} + files := models.ChartFiles{ID: filesID, Readme: "foo", DefaultValues: "bar", Repo: &models.Repo{Namespace: namespace, Name: repoName}} mock.ExpectQuery(`INSERT INTO files \(chart_id, repo_name, repo_namespace, chart_files_ID, info\)*`). WithArgs(chartID, repoName, namespace, filesID, files). WillReturnRows(sqlmock.NewRows([]string{"ID"}).AddRow("3")) diff --git a/cmd/asset-syncer/server/utils.go b/cmd/asset-syncer/server/utils.go index 96fab9289b6..1de868f7237 100644 --- a/cmd/asset-syncer/server/utils.go +++ b/cmd/asset-syncer/server/utils.go @@ -889,7 +889,7 @@ func (f *fileImporter) fetchAndImportFiles(name string, repo Repo, cv models.Cha log.Info("README.md not found, name=%s, version=%s", name, cv.Version) } if v, ok := files[models.ValuesKey]; ok { - chartFiles.Values = v + chartFiles.DefaultValues = v } else { log.Info("values.yaml not found, name=%s, version=%s", name, cv.Version) } diff --git a/cmd/asset-syncer/server/utils_test.go b/cmd/asset-syncer/server/utils_test.go index 89564c36b3c..71ae28cf13d 100644 --- a/cmd/asset-syncer/server/utils_test.go +++ b/cmd/asset-syncer/server/utils_test.go @@ -531,7 +531,7 @@ func (r *fakeRepo) Charts(shallow bool) ([]models.Chart, error) { func (r *fakeRepo) FetchFiles(name string, cv models.ChartVersion, userAgent string, passCredentials bool) (map[string]string, error) { return map[string]string{ - models.ValuesKey: r.chartFiles.Values, + models.ValuesKey: r.chartFiles.DefaultValues, models.ReadmeKey: r.chartFiles.Readme, models.SchemaKey: r.chartFiles.Schema, }, nil @@ -544,12 +544,12 @@ func Test_fetchAndImportFiles(t *testing.T) { chartID := fmt.Sprintf("%s/%s", charts[0].Repo.Name, charts[0].Name) chartFilesID := fmt.Sprintf("%s-%s", chartID, chartVersion.Version) chartFiles := models.ChartFiles{ - ID: chartFilesID, - Readme: testChartReadme, - Values: testChartValues, - Schema: testChartSchema, - Repo: charts[0].Repo, - Digest: chartVersion.Digest, + ID: chartFilesID, + Readme: testChartReadme, + DefaultValues: testChartValues, + Schema: testChartSchema, + Repo: charts[0].Repo, + Digest: chartVersion.Digest, } fRepo := &fakeRepo{ RepoInternal: repo, @@ -579,12 +579,12 @@ func Test_fetchAndImportFiles(t *testing.T) { defer cleanup() files := models.ChartFiles{ - ID: chartFilesID, - Readme: "", - Values: "", - Schema: "", - Repo: charts[0].Repo, - Digest: chartVersion.Digest, + ID: chartFilesID, + Readme: "", + DefaultValues: "", + Schema: "", + Repo: charts[0].Repo, + Digest: chartVersion.Digest, } // file does not exist (no rows returned) so insertion goes ahead. diff --git a/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server.go b/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server.go index 6388240a9c1..05942bc4d62 100644 --- a/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server.go +++ b/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server.go @@ -422,7 +422,7 @@ func AvailablePackageDetailFromChart(chart *models.Chart, chartFiles *models.Cha AppVersion: chart.ChartVersions[0].AppVersion, } pkg.Readme = chartFiles.Readme - pkg.DefaultValues = chartFiles.Values + pkg.DefaultValues = chartFiles.DefaultValues pkg.ValuesSchema = chartFiles.Schema } return pkg, nil diff --git a/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server_test.go b/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server_test.go index b4af4d96f58..33b21c99134 100644 --- a/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server_test.go +++ b/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server_test.go @@ -7,8 +7,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/utils/fake" - "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/helm/agent" "io" "net/url" "os" @@ -18,6 +16,9 @@ import ( "strings" "testing" + "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/utils/fake" + "github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/plugins/pkg/helm/agent" + "github.com/DATA-DOG/go-sqlmock" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -858,9 +859,9 @@ func TestAvailablePackageDetailFromChart(t *testing.T) { name: "it returns AvailablePackageDetail if the chart is correct", chart: makeChart("foo", "repo-1", "http://foo", "my-ns", []string{"3.0.0"}, DefaultChartCategory), chartFiles: &models.ChartFiles{ - Readme: "chart readme", - Values: "chart values", - Schema: "chart schema", + Readme: "chart readme", + DefaultValues: "chart values", + Schema: "chart schema", }, expected: &corev1.AvailablePackageDetail{ Name: "foo", @@ -1089,9 +1090,9 @@ func TestGetAvailablePackageDetail(t *testing.T) { WillReturnRows(rows) fileID := fileIDForChart(chartIDUnescaped, tc.expectedPackage.Version.PkgVersion) fileJSON, err := json.Marshal(models.ChartFiles{ - Readme: tc.expectedPackage.Readme, - Values: tc.expectedPackage.DefaultValues, - Schema: tc.expectedPackage.ValuesSchema, + Readme: tc.expectedPackage.Readme, + DefaultValues: tc.expectedPackage.DefaultValues, + Schema: tc.expectedPackage.ValuesSchema, }) if err != nil { t.Fatalf("%+v", err) diff --git a/pkg/chart/models/chart.go b/pkg/chart/models/chart.go index 44418e97398..991bf881db6 100644 --- a/pkg/chart/models/chart.go +++ b/pkg/chart/models/chart.go @@ -77,10 +77,9 @@ type ChartVersion struct { // ChartFiles holds the README and default values for a given chart version type ChartFiles struct { - ID string `bson:"file_id"` - Readme string - // TODO(absoludity): Rename to DefaultValues in separate PR for easy review. - Values string + ID string `bson:"file_id"` + Readme string + DefaultValues string CustomDefaultValues map[string]string Schema string Repo *Repo