mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 00:52:55 +00:00
Address kyaml windows compatibility issues
This commit is contained in:
@@ -173,6 +173,9 @@ func (r LocalPackageReader) Read() ([]*yaml.RNode, error) {
|
||||
if r.PackagePath == "" {
|
||||
return nil, fmt.Errorf("must specify package path")
|
||||
}
|
||||
|
||||
// use slash for path
|
||||
r.PackagePath = filepath.ToSlash(r.PackagePath)
|
||||
if len(r.MatchFilesGlob) == 0 {
|
||||
r.MatchFilesGlob = DefaultMatch
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/kustomize/kyaml/testutil"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
. "sigs.k8s.io/kustomize/kyaml/kio"
|
||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||
@@ -186,7 +188,9 @@ func TestLocalPackageWriter_Write_absPath(t *testing.T) {
|
||||
d, node1, node2, node3 := getWriterInputs(t)
|
||||
defer os.RemoveAll(d)
|
||||
|
||||
node4, err := yaml.Parse(fmt.Sprintf(`e: f
|
||||
d = filepath.ToSlash(d)
|
||||
|
||||
n4 := fmt.Sprintf(`e: f
|
||||
g:
|
||||
h:
|
||||
- i # has a list
|
||||
@@ -195,16 +199,13 @@ metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/index: a
|
||||
config.kubernetes.io/path: "%s/a/b/b_test.yaml" # use a different path, should still collide
|
||||
`, d))
|
||||
if !assert.NoError(t, err) {
|
||||
assert.FailNow(t, err.Error())
|
||||
}
|
||||
`, d)
|
||||
node4, err := yaml.Parse(n4)
|
||||
testutil.AssertNoError(t, err, n4)
|
||||
|
||||
w := LocalPackageWriter{PackagePath: d}
|
||||
err = w.Write([]*yaml.RNode{node2, node1, node3, node4})
|
||||
if assert.Error(t, err) {
|
||||
assert.Contains(t, err.Error(), "package paths may not be absolute paths")
|
||||
}
|
||||
testutil.AssertErrorContains(t, err, "package paths may not be absolute paths")
|
||||
}
|
||||
|
||||
// TestLocalPackageWriter_Write_missingPath tests:
|
||||
|
||||
@@ -5,6 +5,8 @@ package kio_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -68,15 +70,15 @@ spec:
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if !assert.Equal(t, `
|
||||
if !assert.Equal(t, fmt.Sprintf(`
|
||||
├── bar-package
|
||||
│ └── [f2.yaml] Deployment bar
|
||||
└── foo-package
|
||||
├── [f1.yaml] Deployment default/foo
|
||||
├── [f1.yaml] Service default/foo
|
||||
└── foo-package/3
|
||||
└── foo-package%s3
|
||||
└── [f3.yaml] Deployment default/foo
|
||||
`, out.String()) {
|
||||
`, string(filepath.Separator)), out.String()) {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user