Move expandFilePath to pkg/action

Signed-off-by: itaispiegel <itai.spiegel@gmail.com>
pull/10077/head
itaispiegel 3 years ago
parent b0c802439b
commit df457bf826

@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package loader package action
import ( import (
"errors" "errors"
@ -20,8 +20,8 @@ import (
"strings" "strings"
) )
// ExpandFilePath expands a local file, dir or glob path to a list of files // expandFilePath expands a local file, dir or glob path to a list of files
func ExpandFilePath(path string) ([]string, error) { func expandFilePath(path string) ([]string, error) {
if strings.Contains(path, "*") { if strings.Contains(path, "*") {
// if this is a glob, we expand it and return a list of files // if this is a glob, we expand it and return a list of files
return expandGlob(path) return expandGlob(path)

@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package loader package action
import ( import (
"testing" "testing"
@ -22,17 +22,15 @@ import (
func TestExpandLocalPath(t *testing.T) { func TestExpandLocalPath(t *testing.T) {
req := require.New(t) req := require.New(t)
glob, err := ExpandFilePath("testdata/frobnitz/*.yaml") glob, err := expandFilePath("testdata/output/*.txt")
req.NoError(err) req.NoError(err)
req.Contains(glob, "testdata/frobnitz/Chart.yaml") req.Contains(glob, "testdata/output/list-compressed-deps.txt")
req.Contains(glob, "testdata/frobnitz/values.yaml") req.Contains(glob, "testdata/output/list-missing-deps.txt")
dir, err := ExpandFilePath("testdata/albatross/") dir, err := expandFilePath("testdata/files/")
req.NoError(err) req.NoError(err)
req.Contains(dir, "testdata/albatross/Chart.yaml") req.Contains(dir, "testdata/files/external.txt")
req.Contains(dir, "testdata/albatross/values.yaml")
file, err := ExpandFilePath("testdata/albatross/Chart.yaml") _, err = expandFilePath("testdata/non_existing")
req.NoError(err) req.Error(err)
req.Contains(file, "testdata/albatross/Chart.yaml")
} }
Loading…
Cancel
Save