From 87ce89471cf0a40f93732296157b2297e07002b5 Mon Sep 17 00:00:00 2001 From: Adriano Machado <> Date: Wed, 15 Jun 2022 19:39:46 -0400 Subject: [PATCH 1/2] Fixes `kamel local run` panic on Windows --- pkg/cmd/util_commands.go | 3 ++- pkg/resources/resources_support.go | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/cmd/util_commands.go b/pkg/cmd/util_commands.go index 794f49e33d..7f0252a3f5 100644 --- a/pkg/cmd/util_commands.go +++ b/pkg/cmd/util_commands.go @@ -21,6 +21,7 @@ import ( "context" "fmt" "io" + "os" "os/exec" "strings" @@ -49,7 +50,7 @@ func assembleClasspathArgValue(properties []string, dependencies []string, route classpathContents = append(classpathContents, properties...) classpathContents = append(classpathContents, routes...) classpathContents = append(classpathContents, dependencies...) - return strings.Join(classpathContents, ":") + return strings.Join(classpathContents, string(os.PathListSeparator)) } func assembleIntegrationRunCommand(ctx context.Context, properties []string, dependencies []string, routes []string, propertiesDir string, stdout, stderr io.Writer, local bool) (*exec.Cmd, error) { diff --git a/pkg/resources/resources_support.go b/pkg/resources/resources_support.go index 46a8c36b48..684fab2f92 100644 --- a/pkg/resources/resources_support.go +++ b/pkg/resources/resources_support.go @@ -20,6 +20,7 @@ package resources import ( "bytes" "io/ioutil" + "net/http" "os" "path/filepath" "strings" @@ -46,7 +47,7 @@ func Resource(name string) ([]byte, error) { name = "/" + name } - file, err := assets.Open(name) + file, err := openAsset(name) if err != nil { return nil, errors.Wrapf(err, "cannot access resource file %s", name) } @@ -85,7 +86,7 @@ func TemplateResource(name string, params interface{}) (string, error) { // DirExists tells if a directory exists and can be listed for files. func DirExists(dirName string) bool { - if _, err := assets.Open(dirName); err != nil { + if _, err := openAsset(dirName); err != nil { return false } return true @@ -103,8 +104,9 @@ func WithPrefix(pathPrefix string) ([]string, error) { var res []string for i := range paths { - if result, _ := filepath.Match(pathPrefix+"*", paths[i]); result { - res = append(res, paths[i]) + path := filepath.FromSlash(paths[i]) + if result, _ := filepath.Match(pathPrefix+"*", path); result { + res = append(res, path) } } @@ -113,7 +115,7 @@ func WithPrefix(pathPrefix string) ([]string, error) { // Resources lists all file names in the given path (starts with '/'). func Resources(dirName string) ([]string, error) { - dir, err := assets.Open(dirName) + dir, err := openAsset(dirName) if err != nil { if os.IsNotExist(err) { return nil, nil @@ -146,3 +148,7 @@ func Resources(dirName string) ([]string, error) { return res, dir.Close() } + +func openAsset(path string) (http.File, error) { + return assets.Open(filepath.FromSlash(path)) +} From 3b49a144fe4ae8c1a984b24ac5d9d0edc3d510c5 Mon Sep 17 00:00:00 2001 From: Adriano Machado <> Date: Thu, 16 Jun 2022 09:57:55 -0400 Subject: [PATCH 2/2] Fixed typo --- pkg/resources/resources_support.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/resources/resources_support.go b/pkg/resources/resources_support.go index 684fab2f92..28fa9ab4fa 100644 --- a/pkg/resources/resources_support.go +++ b/pkg/resources/resources_support.go @@ -104,7 +104,7 @@ func WithPrefix(pathPrefix string) ([]string, error) { var res []string for i := range paths { - path := filepath.FromSlash(paths[i]) + path := filepath.ToSlash(paths[i]) if result, _ := filepath.Match(pathPrefix+"*", path); result { res = append(res, path) } @@ -150,5 +150,5 @@ func Resources(dirName string) ([]string, error) { } func openAsset(path string) (http.File, error) { - return assets.Open(filepath.FromSlash(path)) + return assets.Open(filepath.ToSlash(path)) }