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/12/20 03:21:37 UTC
[camel-k] 04/05: (e2e): make the use of paths os independent
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 0b8a1fe6a720830e2f578ed0011ff9a622073f6e
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Thu Dec 1 18:42:27 2022 +0000
(e2e): make the use of paths os independent
* Uses FromSlash in tests to ensure comparisons on Windows are not affected
by direction of slashes
* Uses filepath.Base as path.Base fails to return the final name when
running on Windows
* Uses filepath.Join as path.Join, where appropriate, to return os
corrected paths
* Tests / Resources
* Uses filepath.ToSlash to make paths unix-like for consistent storage
and easy comparison
* jvm
* Ensure the classpath default paths are always converted to unix-style
* cmd/source/util.go
* Handles difference between how linux and windows deal with an invalid
path. Since a PathError is returned from the PermissionDenied test as
well then handling this through the error message is the only alternative
---
cmd/util/vfs-gen/main.go | 2 +-
pkg/builder/image.go | 13 +++---
pkg/builder/quarkus.go | 15 +++----
pkg/builder/s2i.go | 5 +--
pkg/builder/spectrum.go | 5 +--
pkg/cmd/config_test.go | 9 ++--
pkg/cmd/local/local.go | 30 ++++++-------
pkg/cmd/local/workdir.go | 25 ++++++-----
pkg/cmd/modeline.go | 5 +--
pkg/cmd/modeline_test.go | 78 ++++++++++++++++-----------------
pkg/cmd/run_support.go | 7 ++-
pkg/cmd/source/source.go | 4 +-
pkg/cmd/source/util.go | 8 ++++
pkg/cmd/source/util_test.go | 26 ++++++++++-
pkg/controller/build/build_pod.go | 14 +++---
pkg/controller/build/monitor_routine.go | 6 +--
pkg/install/kamelets.go | 3 +-
pkg/resources/resources_support.go | 5 ++-
pkg/trait/container.go | 4 +-
pkg/trait/jvm.go | 8 ++--
pkg/trait/jvm_test.go | 16 ++++---
pkg/trait/knative_service_test.go | 5 ++-
pkg/trait/openapi.go | 7 ++-
pkg/trait/trait_test.go | 6 +--
pkg/trait/trait_types.go | 17 +++----
pkg/util/camel/camel_dependencies.go | 3 +-
pkg/util/camel/camel_util.go | 16 +++----
pkg/util/camel/catalog.go | 4 +-
pkg/util/digest/digest.go | 4 +-
pkg/util/docker/docker.go | 10 ++---
pkg/util/docker/docker_base.go | 4 +-
pkg/util/jvm/keystore.go | 4 +-
pkg/util/maven/maven_command.go | 14 +++---
pkg/util/util.go | 2 +-
34 files changed, 211 insertions(+), 173 deletions(-)
diff --git a/cmd/util/vfs-gen/main.go b/cmd/util/vfs-gen/main.go
index 121d3646b..df8d94e01 100644
--- a/cmd/util/vfs-gen/main.go
+++ b/cmd/util/vfs-gen/main.go
@@ -110,7 +110,7 @@ func main() {
//
err = vfsgen.Generate(fs, vfsgen.Options{
Filename: resourceFile,
- PackageName: path.Base(destDir),
+ PackageName: filepath.Base(destDir),
})
if err != nil {
log.Fatalln(err)
diff --git a/pkg/builder/image.go b/pkg/builder/image.go
index a005f42f2..5bd5c46f0 100644
--- a/pkg/builder/image.go
+++ b/pkg/builder/image.go
@@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path"
+ "path/filepath"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
@@ -68,7 +69,7 @@ func nativeImageContext(ctx *builderContext) error {
ctx.Artifacts = []v1.Artifact{
{
ID: runner,
- Location: path.Join(ctx.Path, "maven", "target", runner),
+ Location: filepath.Join(ctx.Path, "maven", "target", runner),
Target: runner,
},
}
@@ -87,7 +88,7 @@ func executableDockerfile(ctx *builderContext) error {
USER nonroot
`)
- err := ioutil.WriteFile(path.Join(ctx.Path, ContextDir, "Dockerfile"), dockerfile, 0o400)
+ err := ioutil.WriteFile(filepath.Join(ctx.Path, ContextDir, "Dockerfile"), dockerfile, 0o400)
if err != nil {
return err
}
@@ -111,7 +112,7 @@ func jvmDockerfile(ctx *builderContext) error {
USER 1000
`)
- err := ioutil.WriteFile(path.Join(ctx.Path, ContextDir, "Dockerfile"), dockerfile, 0o400)
+ err := ioutil.WriteFile(filepath.Join(ctx.Path, ContextDir, "Dockerfile"), dockerfile, 0o400)
if err != nil {
return err
}
@@ -153,7 +154,7 @@ func imageContext(ctx *builderContext, selector artifactsSelector) error {
return err
}
- contextDir := path.Join(ctx.Path, ContextDir)
+ contextDir := filepath.Join(ctx.Path, ContextDir)
err = os.MkdirAll(contextDir, 0o700)
if err != nil {
@@ -161,7 +162,7 @@ func imageContext(ctx *builderContext, selector artifactsSelector) error {
}
for _, entry := range ctx.SelectedArtifacts {
- _, err := util.CopyFile(entry.Location, path.Join(contextDir, entry.Target))
+ _, err := util.CopyFile(entry.Location, filepath.Join(contextDir, entry.Target))
if err != nil {
return err
}
@@ -169,7 +170,7 @@ func imageContext(ctx *builderContext, selector artifactsSelector) error {
for _, entry := range ctx.Resources {
filePath, fileName := path.Split(entry.Target)
- fullPath := path.Join(contextDir, filePath, fileName)
+ fullPath := filepath.Join(contextDir, filePath, fileName)
if err := util.WriteFileWithContent(fullPath, entry.Content); err != nil {
return err
}
diff --git a/pkg/builder/quarkus.go b/pkg/builder/quarkus.go
index 2061a160f..f5ad3ef79 100644
--- a/pkg/builder/quarkus.go
+++ b/pkg/builder/quarkus.go
@@ -21,7 +21,6 @@ import (
"context"
"fmt"
"os"
- "path"
"path/filepath"
"strings"
@@ -146,7 +145,7 @@ func GenerateQuarkusProjectCommon(camelQuarkusVersion string, runtimeVersion str
}
func buildQuarkusRunner(ctx *builderContext) error {
- mc := maven.NewContext(path.Join(ctx.Path, "maven"))
+ mc := maven.NewContext(filepath.Join(ctx.Path, "maven"))
mc.GlobalSettings = ctx.Maven.GlobalSettings
mc.UserSettings = ctx.Maven.UserSettings
mc.SettingsSecurity = ctx.Maven.SettingsSecurity
@@ -155,7 +154,7 @@ func buildQuarkusRunner(ctx *builderContext) error {
if ctx.Maven.TrustStoreName != "" {
mc.ExtraMavenOpts = append(mc.ExtraMavenOpts,
- "-Djavax.net.ssl.trustStore="+path.Join(ctx.Path, ctx.Maven.TrustStoreName),
+ "-Djavax.net.ssl.trustStore="+filepath.Join(ctx.Path, ctx.Maven.TrustStoreName),
"-Djavax.net.ssl.trustStorePassword="+ctx.Maven.TrustStorePass,
)
}
@@ -169,7 +168,7 @@ func buildQuarkusRunner(ctx *builderContext) error {
}
func BuildQuarkusRunnerCommon(ctx context.Context, mc maven.Context, project maven.Project) error {
- resourcesPath := path.Join(mc.Path, "src", "main", "resources")
+ resourcesPath := filepath.Join(mc.Path, "src", "main", "resources")
if err := os.MkdirAll(resourcesPath, os.ModePerm); err != nil {
return errors.Wrap(err, "failure while creating resource folder")
}
@@ -179,7 +178,7 @@ func BuildQuarkusRunnerCommon(ctx context.Context, mc maven.Context, project mav
// may fail the build.
// In the future there should be a way to provide build information from secrets,
// configmap, etc.
- if _, err := os.Create(path.Join(resourcesPath, "application.properties")); err != nil {
+ if _, err := os.Create(filepath.Join(resourcesPath, "application.properties")); err != nil {
return errors.Wrap(err, "failure while creating application.properties")
}
@@ -194,7 +193,7 @@ func BuildQuarkusRunnerCommon(ctx context.Context, mc maven.Context, project mav
}
func computeQuarkusDependencies(ctx *builderContext) error {
- mc := maven.NewContext(path.Join(ctx.Path, "maven"))
+ mc := maven.NewContext(filepath.Join(ctx.Path, "maven"))
mc.GlobalSettings = ctx.Maven.GlobalSettings
mc.UserSettings = ctx.Maven.UserSettings
mc.SettingsSecurity = ctx.Maven.SettingsSecurity
@@ -215,7 +214,7 @@ func ProcessQuarkusTransitiveDependencies(mc maven.Context) ([]v1.Artifact, erro
var artifacts []v1.Artifact
// Quarkus fast-jar format is split into various sub-directories in quarkus-app
- quarkusAppDir := path.Join(mc.Path, "target", "quarkus-app")
+ quarkusAppDir := filepath.Join(mc.Path, "target", "quarkus-app")
// Discover application dependencies from the Quarkus fast-jar directory tree
err := filepath.Walk(quarkusAppDir, func(filePath string, info os.FileInfo, err error) error {
@@ -234,7 +233,7 @@ func ProcessQuarkusTransitiveDependencies(mc maven.Context) ([]v1.Artifact, erro
artifacts = append(artifacts, v1.Artifact{
ID: filepath.Base(fileRelPath),
Location: filePath,
- Target: path.Join(DependenciesDir, fileRelPath),
+ Target: filepath.Join(DependenciesDir, fileRelPath),
Checksum: "sha1:" + sha1,
})
}
diff --git a/pkg/builder/s2i.go b/pkg/builder/s2i.go
index d523e843b..140d3ad95 100644
--- a/pkg/builder/s2i.go
+++ b/pkg/builder/s2i.go
@@ -26,7 +26,6 @@ import (
"fmt"
"io"
"os"
- "path"
"path/filepath"
"strings"
"time"
@@ -145,7 +144,7 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
}
err = util.WithTempDir(t.build.Name+"-s2i-", func(tmpDir string) error {
- archive := path.Join(tmpDir, "archive.tar.gz")
+ archive := filepath.Join(tmpDir, "archive.tar.gz")
contextDir := t.task.ContextDir
if contextDir == "" {
@@ -157,7 +156,7 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
if err != nil {
return err
}
- contextDir = path.Join(pwd, ContextDir)
+ contextDir = filepath.Join(pwd, ContextDir)
}
archiveFile, err := os.Create(archive)
diff --git a/pkg/builder/spectrum.go b/pkg/builder/spectrum.go
index bcfac8e3f..d43f52954 100644
--- a/pkg/builder/spectrum.go
+++ b/pkg/builder/spectrum.go
@@ -23,7 +23,6 @@ import (
"io"
"io/ioutil"
"os"
- "path"
"path/filepath"
"runtime"
"strings"
@@ -67,7 +66,7 @@ func (t *spectrumTask) Do(ctx context.Context) v1.BuildStatus {
if err != nil {
return status.Failed(err)
}
- contextDir = path.Join(pwd, ContextDir)
+ contextDir = filepath.Join(pwd, ContextDir)
}
exists, err := util.DirectoryExists(contextDir)
@@ -132,7 +131,7 @@ func (t *spectrumTask) Do(ctx context.Context) v1.BuildStatus {
}
go readSpectrumLogs(newStdR)
- digest, err := spectrum.Build(options, contextDir+":"+path.Join(DeploymentDir))
+ digest, err := spectrum.Build(options, contextDir+":"+filepath.Join(DeploymentDir)) //nolint
if err != nil {
_ = os.RemoveAll(registryConfigDir)
return status.Failed(err)
diff --git a/pkg/cmd/config_test.go b/pkg/cmd/config_test.go
index 57d5a981e..ca299d775 100644
--- a/pkg/cmd/config_test.go
+++ b/pkg/cmd/config_test.go
@@ -20,6 +20,7 @@ package cmd
import (
"fmt"
"os"
+ "path/filepath"
"strings"
"testing"
@@ -85,14 +86,14 @@ func TestConfigFolderFlagToSub(t *testing.T) {
_, rootCmd, _ := initializeConfigCmdOptions(t, false)
output, err := test.ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "sub")
assert.Nil(t, err)
- assert.True(t, strings.Contains(output, fmt.Sprintf(" .kamel/%s", DefaultConfigLocation)), "The output is unexpected: "+output)
+ assert.True(t, strings.Contains(output, filepath.FromSlash(fmt.Sprintf(".kamel/%s", DefaultConfigLocation))), "The output is unexpected: "+output)
}
func TestConfigFolderFlagToHome(t *testing.T) {
_, rootCmd, _ := initializeConfigCmdOptions(t, false)
output, err := test.ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "home")
assert.Nil(t, err)
- assert.True(t, strings.Contains(output, fmt.Sprintf("/.kamel/%s", DefaultConfigLocation)), "The output is unexpected: "+output)
+ assert.True(t, strings.Contains(output, filepath.FromSlash(fmt.Sprintf(".kamel/%s", DefaultConfigLocation))), "The output is unexpected: "+output)
}
func TestConfigFolderFlagToEnv(t *testing.T) {
@@ -101,7 +102,7 @@ func TestConfigFolderFlagToEnv(t *testing.T) {
_, rootCmd, _ := initializeConfigCmdOptions(t, false)
output, err := test.ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "env")
assert.Nil(t, err)
- assert.True(t, strings.Contains(output, fmt.Sprintf("/foo/bar/%s", DefaultConfigLocation)), "The output is unexpected: "+output)
+ assert.True(t, strings.Contains(output, filepath.FromSlash(fmt.Sprintf("foo/bar/%s", DefaultConfigLocation))), "The output is unexpected: "+output)
}
func TestConfigFolderFlagToEnvWithConfigName(t *testing.T) {
@@ -114,7 +115,7 @@ func TestConfigFolderFlagToEnvWithConfigName(t *testing.T) {
_, rootCmd, _ := initializeConfigCmdOptions(t, false)
output, err := test.ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "env")
assert.Nil(t, err)
- assert.True(t, strings.Contains(output, "/foo/bar/config.yaml"), "The output is unexpected: "+output)
+ assert.True(t, strings.Contains(output, filepath.FromSlash("/foo/bar/config.yaml")), "The output is unexpected: "+output)
}
func TestConfigDefaultNamespace(t *testing.T) {
diff --git a/pkg/cmd/local/local.go b/pkg/cmd/local/local.go
index 353e7a1f9..0032e0eee 100644
--- a/pkg/cmd/local/local.go
+++ b/pkg/cmd/local/local.go
@@ -23,7 +23,7 @@ import (
"fmt"
"io/ioutil"
"os"
- "path"
+ "path/filepath"
"sort"
"strings"
@@ -99,7 +99,7 @@ func getTopLevelDependencies(ctx context.Context, catalog *camel.RuntimeCatalog,
sourceSpec := v1.SourceSpec{
DataSpec: v1.DataSpec{
- Name: path.Base(src),
+ Name: filepath.Base(src),
Content: data,
Compression: false,
},
@@ -176,7 +176,7 @@ func getRegularFilesInDir(directory string, dirnameInPath bool) ([]string, error
// Do not include hidden files or sub-directories.
if !file.IsDir() && !strings.HasPrefix(fileName, ".") {
if dirnameInPath {
- dirFiles = append(dirFiles, path.Join(directory, fileName))
+ dirFiles = append(dirFiles, filepath.Join(directory, fileName))
} else {
dirFiles = append(dirFiles, fileName)
}
@@ -373,7 +373,7 @@ func UpdateIntegrationProperties(properties []string, propertyFiles []string, ha
relocatedPropertyFiles := []string{}
dir := GetLocalPropertiesDir()
for _, propertyFile := range propertyFiles {
- relocatedPropertyFile := path.Join(dir, path.Base(propertyFile))
+ relocatedPropertyFile := filepath.Join(dir, filepath.Base(propertyFile))
if _, err := util.CopyFile(propertyFile, relocatedPropertyFile); err != nil {
return nil, err
}
@@ -383,7 +383,7 @@ func UpdateIntegrationProperties(properties []string, propertyFiles []string, ha
if !hasIntegrationDir {
// Output list of properties to property file if any CLI properties were given.
if len(properties) > 0 {
- propertyFilePath := path.Join(dir, "CLI.properties")
+ propertyFilePath := filepath.Join(dir, "CLI.properties")
if err := ioutil.WriteFile(propertyFilePath, []byte(strings.Join(properties, "\n")), 0o600); err != nil {
return nil, err
}
@@ -407,9 +407,9 @@ func updateIntegrationDependencies(dependencies []string) error {
var targetPath string
basePath := util.SubstringFrom(dependency, util.QuarkusDependenciesBaseDirectory)
if basePath != "" {
- targetPath = path.Join(dir, basePath)
+ targetPath = filepath.Join(dir, basePath)
} else {
- targetPath = path.Join(dir, path.Base(dependency))
+ targetPath = filepath.Join(dir, filepath.Base(dependency))
}
if _, err := util.CopyFile(dependency, targetPath); err != nil {
return err
@@ -426,7 +426,7 @@ func updateIntegrationRoutes(routes []string) error {
dir := getLocalRoutesDir()
for _, route := range routes {
- if _, err := util.CopyFile(route, path.Join(dir, path.Base(route))); err != nil {
+ if _, err := util.CopyFile(route, filepath.Join(dir, filepath.Base(route))); err != nil {
return err
}
}
@@ -476,7 +476,7 @@ func CopyIntegrationFilesToDirectory(files []string, directory string) ([]string
// Copy files to new location. Also create the list with relocated files.
relocatedFilesList := []string{}
for _, filePath := range files {
- newFilePath := path.Join(directory, path.Base(filePath))
+ newFilePath := filepath.Join(directory, filepath.Base(filePath))
if _, err := util.CopyFile(filePath, newFilePath); err != nil {
return relocatedFilesList, err
}
@@ -499,8 +499,8 @@ func CopyQuarkusAppFiles(dependenciesDir string, quarkusDir string) error {
}
for _, file := range files {
if strings.HasSuffix(file, ".dat") || strings.HasSuffix(file, "-bytecode.jar") {
- source := path.Join(dependenciesDir, file)
- destination := path.Join(quarkusDir, file)
+ source := filepath.Join(dependenciesDir, file)
+ destination := filepath.Join(quarkusDir, file)
if _, err = util.CopyFile(source, destination); err != nil {
return err
}
@@ -522,8 +522,8 @@ func CopyLibFiles(dependenciesDir string, libDir string) error {
}
for _, dependencyJar := range fileNames {
- source := path.Join(dependenciesDir, dependencyJar)
- destination := path.Join(libDir, dependencyJar)
+ source := filepath.Join(dependenciesDir, dependencyJar)
+ destination := filepath.Join(libDir, dependencyJar)
if _, err = util.CopyFile(source, destination); err != nil {
return err
}
@@ -545,8 +545,8 @@ func CopyAppFile(dependenciesDir string, appDir string) error {
for _, dependencyJar := range fileNames {
if strings.HasPrefix(dependencyJar, "camel-k-integration-") {
- source := path.Join(dependenciesDir, dependencyJar)
- destination := path.Join(appDir, dependencyJar)
+ source := filepath.Join(dependenciesDir, dependencyJar)
+ destination := filepath.Join(appDir, dependencyJar)
if _, err = util.CopyFile(source, destination); err != nil {
return err
}
diff --git a/pkg/cmd/local/workdir.go b/pkg/cmd/local/workdir.go
index 3ab67f5ba..1a7eecc6b 100644
--- a/pkg/cmd/local/workdir.go
+++ b/pkg/cmd/local/workdir.go
@@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -50,7 +51,7 @@ func DeleteMavenWorkingDirectory() error {
// getLocalDependenciesDir returns <mavenWorkingDirectory>/dependencies.
func getLocalDependenciesDir() string {
- return path.Join(MavenWorkingDirectory, util.DefaultDependenciesDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.DefaultDependenciesDirectoryName)
}
func createLocalDependenciesDirectory() error {
@@ -75,7 +76,7 @@ func createLocalDependenciesDirectory() error {
// GetLocalPropertiesDir returns <mavenWorkingDirectory>/properties.
func GetLocalPropertiesDir() string {
- return path.Join(MavenWorkingDirectory, util.DefaultPropertiesDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.DefaultPropertiesDirectoryName)
}
func CreateLocalPropertiesDirectory() error {
@@ -101,7 +102,7 @@ func CreateLocalPropertiesDirectory() error {
// getLocalRoutesDir returns <mavenWorkingDirectory>/routes.
func getLocalRoutesDir() string {
- return path.Join(MavenWorkingDirectory, util.DefaultRoutesDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.DefaultRoutesDirectoryName)
}
func createLocalRoutesDirectory() error {
@@ -126,7 +127,7 @@ func createLocalRoutesDirectory() error {
// getLocalQuarkusDir returns <mavenWorkingDirectory>/quarkus.
func getLocalQuarkusDir() string {
- return path.Join(MavenWorkingDirectory, util.CustomQuarkusDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.CustomQuarkusDirectoryName)
}
func createLocalQuarkusDirectory() error {
@@ -151,7 +152,7 @@ func createLocalQuarkusDirectory() error {
// getLocalAppDir returns <mavenWorkingDirectory>/app.
func getLocalAppDir() string {
- return path.Join(MavenWorkingDirectory, util.CustomAppDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.CustomAppDirectoryName)
}
func createLocalAppDirectory() error {
@@ -176,7 +177,7 @@ func createLocalAppDirectory() error {
// getLocalLibDir returns <mavenWorkingDirectory>/lib/main.
func getLocalLibDir() string {
- return path.Join(MavenWorkingDirectory, util.CustomLibDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.CustomLibDirectoryName)
}
func createLocalLibDirectory() error {
@@ -200,30 +201,30 @@ func createLocalLibDirectory() error {
}
func GetCustomDependenciesDir(dir string) string {
- return path.Join(dir, util.DefaultDependenciesDirectoryName)
+ return filepath.Join(dir, util.DefaultDependenciesDirectoryName)
}
func GetCustomPropertiesDir(dir string) string {
- return path.Join(dir, util.DefaultPropertiesDirectoryName)
+ return filepath.Join(dir, util.DefaultPropertiesDirectoryName)
}
func GetCustomRoutesDir(dir string) string {
- return path.Join(dir, util.DefaultRoutesDirectoryName)
+ return filepath.Join(dir, util.DefaultRoutesDirectoryName)
}
func GetCustomQuarkusDir(dir string) string {
parentDir := path.Dir(strings.TrimSuffix(dir, "/"))
- return path.Join(parentDir, util.CustomQuarkusDirectoryName)
+ return filepath.Join(parentDir, util.CustomQuarkusDirectoryName)
}
func GetCustomLibDir(dir string) string {
parentDir := path.Dir(strings.TrimSuffix(dir, "/"))
- return path.Join(parentDir, util.CustomLibDirectoryName)
+ return filepath.Join(parentDir, util.CustomLibDirectoryName)
}
func GetCustomAppDir(dir string) string {
parentDir := path.Dir(strings.TrimSuffix(dir, "/"))
- return path.Join(parentDir, "app")
+ return filepath.Join(parentDir, "app")
}
func DeleteLocalIntegrationDirs(dir string) error {
diff --git a/pkg/cmd/modeline.go b/pkg/cmd/modeline.go
index 4ef02caa2..5a7f2a698 100644
--- a/pkg/cmd/modeline.go
+++ b/pkg/cmd/modeline.go
@@ -20,7 +20,6 @@ package cmd
import (
"context"
"fmt"
- "path"
"path/filepath"
"strings"
@@ -231,7 +230,7 @@ func extractModelineOptionsFromSource(resolvedSource source.Source) ([]modeline.
baseDir := filepath.Dir(resolvedSource.Origin)
refPath := o.Value
if !filepath.IsAbs(refPath) {
- full := path.Join(baseDir, refPath)
+ full := filepath.Join(baseDir, refPath)
o.Value = full
ops[i] = o
}
@@ -239,7 +238,7 @@ func extractModelineOptionsFromSource(resolvedSource source.Source) ([]modeline.
baseDir := filepath.Dir(resolvedSource.Origin)
refPath := getRefPathOrProperty(o.Value)
if !filepath.IsAbs(refPath) {
- full := getFullPathOrProperty(o.Value, path.Join(baseDir, refPath))
+ full := getFullPathOrProperty(o.Value, filepath.Join(baseDir, refPath))
o.Value = full
ops[i] = o
}
diff --git a/pkg/cmd/modeline_test.go b/pkg/cmd/modeline_test.go
index 854bd52a9..f810380e9 100644
--- a/pkg/cmd/modeline_test.go
+++ b/pkg/cmd/modeline_test.go
@@ -22,7 +22,7 @@ import (
"fmt"
"io/ioutil"
"os"
- "path"
+ "path/filepath"
"testing"
"github.com/apache/camel-k/pkg/util"
@@ -35,7 +35,7 @@ func TestModelineRunSimple(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib:1.0
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -53,7 +53,7 @@ func TestModelineRunSimple(t *testing.T) {
func TestModelineRunHelp(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
// no file created
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "run", fileName, "--help"})
assert.NoError(t, err)
@@ -71,7 +71,7 @@ func TestModelineRunChain(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib:2.0
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -91,14 +91,14 @@ func TestModelineRunMultipleFiles(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib1:3.0
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
file2 := `
// camel-k: dependency=mvn:org.my:lib2:3.0
`
- fileName2 := path.Join(dir, "ext.groovy")
+ fileName2 := filepath.Join(dir, "ext.groovy")
err = ioutil.WriteFile(fileName2, []byte(file2), 0o400)
assert.NoError(t, err)
@@ -115,14 +115,14 @@ func TestModelineRunMultipleFiles(t *testing.T) {
func TestModelineRunProperty(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: property=my-prop=my-val
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -139,7 +139,7 @@ func TestModelineRunProperty(t *testing.T) {
func TestModelineRunDuplicatedProperties(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
@@ -148,7 +148,7 @@ func TestModelineRunDuplicatedProperties(t *testing.T) {
// camel-k: property=prop2=false
// camel-k: property=foo=bar
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -165,7 +165,7 @@ func TestModelineRunDuplicatedProperties(t *testing.T) {
func TestModelineRunDuplicatedBuildProperties(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
@@ -174,7 +174,7 @@ func TestModelineRunDuplicatedBuildProperties(t *testing.T) {
// camel-k: build-property=prop2=false
// camel-k: build-property=foo=bar
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -197,21 +197,21 @@ func TestModelineRunDuplicatedBuildProperties(t *testing.T) {
func TestModelineRunPropertyFiles(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: property=file:application.properties
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
propFile := `
a=b
`
- propFileName := path.Join(subDir, "application.properties")
+ propFileName := filepath.Join(subDir, "application.properties")
err = ioutil.WriteFile(propFileName, []byte(propFile), 0o400)
assert.NoError(t, err)
@@ -228,14 +228,14 @@ func TestModelineRunPropertyFiles(t *testing.T) {
func TestModelineRunBuildProperty(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: build-property=my-build-prop=my-val
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -252,21 +252,21 @@ func TestModelineRunBuildProperty(t *testing.T) {
func TestModelineRunBuildPropertyFiles(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: build-property=file:application.properties
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
propFile := `
a=b
`
- propFileName := path.Join(subDir, "application.properties")
+ propFileName := filepath.Join(subDir, "application.properties")
err = ioutil.WriteFile(propFileName, []byte(propFile), 0o400)
assert.NoError(t, err)
@@ -283,7 +283,7 @@ func TestModelineRunBuildPropertyFiles(t *testing.T) {
func TestModelineRunDuplicateTraits(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
@@ -292,7 +292,7 @@ func TestModelineRunDuplicateTraits(t *testing.T) {
// camel-k: trait=trait2=false
// camel-k: trait=foo=bar
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -309,14 +309,14 @@ func TestModelineRunDuplicateTraits(t *testing.T) {
func TestModelineRunConfigConfigmap(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: config=configmap:my-cm
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -333,14 +333,14 @@ func TestModelineRunConfigConfigmap(t *testing.T) {
func TestModelineRunConfigSecret(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: config=secret:my-secret
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -357,21 +357,21 @@ func TestModelineRunConfigSecret(t *testing.T) {
func TestModelineRunConfigFile(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: config=file:application.properties
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
propFile := `
a=b
`
- propFileName := path.Join(subDir, "application.properties")
+ propFileName := filepath.Join(subDir, "application.properties")
err = ioutil.WriteFile(propFileName, []byte(propFile), 0o400)
assert.NoError(t, err)
@@ -388,14 +388,14 @@ func TestModelineRunConfigFile(t *testing.T) {
func TestModelineRunResourceConfigmap(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: resource=configmap:my-cm
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -412,14 +412,14 @@ func TestModelineRunResourceConfigmap(t *testing.T) {
func TestModelineRunResourceSecret(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: resource=secret:my-secret
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -436,21 +436,21 @@ func TestModelineRunResourceSecret(t *testing.T) {
func TestModelineRunResourceFile(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: resource=file:application.properties
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
propFile := `
a=b
`
- propFileName := path.Join(subDir, "application.properties")
+ propFileName := filepath.Join(subDir, "application.properties")
err = ioutil.WriteFile(propFileName, []byte(propFile), 0o400)
assert.NoError(t, err)
@@ -471,7 +471,7 @@ func TestModelineInspectSimple(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib:1.0
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -493,7 +493,7 @@ func TestModelineInspectMultipleDeps(t *testing.T) {
// camel-k: dependency=mvn:org.my:lib:1.0
// camel-k: dependency=camel-k:camel-dep
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -514,7 +514,7 @@ func TestModelineQuotedPodTemplate(t *testing.T) {
file := `
// camel-k: pod-template='{ "containers": [], "securityContext": { "supplementalGroups": [ 553 ] }, "volumes": [] } }'
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
diff --git a/pkg/cmd/run_support.go b/pkg/cmd/run_support.go
index e929a67f3..812c7d326 100644
--- a/pkg/cmd/run_support.go
+++ b/pkg/cmd/run_support.go
@@ -24,7 +24,6 @@ import (
"net/http"
"net/url"
"os"
- "path"
"path/filepath"
"reflect"
"strings"
@@ -74,7 +73,7 @@ func parseConfigAndGenCm(ctx context.Context, cmd *cobra.Command, c client.Clien
if config.ContentType() == resource.ContentTypeText {
resourceType = v1.ResourceTypeConfig
}
- resourceSpec, err := binaryOrTextResource(path.Base(config.Name()), rawData, contentType, enableCompression, resourceType, config.DestinationPath())
+ resourceSpec, err := binaryOrTextResource(filepath.Base(config.Name()), rawData, contentType, enableCompression, resourceType, config.DestinationPath())
if err != nil {
return nil, err
}
@@ -189,9 +188,9 @@ func downloadDependency(ctx context.Context, url url.URL) (string, error) {
return "", err
}
defer res.Body.Close()
- base := path.Base(url.Path)
+ base := filepath.Base(url.Path)
if base == "." || base == "/" || filepath.Ext(base) == "" {
- base = path.Base(url.String())
+ base = filepath.Base(url.String())
if base == "." || base == "/" {
base = "tmp"
}
diff --git a/pkg/cmd/source/source.go b/pkg/cmd/source/source.go
index 4daeb89c2..3f04d0061 100644
--- a/pkg/cmd/source/source.go
+++ b/pkg/cmd/source/source.go
@@ -23,7 +23,7 @@ import (
"net/http"
"net/url"
"os"
- "path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -53,7 +53,7 @@ func newSource(location string, compress bool, loadContent func() ([]byte, error
locPath = location
}
src := Source{
- Name: path.Base(locPath),
+ Name: filepath.Base(locPath),
Origin: location,
Location: location,
Compress: compress,
diff --git a/pkg/cmd/source/util.go b/pkg/cmd/source/util.go
index 3e2b6a787..3ad2dc9ed 100644
--- a/pkg/cmd/source/util.go
+++ b/pkg/cmd/source/util.go
@@ -19,7 +19,9 @@ package source
import (
"fmt"
+ "io/fs"
"os"
+ "runtime"
"strings"
"github.com/pkg/errors"
@@ -43,6 +45,12 @@ func IsLocalAndFileExists(uri string) (bool, error) {
if os.IsNotExist(err) {
return false, nil
}
+
+ if _, ok := err.(*fs.PathError); ok && runtime.GOOS == "windows" { // nolint
+ // Windows returns a PathError rather than NotExist is path is invalid
+ return false, nil
+ }
+
// If it is a different error (ie, permission denied) we should report it back
return false, errors.Wrap(err, fmt.Sprintf("file system error while looking for %s", uri))
}
diff --git a/pkg/cmd/source/util_test.go b/pkg/cmd/source/util_test.go
index 53de90c9b..586743d2b 100644
--- a/pkg/cmd/source/util_test.go
+++ b/pkg/cmd/source/util_test.go
@@ -21,6 +21,9 @@ limitations under the License.
package source
import (
+ "os"
+ "path/filepath"
+ "runtime"
"testing"
"github.com/stretchr/testify/assert"
@@ -37,8 +40,29 @@ func TestCorrectFileValuesButNotFound(t *testing.T) {
assert.False(t, value2)
}
+func isWindows() bool {
+ return runtime.GOOS == "windows"
+}
+
func TestPermissionDenied(t *testing.T) {
- value, err := IsLocalAndFileExists("/root/test")
+ dir := "/tmp/filedir"
+
+ if isWindows() {
+ t.Skip("Test not reliably producing a result on a windows OS")
+ }
+
+ err := os.Mkdir(dir, 0700)
+ assert.Nil(t, err)
+
+ filename := filepath.Join(dir, "file.txt")
+ f, err := os.Create(filename)
+ assert.Nil(t, err)
+ defer f.Close()
+
+ err = os.Chmod(dir, 0000)
+ assert.Nil(t, err)
+
+ value, err := IsLocalAndFileExists(filename)
// must not panic because a permission error
assert.NotNil(t, err)
assert.False(t, value)
diff --git a/pkg/controller/build/build_pod.go b/pkg/controller/build/build_pod.go
index 42385d95c..257405928 100644
--- a/pkg/controller/build/build_pod.go
+++ b/pkg/controller/build/build_pod.go
@@ -21,7 +21,7 @@ import (
"context"
"fmt"
"os"
- "path"
+ "path/filepath"
"strconv"
"strings"
@@ -230,7 +230,7 @@ func addBuildTaskToPod(build *v1.Build, taskName string, pod *corev1.Pod) {
"--task-name",
taskName,
},
- WorkingDir: path.Join(builderDir, build.Name),
+ WorkingDir: filepath.Join(builderDir, build.Name),
Env: proxyFromEnvironment(),
}
@@ -336,7 +336,7 @@ func addBuildahTaskToPod(ctx context.Context, c ctrl.Reader, build *v1.Build, ta
Command: []string{"/bin/sh", "-c"},
Args: []string{strings.Join(args, " && ")},
Env: env,
- WorkingDir: path.Join(builderDir, build.Name, builder.ContextDir),
+ WorkingDir: filepath.Join(builderDir, build.Name, builder.ContextDir),
VolumeMounts: volumeMounts,
}
@@ -355,7 +355,7 @@ func addKanikoTaskToPod(ctx context.Context, c ctrl.Reader, build *v1.Build, tas
args := []string{
"--dockerfile=Dockerfile",
- "--context=" + path.Join(builderDir, build.Name, builder.ContextDir),
+ "--context=" + filepath.Join(builderDir, build.Name, builder.ContextDir),
"--destination=" + task.Image,
"--cache=" + strconv.FormatBool(cache),
"--cache-dir=" + builder.KanikoCacheDir,
@@ -452,7 +452,7 @@ func addKanikoTaskToPod(ctx context.Context, c ctrl.Reader, build *v1.Build, tas
ImagePullPolicy: corev1.PullIfNotPresent,
Args: args,
Env: env,
- WorkingDir: path.Join(builderDir, build.Name, builder.ContextDir),
+ WorkingDir: filepath.Join(builderDir, build.Name, builder.ContextDir),
VolumeMounts: volumeMounts,
}
@@ -469,7 +469,7 @@ func addContainerToPod(build *v1.Build, container corev1.Container, pod *corev1.
if hasBuilderVolume(pod) {
container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{
Name: builderVolume,
- MountPath: path.Join(builderDir, build.Name),
+ MountPath: filepath.Join(builderDir, build.Name),
})
}
@@ -563,7 +563,7 @@ func addRegistrySecret(name string, secret registrySecret, volumes *[]corev1.Vol
if secret.refEnv != "" {
*env = append(*env, corev1.EnvVar{
Name: secret.refEnv,
- Value: path.Join(secret.mountPath, secret.destination),
+ Value: filepath.Join(secret.mountPath, secret.destination),
})
}
}
diff --git a/pkg/controller/build/monitor_routine.go b/pkg/controller/build/monitor_routine.go
index 42f5a7902..2820c8a70 100644
--- a/pkg/controller/build/monitor_routine.go
+++ b/pkg/controller/build/monitor_routine.go
@@ -23,7 +23,7 @@ import (
"fmt"
"io/ioutil"
"os"
- "path"
+ "path/filepath"
"sync"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -137,13 +137,13 @@ tasks:
status.Failed(fmt.Errorf("cannot determine context directory for task %s", t.Name))
break tasks
}
- t.ContextDir = path.Join(buildDir, builder.ContextDir)
+ t.ContextDir = filepath.Join(buildDir, builder.ContextDir)
} else if t := task.S2i; t != nil && t.ContextDir == "" {
if buildDir == "" {
status.Failed(fmt.Errorf("cannot determine context directory for task %s", t.Name))
break tasks
}
- t.ContextDir = path.Join(buildDir, builder.ContextDir)
+ t.ContextDir = filepath.Join(buildDir, builder.ContextDir)
}
// Execute the task
diff --git a/pkg/install/kamelets.go b/pkg/install/kamelets.go
index 569453734..4f8102a85 100644
--- a/pkg/install/kamelets.go
+++ b/pkg/install/kamelets.go
@@ -25,7 +25,6 @@ import (
"io/fs"
"net/http"
"os"
- "path"
"path/filepath"
"strings"
"sync"
@@ -90,7 +89,7 @@ func KameletCatalog(ctx context.Context, c client.Client, namespace string) erro
}
// We may want to throttle the creation of Go routines if the number of bundled Kamelets increases.
g.Go(func() error {
- kamelet, err := loadKamelet(path.Join(kameletDir, f.Name()), namespace)
+ kamelet, err := loadKamelet(filepath.Join(kameletDir, f.Name()), namespace)
if err != nil {
return err
}
diff --git a/pkg/resources/resources_support.go b/pkg/resources/resources_support.go
index 28fa9ab4f..85774a3a0 100644
--- a/pkg/resources/resources_support.go
+++ b/pkg/resources/resources_support.go
@@ -22,6 +22,7 @@ import (
"io/ioutil"
"net/http"
"os"
+ "path"
"path/filepath"
"strings"
"text/template"
@@ -43,6 +44,7 @@ func ResourceAsString(name string) (string, error) {
// Resource provides an easy way to access to embedded assets.
func Resource(name string) ([]byte, error) {
name = strings.Trim(name, " ")
+ name = filepath.ToSlash(name)
if !strings.HasPrefix(name, "/") {
name = "/" + name
}
@@ -115,6 +117,7 @@ func WithPrefix(pathPrefix string) ([]string, error) {
// Resources lists all file names in the given path (starts with '/').
func Resources(dirName string) ([]string, error) {
+ dirName = filepath.ToSlash(dirName)
dir, err := openAsset(dirName)
if err != nil {
if os.IsNotExist(err) {
@@ -142,7 +145,7 @@ func Resources(dirName string) ([]string, error) {
var res []string
for _, f := range files {
if !f.IsDir() {
- res = append(res, filepath.Join(dirName, f.Name()))
+ res = append(res, path.Join(dirName, f.Name()))
}
}
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index bf2205473..b42f1e2df 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -19,7 +19,7 @@ package trait
import (
"fmt"
- "path"
+ "path/filepath"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
@@ -162,7 +162,7 @@ func (t *containerTrait) configureContainer(e *Environment) error {
}
envvar.SetVal(&container.Env, digest.IntegrationDigestEnvVar, e.Integration.Status.Digest)
- envvar.SetVal(&container.Env, "CAMEL_K_CONF", path.Join(camel.BasePath, "application.properties"))
+ envvar.SetVal(&container.Env, "CAMEL_K_CONF", filepath.Join(camel.BasePath, "application.properties"))
envvar.SetVal(&container.Env, "CAMEL_K_CONF_D", camel.ConfDPath)
e.addSourcesProperties()
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index 05609ff9e..60a4fbac2 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -20,7 +20,7 @@ package trait
import (
"fmt"
"net/url"
- "path"
+ "path/filepath"
"sort"
"strings"
@@ -102,8 +102,8 @@ func (t *jvmTrait) Apply(e *Environment) error {
classpath := strset.New()
classpath.Add("./resources")
- classpath.Add(camel.ConfigResourcesMountPath)
- classpath.Add(camel.ResourcesDefaultMountPath)
+ classpath.Add(filepath.ToSlash(camel.ConfigResourcesMountPath))
+ classpath.Add(filepath.ToSlash(camel.ResourcesDefaultMountPath))
if t.Classpath != "" {
classpath.Add(strings.Split(t.Classpath, ":")...)
}
@@ -116,7 +116,7 @@ func (t *jvmTrait) Apply(e *Environment) error {
// In case of an external created kit, we do not have any information about
// the classpath, so we assume the all jars in /deployments/dependencies/ have
// to be taken into account.
- dependencies := path.Join(builder.DeploymentDir, builder.DependenciesDir)
+ dependencies := filepath.Join(builder.DeploymentDir, builder.DependenciesDir)
classpath.Add(
dependencies+"/*",
dependencies+"/app/*",
diff --git a/pkg/trait/jvm_test.go b/pkg/trait/jvm_test.go
index 8fe4b772f..ad2d750f2 100644
--- a/pkg/trait/jvm_test.go
+++ b/pkg/trait/jvm_test.go
@@ -19,6 +19,7 @@ package trait
import (
"fmt"
+ "path/filepath"
"sort"
"strings"
"testing"
@@ -40,6 +41,11 @@ import (
"github.com/apache/camel-k/pkg/util/test"
)
+var (
+ crMountPath = filepath.ToSlash(camel.ConfigResourcesMountPath)
+ rdMountPath = filepath.ToSlash(camel.ResourcesDefaultMountPath)
+)
+
func TestConfigureJvmTraitInRightPhasesDoesSucceed(t *testing.T) {
trait, environment := createNominalJvmTest(v1.IntegrationKitTypePlatform)
@@ -103,12 +109,12 @@ func TestApplyJvmTraitWithDeploymentResource(t *testing.T) {
assert.Nil(t, err)
- cp := strset.New("./resources", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath, "/mount/path").List()
+ cp := strset.New("./resources", crMountPath, rdMountPath, "/mount/path").List()
sort.Strings(cp)
assert.Equal(t, []string{
"-cp",
- fmt.Sprintf("./resources:%s:%s:/mount/path", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath),
+ fmt.Sprintf("./resources:%s:%s:/mount/path", crMountPath, rdMountPath),
"io.quarkus.bootstrap.runner.QuarkusEntryPoint",
}, d.Spec.Template.Spec.Containers[0].Args)
}
@@ -135,12 +141,12 @@ func TestApplyJvmTraitWithKNativeResource(t *testing.T) {
assert.Nil(t, err)
- cp := strset.New("./resources", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath, "/mount/path").List()
+ cp := strset.New("./resources", crMountPath, rdMountPath, "/mount/path").List()
sort.Strings(cp)
assert.Equal(t, []string{
"-cp",
- fmt.Sprintf("./resources:%s:%s:/mount/path", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath),
+ fmt.Sprintf("./resources:%s:%s:/mount/path", crMountPath, rdMountPath),
"io.quarkus.bootstrap.runner.QuarkusEntryPoint",
}, s.Spec.Template.Spec.Containers[0].Args)
}
@@ -244,7 +250,7 @@ func TestApplyJvmTraitWithClasspath(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, []string{
"-cp",
- fmt.Sprintf("./resources:%s:%s:/mount/path:%s:%s", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath,
+ fmt.Sprintf("./resources:%s:%s:/mount/path:%s:%s", crMountPath, rdMountPath,
"/path/to/another/dep.jar", "/path/to/my-dep.jar"),
"io.quarkus.bootstrap.runner.QuarkusEntryPoint",
}, d.Spec.Template.Spec.Containers[0].Args)
diff --git a/pkg/trait/knative_service_test.go b/pkg/trait/knative_service_test.go
index d2f42e0aa..7f59faf74 100644
--- a/pkg/trait/knative_service_test.go
+++ b/pkg/trait/knative_service_test.go
@@ -18,6 +18,7 @@ limitations under the License.
package trait
import (
+ "path/filepath"
"testing"
"github.com/stretchr/testify/assert"
@@ -175,8 +176,8 @@ func TestKnativeService(t *testing.T) {
assert.Equal(t, "file:/etc/camel/sources/routes.js", environment.ApplicationProperties["camel.k.sources[0].location"])
assert.Equal(t, "js", environment.ApplicationProperties["camel.k.sources[0].language"])
assert.Equal(t, "true", environment.ApplicationProperties["camel.k.sources[0].compressed"])
- test.EnvVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF", "/etc/camel/application.properties")
- test.EnvVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF_D", "/etc/camel/conf.d")
+ test.EnvVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF", filepath.FromSlash("/etc/camel/application.properties"))
+ test.EnvVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF_D", filepath.FromSlash("/etc/camel/conf.d"))
}
func TestKnativeServiceWithCustomContainerName(t *testing.T) {
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
index 8615b1b07..f34589c5b 100644
--- a/pkg/trait/openapi.go
+++ b/pkg/trait/openapi.go
@@ -22,7 +22,6 @@ import (
"fmt"
"io/ioutil"
"os"
- "path"
"path/filepath"
"strconv"
"strings"
@@ -194,7 +193,7 @@ func (t *openAPITrait) generateOpenAPIConfigMap(e *Environment, resource v1.Data
}
func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.DataSpec, tmpDir, generatedContentName string) error {
- tmpDir = path.Join(tmpDir, generatedContentName)
+ tmpDir = filepath.Join(tmpDir, generatedContentName)
err := os.MkdirAll(tmpDir, os.ModePerm)
if err != nil {
return err
@@ -208,8 +207,8 @@ func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.Dat
}
}
- in := path.Join(tmpDir, resource.Name)
- out := path.Join(tmpDir, "openapi-dsl.xml")
+ in := filepath.Join(tmpDir, resource.Name)
+ out := filepath.Join(tmpDir, "openapi-dsl.xml")
err = ioutil.WriteFile(in, content, 0o400)
if err != nil {
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index 114c6fe00..63fcb07d0 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -18,7 +18,7 @@ limitations under the License.
package trait
import (
- "path"
+ "path/filepath"
"testing"
"github.com/stretchr/testify/assert"
@@ -233,7 +233,7 @@ func TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) {
m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "test-configmap" })
assert.NotNil(t, m)
- assert.Equal(t, path.Join(camel.ConfigConfigmapsMountPath, "test-configmap"), m.MountPath)
+ assert.Equal(t, filepath.Join(camel.ConfigConfigmapsMountPath, "test-configmap"), m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.Name == "test-secret" })
assert.NotNil(t, v)
@@ -242,7 +242,7 @@ func TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) {
m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "test-secret" })
assert.NotNil(t, m)
- assert.Equal(t, path.Join(camel.ConfigSecretsMountPath, "test-secret"), m.MountPath)
+ assert.Equal(t, filepath.Join(camel.ConfigSecretsMountPath, "test-secret"), m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.Name == "testvolume-data" })
assert.NotNil(t, v)
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index 39c800077..b38b9a7d8 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -21,6 +21,7 @@ import (
"context"
"fmt"
"path"
+ "path/filepath"
"sort"
"strings"
@@ -405,8 +406,8 @@ func (e *Environment) addSourcesProperties() {
e.ApplicationProperties = make(map[string]string)
}
for i, s := range e.Integration.Sources() {
- srcName := strings.TrimPrefix(s.Name, "/")
- src := "file:" + path.Join(camel.SourcesMountPath, srcName)
+ srcName := strings.TrimPrefix(filepath.ToSlash(s.Name), "/")
+ src := "file:" + path.Join(filepath.ToSlash(camel.SourcesMountPath), srcName)
e.ApplicationProperties[fmt.Sprintf("camel.k.sources[%d].location", i)] = src
simpleName := srcName
@@ -460,7 +461,7 @@ func (e *Environment) configureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]c
}
resName := strings.TrimPrefix(s.Name, "/")
refName := fmt.Sprintf("i-source-%03d", i)
- resPath := path.Join(camel.SourcesMountPath, resName)
+ resPath := filepath.Join(camel.SourcesMountPath, resName)
vol := getVolume(refName, "configmap", cmName, cmKey, resName)
mnt := getMount(refName, resPath, resName, true)
@@ -476,9 +477,9 @@ func (e *Environment) configureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]c
var mountPath string
switch propertiesType {
case "application":
- mountPath = path.Join(camel.BasePath, resName)
+ mountPath = filepath.Join(camel.BasePath, resName)
case "user":
- mountPath = path.Join(camel.ConfDPath, resName)
+ mountPath = filepath.Join(camel.ConfDPath, resName)
}
if propertiesType != "" {
@@ -521,7 +522,7 @@ func (e *Environment) configureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]c
if len(e.ServiceBindingSecret) > 0 {
secret := e.ServiceBindingSecret
refName := kubernetes.SanitizeLabel(secret)
- mountPath := path.Join(camel.ServiceBindingsMountPath, strings.ToLower(secret))
+ mountPath := filepath.Join(camel.ServiceBindingsMountPath, strings.ToLower(secret))
vol := getVolume(refName, "secret", secret, "", "")
mnt := getMount(refName, mountPath, "", true)
@@ -613,14 +614,14 @@ func getMountPoint(resourceName string, mountPoint string, storagetype, resource
return mountPoint
}
if resourceType == "data" {
- return path.Join(camel.ResourcesDefaultMountPath, resourceName)
+ return filepath.Join(camel.ResourcesDefaultMountPath, resourceName)
}
defaultMountPoint := camel.ConfigConfigmapsMountPath
if storagetype == "secret" {
defaultMountPoint = camel.ConfigSecretsMountPath
}
- return path.Join(defaultMountPoint, resourceName)
+ return filepath.Join(defaultMountPoint, resourceName)
}
func (e *Environment) collectConfigurationValues(configurationType string) []string {
diff --git a/pkg/util/camel/camel_dependencies.go b/pkg/util/camel/camel_dependencies.go
index abe230f08..7ef91d326 100644
--- a/pkg/util/camel/camel_dependencies.go
+++ b/pkg/util/camel/camel_dependencies.go
@@ -20,7 +20,6 @@ package camel
import (
"fmt"
"io"
- "path"
"path/filepath"
"strings"
@@ -221,7 +220,7 @@ func addRegistryMavenDependency(project *maven.Project, dependency string) error
"artifact",
},
Configuration: map[string]string{
- "outputDirectory": path.Join(outputDirectory, filepath.Dir(outputFileRelativePath)),
+ "outputDirectory": filepath.Join(outputDirectory, filepath.Dir(outputFileRelativePath)),
"outputFileName": filepath.Base(outputFileRelativePath),
"groupId": gav.GroupID,
"artifactId": gav.ArtifactID,
diff --git a/pkg/util/camel/camel_util.go b/pkg/util/camel/camel_util.go
index 7b6215881..4e252c906 100644
--- a/pkg/util/camel/camel_util.go
+++ b/pkg/util/camel/camel_util.go
@@ -18,7 +18,7 @@ limitations under the License.
package camel
import (
- "path"
+ "path/filepath"
"sort"
"strings"
@@ -30,13 +30,13 @@ import (
var (
BasePath = "/etc/camel"
- ConfDPath = path.Join(BasePath, "conf.d")
- SourcesMountPath = path.Join(BasePath, "sources")
- ResourcesDefaultMountPath = path.Join(BasePath, "resources")
- ConfigResourcesMountPath = path.Join(ConfDPath, "_resources")
- ConfigConfigmapsMountPath = path.Join(ConfDPath, "_configmaps")
- ConfigSecretsMountPath = path.Join(ConfDPath, "_secrets")
- ServiceBindingsMountPath = path.Join(ConfDPath, "_servicebindings")
+ ConfDPath = filepath.Join(BasePath, "conf.d")
+ SourcesMountPath = filepath.Join(BasePath, "sources")
+ ResourcesDefaultMountPath = filepath.Join(BasePath, "resources")
+ ConfigResourcesMountPath = filepath.Join(ConfDPath, "_resources")
+ ConfigConfigmapsMountPath = filepath.Join(ConfDPath, "_configmaps")
+ ConfigSecretsMountPath = filepath.Join(ConfDPath, "_secrets")
+ ServiceBindingsMountPath = filepath.Join(ConfDPath, "_servicebindings")
)
func findBestMatch(catalogs []v1.CamelCatalog, runtime v1.RuntimeSpec) (*RuntimeCatalog, error) {
diff --git a/pkg/util/camel/catalog.go b/pkg/util/camel/catalog.go
index 360f5ed12..7918fd775 100644
--- a/pkg/util/camel/catalog.go
+++ b/pkg/util/camel/catalog.go
@@ -19,7 +19,7 @@ package camel
import (
"context"
- "path"
+ "path/filepath"
yaml2 "gopkg.in/yaml.v2"
@@ -148,7 +148,7 @@ func GenerateCatalogCommon(
return err
}
- content, err := util.ReadFile(path.Join(tmpDir, "catalog.yaml"))
+ content, err := util.ReadFile(filepath.Join(tmpDir, "catalog.yaml"))
if err != nil {
return err
}
diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index ee119a452..ddadc615b 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -27,7 +27,7 @@ import (
"fmt"
"hash"
"io"
- "path"
+ "path/filepath"
"sort"
"strconv"
"strings"
@@ -311,7 +311,7 @@ func sortedTraitAnnotationsKeys(it *v1.Integration) []string {
}
func ComputeSHA1(elem ...string) (string, error) {
- file := path.Join(elem...)
+ file := filepath.Join(elem...)
// #nosec G401
h := sha1.New()
diff --git a/pkg/util/docker/docker.go b/pkg/util/docker/docker.go
index eca77307f..37d298190 100644
--- a/pkg/util/docker/docker.go
+++ b/pkg/util/docker/docker.go
@@ -19,7 +19,7 @@ package docker
import (
"os/exec"
- "path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -38,7 +38,7 @@ func CreateBaseImageDockerFile() error {
dockerFile = append(dockerFile, RUNMavenInstall())
// Write <BaseWorkingDirectory>/Dockerfile
- baseDockerFilePath := path.Join(BaseWorkingDirectory, "Dockerfile")
+ baseDockerFilePath := filepath.Join(BaseWorkingDirectory, "Dockerfile")
if err := util.WriteToFile(baseDockerFilePath, strings.Join(dockerFile, "\n")); err != nil {
return err
}
@@ -82,7 +82,7 @@ func CreateIntegrationImageDockerFile(integrationRunCmd *exec.Cmd, startsFromLoc
dockerFile = append(dockerFile, CMDShellWrap(strings.Join(integrationRunCmd.Args, " ")))
// Write <IntegrationWorkingDirectory>/Dockerfile
- integrationDockerFilePath := path.Join(IntegrationWorkingDirectory, "Dockerfile")
+ integrationDockerFilePath := filepath.Join(IntegrationWorkingDirectory, "Dockerfile")
err := util.WriteToFile(integrationDockerFilePath, strings.Join(dockerFile, "\n"))
if err != nil {
return err
@@ -139,7 +139,7 @@ func GetContainerRoutesDir() string {
func ContainerizeFilePaths(currentFilePaths []string, newDir string) []string {
newFilePaths := []string{}
for _, currentFilePath := range currentFilePaths {
- newFilePaths = append(newFilePaths, newDir+containerFileSeparator+path.Base(currentFilePath))
+ newFilePaths = append(newFilePaths, newDir+containerFileSeparator+filepath.Base(currentFilePath))
}
return newFilePaths
@@ -153,7 +153,7 @@ func ContainerizeDependencyPaths(dependencyPaths []string, newDir string) []stri
if newDependencyPath != "" {
newDependencyPaths = append(newDependencyPaths, newDir+newDependencyPath)
} else {
- newDependencyPaths = append(newDependencyPaths, newDir+containerFileSeparator+path.Base(currentDependencyPath))
+ newDependencyPaths = append(newDependencyPaths, newDir+containerFileSeparator+filepath.Base(currentDependencyPath))
}
}
return newDependencyPaths
diff --git a/pkg/util/docker/docker_base.go b/pkg/util/docker/docker_base.go
index 5fba82e95..f91f60bc1 100644
--- a/pkg/util/docker/docker_base.go
+++ b/pkg/util/docker/docker_base.go
@@ -18,7 +18,7 @@ limitations under the License.
package docker
import (
- "path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -56,7 +56,7 @@ func BuildImageArgs(dockerFileDir string, imageName string, sourceDir string) []
args = append(args, "build")
// Add path to Dockerfile:
- dockerFile := path.Join(dockerFileDir, "Dockerfile")
+ dockerFile := filepath.Join(dockerFileDir, "Dockerfile")
args = append(args, DockerfilePathArg(dockerFile)...)
diff --git a/pkg/util/jvm/keystore.go b/pkg/util/jvm/keystore.go
index 9788fa362..1721227b9 100644
--- a/pkg/util/jvm/keystore.go
+++ b/pkg/util/jvm/keystore.go
@@ -23,7 +23,7 @@ import (
"fmt"
"os"
"os/exec"
- "path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -56,7 +56,7 @@ func GenerateKeystore(ctx context.Context, keystoreDir, keystoreName, keystorePa
// JVM truststore.
javaHome, ok := os.LookupEnv("JAVA_HOME")
if ok {
- caCertsPath := path.Join(javaHome, "lib/security/cacerts")
+ caCertsPath := filepath.Join(javaHome, "lib/security/cacerts")
args := strings.Fields(fmt.Sprintf("-importkeystore -noprompt -srckeystore %s -srcstorepass %s -destkeystore %s -deststorepass %s", caCertsPath, "changeit", keystoreName, keystorePass))
cmd := exec.CommandContext(ctx, "keytool", args...)
cmd.Dir = keystoreDir
diff --git a/pkg/util/maven/maven_command.go b/pkg/util/maven/maven_command.go
index 2440a4328..c0cc4d764 100644
--- a/pkg/util/maven/maven_command.go
+++ b/pkg/util/maven/maven_command.go
@@ -24,7 +24,7 @@ import (
"io/ioutil"
"os"
"os/exec"
- "path"
+ "path/filepath"
"regexp"
"runtime"
"strconv"
@@ -62,14 +62,14 @@ func (c *Command) Do(ctx context.Context) error {
}
}
- settingsPath := path.Join(c.context.Path, "settings.xml")
+ settingsPath := filepath.Join(c.context.Path, "settings.xml")
if settingsExists, err := util.FileExists(settingsPath); err != nil {
return err
} else if settingsExists {
args = append(args, "--global-settings", settingsPath)
}
- settingsPath = path.Join(c.context.Path, "user-settings.xml")
+ settingsPath = filepath.Join(c.context.Path, "user-settings.xml")
if settingsExists, err := util.FileExists(settingsPath); err != nil {
return err
} else if settingsExists {
@@ -183,19 +183,19 @@ func generateProjectStructure(context Context, project Project) error {
}
if context.GlobalSettings != nil {
- if err := util.WriteFileWithContent(path.Join(context.Path, "settings.xml"), context.GlobalSettings); err != nil {
+ if err := util.WriteFileWithContent(filepath.Join(context.Path, "settings.xml"), context.GlobalSettings); err != nil {
return err
}
}
if context.UserSettings != nil {
- if err := util.WriteFileWithContent(path.Join(context.Path, "user-settings.xml"), context.UserSettings); err != nil {
+ if err := util.WriteFileWithContent(filepath.Join(context.Path, "user-settings.xml"), context.UserSettings); err != nil {
return err
}
}
if context.SettingsSecurity != nil {
- if err := util.WriteFileWithContent(path.Join(context.Path, "settings-security.xml"), context.SettingsSecurity); err != nil {
+ if err := util.WriteFileWithContent(filepath.Join(context.Path, "settings-security.xml"), context.SettingsSecurity); err != nil {
return err
}
}
@@ -218,7 +218,7 @@ func generateProjectStructure(context Context, project Project) error {
if len(bytes) > 0 {
Log.Infof("write entry: %s (%d bytes)", k, len(bytes))
- err = util.WriteFileWithContent(path.Join(context.Path, k), bytes)
+ err = util.WriteFileWithContent(filepath.Join(context.Path, k), bytes)
if err != nil {
return err
}
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 80fb19910..750aada65 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -330,7 +330,7 @@ func WriteFileWithBytesMarshallerContent(basePath string, filePath string, conte
return err
}
- return WriteFileWithContent(path.Join(basePath, filePath), data)
+ return WriteFileWithContent(filepath.Join(basePath, filePath), data)
}
func FindAllDistinctStringSubmatch(data string, regexps ...*regexp.Regexp) []string {