Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes kamel local run panic on Windows #3368

Merged
merged 2 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/cmd/util_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"fmt"
"io"
"os"
"os/exec"
"strings"

Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 11 additions & 5 deletions pkg/resources/resources_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package resources
import (
"bytes"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"strings"
Expand All @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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.ToSlash(paths[i])
if result, _ := filepath.Match(pathPrefix+"*", path); result {
res = append(res, path)
}
}

Expand All @@ -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
Expand Down Expand Up @@ -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.ToSlash(path))
}