You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by jp...@apache.org on 2022/05/16 15:12:14 UTC
[camel-k] 01/02: Fix #3257: work with relative paths on windows to avoid extra semicolon
This is an automated email from the ASF dual-hosted git repository.
jpoth pushed a commit to branch release-1.9.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit add82a8af0266b2a6bba2c9deb0556ef6465d656
Author: John Poth <po...@gmail.com>
AuthorDate: Thu May 12 12:13:52 2022 +0200
Fix #3257: work with relative paths on windows to avoid extra semicolon
(cherry picked from commit 89794bfad8184e6f2553ed039892bf512e2de9ea)
---
pkg/cmd/run.go | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 247d9e1a5..b32fc6f33 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -39,6 +39,7 @@ import (
"path/filepath"
"reflect"
"regexp"
+ runtimeos "runtime"
"strings"
"syscall"
@@ -952,6 +953,15 @@ func extractGav(src *zip.File, localPath string) (maven.Dependency, bool) {
func uploadAsMavenArtifact(dependency maven.Dependency, path string, platform *v1.IntegrationPlatform, ns string, options spectrum.Options) error {
artifactHTTPPath := getArtifactHTTPPath(dependency, platform, ns)
options.Target = fmt.Sprintf("%s/%s:%s", platform.Spec.Build.Registry.Address, artifactHTTPPath, dependency.Version)
+ if runtimeos.GOOS == "windows" {
+ // workaround for https://github.com/container-tools/spectrum/issues/8
+ // work with relative paths instead
+ rel, err := getRelativeToWorkingDirectory(path)
+ if err != nil {
+ return err
+ }
+ path = rel
+ }
_, err := spectrum.Build(options, fmt.Sprintf("%s:.", path))
if err != nil {
return err
@@ -960,6 +970,23 @@ func uploadAsMavenArtifact(dependency maven.Dependency, path string, platform *v
return uploadChecksumFiles(path, options, platform, artifactHTTPPath, dependency)
}
+// Deprecated: workaround for https://github.com/container-tools/spectrum/issues/8
+func getRelativeToWorkingDirectory(path string) (string, error) {
+ wd, err := os.Getwd()
+ if err != nil {
+ return "", err
+ }
+ abs, err := filepath.Abs(path)
+ if err != nil {
+ return "", err
+ }
+ path, err = filepath.Rel(wd, abs)
+ if err != nil {
+ return "", err
+ }
+ return path, nil
+}
+
// Currently swallows errors because our Project model is incomplete.
// Most of the time it is irrelevant for our use case (GAV).
// nolint:errcheck