fix some typo.

Signed-off-by: wujunwei <wjw3323@live.com>
pull/11551/head
wujunwei 3 years ago
parent da5af20be7
commit b869a50056

@ -112,6 +112,8 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
// with globs or directory names.
splitManifests := releaseutil.SplitManifests(manifests.String())
manifestsKeys := make([]string, 0, len(splitManifests))
// such as `# Source: subchart/templates/service.yaml` will be divided into two parts `subchart/`, `templates/service.yaml`
// and manifestName will be `templates/service.yaml` , manifestPath will be `subchart/templates/service.yam`
manifestNameRegex := regexp.MustCompile("# Source: ([^/]+/)(.+)")
for k := range splitManifests {
manifestsKeys = append(manifestsKeys, k)
@ -229,7 +231,7 @@ func matchFilePatterns(target string, sf []string) bool {
return false
}
// writeManifest write manifest to stdout or file stream. use withHeader to control if write file header `# Source: XXXXX.yaml` or not.
// writeManifest write manifest to stdout or file stream. use withHeader to control if write file header `# Source: XXXXX.yaml`.
func writeManifest(outputDir, path, manifest string, fileWritten map[string]bool, withHeader bool, outStream io.Writer) error {
if outputDir == "" {
return writeStream(path, manifest, withHeader, outStream)

@ -176,7 +176,7 @@ func TestTemplateOutputDir(t *testing.T) {
t.Logf("Output: %s", out)
t.Fatal(err)
}
var exitFileList = [][]string{
var existent = [][]string{
{dir, "subchart", "templates", "service.yaml"},
{dir, "subchart", "templates", "tests", "test-config.yaml"},
{dir, "subchart", "templates", "tests", "test-nothing.yaml"},
@ -186,11 +186,11 @@ func TestTemplateOutputDir(t *testing.T) {
{dir, "subchart", "charts", "subcharta", "templates", "service.yaml"},
{dir, "subchart", "charts", "subchartb", "templates", "service.yaml"},
}
for _, s := range exitFileList {
for _, s := range existent {
_, err = os.Stat(filepath.Join(s...))
is.NoError(err)
}
notExistFileList := [][]string{
nonexistent := [][]string{
{dir, "hello", "templates", "empty"},
{dir, releaseName, "subchart", "templates", "service.yaml"},
{dir, releaseName, "subchart", "templates", "tests", "test-config.yaml"},
@ -201,7 +201,7 @@ func TestTemplateOutputDir(t *testing.T) {
{dir, releaseName, "subchart", "charts", "subcharta", "templates", "service.yaml"},
{dir, releaseName, "subchart", "charts", "subchartb", "templates", "service.yaml"},
}
for _, f := range notExistFileList {
for _, f := range nonexistent {
_, err = os.Stat(filepath.Join(f...))
is.True(os.IsNotExist(err))
}
@ -216,14 +216,14 @@ func TestTemplateWithCRDsOutputDir(t *testing.T) {
t.Logf("Output: %s", out)
t.Fatal(err)
}
var exitFileList = [][]string{
var existent = [][]string{
{dir, "subchart", "crds", "crdA.yaml"},
}
for _, s := range exitFileList {
for _, s := range existent {
_, err = os.Stat(filepath.Join(s...))
is.NoError(err)
}
notExistFileList := [][]string{
nonexistent := [][]string{
{dir, "hello", "templates", "empty"},
{dir, releaseName, "subchart", "templates", "service.yaml"},
{dir, releaseName, "subchart", "templates", "tests", "test-config.yaml"},
@ -234,7 +234,7 @@ func TestTemplateWithCRDsOutputDir(t *testing.T) {
{dir, releaseName, "subchart", "charts", "subcharta", "templates", "service.yaml"},
{dir, releaseName, "subchart", "charts", "subchartb", "templates", "service.yaml"},
}
for _, f := range notExistFileList {
for _, f := range nonexistent {
_, err = os.Stat(filepath.Join(f...))
is.True(os.IsNotExist(err))
}
@ -249,7 +249,7 @@ func TestTemplateOutputDirWithReleaseName(t *testing.T) {
t.Logf("Output: %s", out)
t.Fatal(err)
}
var exitFileList = [][]string{
var existent = [][]string{
{dir, releaseName, "subchart", "templates", "service.yaml"},
{dir, releaseName, "subchart", "templates", "tests", "test-config.yaml"},
{dir, releaseName, "subchart", "templates", "tests", "test-nothing.yaml"},
@ -259,11 +259,11 @@ func TestTemplateOutputDirWithReleaseName(t *testing.T) {
{dir, releaseName, "subchart", "charts", "subcharta", "templates", "service.yaml"},
{dir, releaseName, "subchart", "charts", "subchartb", "templates", "service.yaml"},
}
for _, s := range exitFileList {
for _, s := range existent {
_, err = os.Stat(filepath.Join(s...))
is.NoError(err)
}
notExistFileList := [][]string{
nonexistent := [][]string{
{dir, releaseName, "hello", "templates", "empty"},
{dir, "subchart", "templates", "service.yaml"},
{dir, "subchart", "templates", "tests", "test-config.yaml"},
@ -274,7 +274,7 @@ func TestTemplateOutputDirWithReleaseName(t *testing.T) {
{dir, "subchart", "charts", "subcharta", "templates", "service.yaml"},
{dir, "subchart", "charts", "subchartb", "templates", "service.yaml"},
}
for _, f := range notExistFileList {
for _, f := range nonexistent {
_, err = os.Stat(filepath.Join(f...))
is.True(os.IsNotExist(err))
}
@ -289,11 +289,11 @@ func TestTemplateOutputDirSkiptest(t *testing.T) {
t.Logf("Output: %s", out)
t.Fatal(err)
}
notExistFileList := [][]string{
nonexistent := [][]string{
{dir, "subchart", "templates", "tests", "test-config.yaml"},
{dir, "subchart", "templates", "tests", "test-nothing.yaml"},
}
for _, f := range notExistFileList {
for _, f := range nonexistent {
_, err = os.Stat(filepath.Join(f...))
is.True(os.IsNotExist(err))
}

Loading…
Cancel
Save