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.
*/
package loader
package action
import (
"errors"
@ -20,8 +20,8 @@ import (
"strings"
)
// ExpandFilePath expands a local file, dir or glob path to a list of files
func ExpandFilePath(path string) ([]string, error) {
// expandFilePath expands a local file, dir or glob path to a list of files
func expandFilePath(path string) ([]string, error) {
if strings.Contains(path, "*") {
// if this is a glob, we expand it and return a list of files
return expandGlob(path)

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