You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/06/17 03:55:18 UTC

[camel-k] branch release-1.9.x updated (c8803d885 -> 329c1106c)

This is an automated email from the ASF dual-hosted git repository.

tsato pushed a change to branch release-1.9.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git


    from c8803d885 feat: add basic support for PodSecurityContext
     new 0816829fc Fixes `kamel local run` panic on Windows
     new 4dcda1bb5 Changes requested
     new 329c1106c Fixed typo

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pkg/cmd/util_commands.go           |  3 ++-
 pkg/resources/resources_support.go | 16 +++++++++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)


[camel-k] 03/03: Fixed typo

Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tsato pushed a commit to branch release-1.9.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 329c1106c6423a3c518a47cd1e252306b5d6251b
Author: Adriano Machado <unknown>
AuthorDate: Thu Jun 16 09:57:55 2022 -0400

    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 684fab2f9..28fa9ab4f 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))
 }


[camel-k] 01/03: Fixes `kamel local run` panic on Windows

Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tsato pushed a commit to branch release-1.9.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 0816829fc518d282f8f4237edb62345d29040bd2
Author: Adriano Machado <unknown>
AuthorDate: Wed Jun 15 19:39:46 2022 -0400

    Fixes `kamel local run` panic on Windows
---
 pkg/cmd/util_commands.go           |  9 ++++++++-
 pkg/resources/resources_support.go | 20 +++++++++++++++-----
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/pkg/cmd/util_commands.go b/pkg/cmd/util_commands.go
index 794f49e33..04a189fce 100644
--- a/pkg/cmd/util_commands.go
+++ b/pkg/cmd/util_commands.go
@@ -22,6 +22,7 @@ import (
 	"fmt"
 	"io"
 	"os/exec"
+	"runtime"
 	"strings"
 
 	"github.com/apache/camel-k/pkg/util"
@@ -49,7 +50,13 @@ func assembleClasspathArgValue(properties []string, dependencies []string, route
 	classpathContents = append(classpathContents, properties...)
 	classpathContents = append(classpathContents, routes...)
 	classpathContents = append(classpathContents, dependencies...)
-	return strings.Join(classpathContents, ":")
+
+	pathSeparator := ":"
+	if runtime.GOOS == "windows" {
+		pathSeparator = ";"
+	}
+
+	return strings.Join(classpathContents, pathSeparator)
 }
 
 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 46a8c36b4..167ccce13 100644
--- a/pkg/resources/resources_support.go
+++ b/pkg/resources/resources_support.go
@@ -22,6 +22,7 @@ import (
 	"io/ioutil"
 	"os"
 	"path/filepath"
+	"runtime"
 	"strings"
 	"text/template"
 
@@ -46,7 +47,7 @@ func Resource(name string) ([]byte, error) {
 		name = "/" + name
 	}
 
-	file, err := assets.Open(name)
+	file, err := assets.Open(fixPath(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 := assets.Open(fixPath(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 := fixPath(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 := assets.Open(fixPath(dirName))
 	if err != nil {
 		if os.IsNotExist(err) {
 			return nil, nil
@@ -146,3 +148,11 @@ func Resources(dirName string) ([]string, error) {
 
 	return res, dir.Close()
 }
+
+func fixPath(path string) string {
+	if runtime.GOOS == "windows" {
+		path = strings.ReplaceAll(path, "\\", "/")
+	}
+
+	return path
+}


[camel-k] 02/03: Changes requested

Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tsato pushed a commit to branch release-1.9.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 4dcda1bb54e414ec95b04453863bcce7f503e717
Author: Adriano Machado <unknown>
AuthorDate: Thu Jun 16 08:44:42 2022 -0400

    Changes requested
---
 pkg/cmd/util_commands.go           | 10 ++--------
 pkg/resources/resources_support.go | 18 +++++++-----------
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/pkg/cmd/util_commands.go b/pkg/cmd/util_commands.go
index 04a189fce..7f0252a3f 100644
--- a/pkg/cmd/util_commands.go
+++ b/pkg/cmd/util_commands.go
@@ -21,8 +21,8 @@ import (
 	"context"
 	"fmt"
 	"io"
+	"os"
 	"os/exec"
-	"runtime"
 	"strings"
 
 	"github.com/apache/camel-k/pkg/util"
@@ -50,13 +50,7 @@ func assembleClasspathArgValue(properties []string, dependencies []string, route
 	classpathContents = append(classpathContents, properties...)
 	classpathContents = append(classpathContents, routes...)
 	classpathContents = append(classpathContents, dependencies...)
-
-	pathSeparator := ":"
-	if runtime.GOOS == "windows" {
-		pathSeparator = ";"
-	}
-
-	return strings.Join(classpathContents, pathSeparator)
+	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 167ccce13..684fab2f9 100644
--- a/pkg/resources/resources_support.go
+++ b/pkg/resources/resources_support.go
@@ -20,9 +20,9 @@ package resources
 import (
 	"bytes"
 	"io/ioutil"
+	"net/http"
 	"os"
 	"path/filepath"
-	"runtime"
 	"strings"
 	"text/template"
 
@@ -47,7 +47,7 @@ func Resource(name string) ([]byte, error) {
 		name = "/" + name
 	}
 
-	file, err := assets.Open(fixPath(name))
+	file, err := openAsset(name)
 	if err != nil {
 		return nil, errors.Wrapf(err, "cannot access resource file %s", name)
 	}
@@ -86,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(fixPath(dirName)); err != nil {
+	if _, err := openAsset(dirName); err != nil {
 		return false
 	}
 	return true
@@ -104,7 +104,7 @@ func WithPrefix(pathPrefix string) ([]string, error) {
 
 	var res []string
 	for i := range paths {
-		path := fixPath(paths[i])
+		path := filepath.FromSlash(paths[i])
 		if result, _ := filepath.Match(pathPrefix+"*", path); result {
 			res = append(res, path)
 		}
@@ -115,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(fixPath(dirName))
+	dir, err := openAsset(dirName)
 	if err != nil {
 		if os.IsNotExist(err) {
 			return nil, nil
@@ -149,10 +149,6 @@ func Resources(dirName string) ([]string, error) {
 	return res, dir.Close()
 }
 
-func fixPath(path string) string {
-	if runtime.GOOS == "windows" {
-		path = strings.ReplaceAll(path, "\\", "/")
-	}
-
-	return path
+func openAsset(path string) (http.File, error) {
+	return assets.Open(filepath.FromSlash(path))
 }