Skip to content

Commit

Permalink
Simple rename.
Browse files Browse the repository at this point in the history
It confuses me every time I deal with the Values field in different
parts of the code, since it's not user values at all, but the chart's
default values file. Hopefully this will make it clearer.

Signed-off-by: Michael Nelson <minelson@vmware.com>
  • Loading branch information
absoludity committed Nov 30, 2022
1 parent a4b3098 commit 91ebd05
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cmd/asset-syncer/server/postgresql_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion cmd/asset-syncer/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
26 changes: 13 additions & 13 deletions cmd/asset-syncer/server/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions pkg/chart/models/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 91ebd05

Please sign in to comment.