Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ import (
"github.com/helm/chart-testing/v3/pkg/util"
)

const maxNameLength = 63
const (
// maxNameLength is the longest name Kubernetes accepts for a namespace.
maxNameLength = 63
// maxReleaseNameLength is the longest release name Helm accepts.
maxReleaseNameLength = 53
)

// Git is the Interface that wraps Git operations.
//
Expand Down Expand Up @@ -228,7 +233,7 @@ func (c *Chart) CreateInstallParams(buildID string, releaseName string) (release
// unconditionally, which made --release-name appear to be ignored (#198).
release = releaseName
} else {
release = util.SanitizeName(fmt.Sprintf("%s-%s", release, randomSuffix), maxNameLength)
release = util.SanitizeName(fmt.Sprintf("%s-%s", release, randomSuffix), maxReleaseNameLength)
}
namespace = util.SanitizeName(fmt.Sprintf("%s-%s", namespace, randomSuffix), maxNameLength)
return
Expand Down
12 changes: 12 additions & 0 deletions pkg/chart/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,18 @@ func TestChart_CreateInstallParams(t *testing.T) {
assert.NotEqual(t, "simple-deployment", release)
}

func TestChart_CreateInstallParams_LongChartDir(t *testing.T) {
// Helm rejects release names longer than 53 characters, while Kubernetes
// allows namespaces of up to 63.
chrt := &Chart{path: "charts/" + strings.Repeat("a", 60), yaml: &util.ChartYaml{Name: "long"}}

release, namespace := chrt.CreateInstallParams("", "")
assert.LessOrEqual(t, len(release), 53)
assert.LessOrEqual(t, len(namespace), 63)
assert.Regexp(t, `-[0-9a-z]{10}$`, release)
assert.Regexp(t, `-[0-9a-z]{10}$`, namespace)
}

func TestInstallChart_SkipsLibraryChart(t *testing.T) {
chrt, err := NewChart("testdata/library_chart")
assert.Nil(t, err)
Expand Down