Skip to content

Commit

Permalink
fix: replace path.join with filepath.join (#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
SparkYuan committed Apr 1, 2024
1 parent c60a904 commit 0500969
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pkg/cmd/mod/mod_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mod
import (
"fmt"
"os"
"path"
"path/filepath"

"github.com/go-git/go-git/v5/plumbing"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/gitutil"
Expand Down Expand Up @@ -90,7 +90,7 @@ func (o *InitOptions) Run() error {
}

// remove existing directory
dir := path.Join(o.Path, o.Name)
dir := filepath.Join(o.Path, o.Name)
if err := os.RemoveAll(dir); err != nil {
return fmt.Errorf("failed to remove existing directory: %v", err)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/modules/generators/workload/workload_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package workload
import (
"fmt"
"net/url"
"path"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -394,7 +393,7 @@ func handleFileCreation(c container.Container, uniqueAppName, containerName stri

volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: sec.Name,
MountPath: path.Join("/", k),
MountPath: filepath.Join("/", k),
SubPath: sec.Key,
})
} else if v.Content != "" {
Expand Down Expand Up @@ -455,7 +454,7 @@ func handleDirCreation(c container.Container) (volumes []corev1.Volume, volumeMo

volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: sec.Name,
MountPath: path.Join("/", mountPath),
MountPath: filepath.Join("/", mountPath),
})
return nil
})
Expand Down
10 changes: 5 additions & 5 deletions pkg/modules/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strings"
"sync"
Expand Down Expand Up @@ -107,7 +107,7 @@ func buildPluginPath(namespace, resourceType, version string) (string, error) {
goOs := runtime.GOOS
goArch := runtime.GOARCH
name := resourceType + "_" + version
p := path.Join(prefixPath, namespace, resourceType, version, goOs, goArch, KusionModuleBinaryPrefix+name)
p := filepath.Join(prefixPath, namespace, resourceType, version, goOs, goArch, KusionModuleBinaryPrefix+name)
_, err = os.Stat(p)
if err != nil {
if os.IsNotExist(err) {
Expand All @@ -126,13 +126,13 @@ func newPluginClient(modulePluginPath, moduleName string) (*plugin.Client, error
if err != nil {
return nil, err
}
logDir := path.Join(dir, log.Folder, Dir)
logDir := filepath.Join(dir, log.Folder, Dir)
if _, err := os.Stat(logDir); os.IsNotExist(err) {
if err := os.MkdirAll(logDir, os.ModePerm); err != nil {
return nil, fmt.Errorf("failed to create module log dir: %w", err)
}
}
logFilePath = path.Join(logDir, moduleName+".log")
logFilePath = filepath.Join(logDir, moduleName+".log")
logFile, err := os.Create(logFilePath)
if err != nil {
return nil, fmt.Errorf("failed to create module log file: %w", err)
Expand Down Expand Up @@ -170,7 +170,7 @@ func PluginDir() (string, error) {
if env, found := os.LookupEnv(DefaultModulePathEnv); found {
return env, nil
} else if dir, err := kfile.KusionDataFolder(); err == nil {
return path.Join(dir, Dir), nil
return filepath.Join(dir, Dir), nil
} else {
return "", err
}
Expand Down

0 comments on commit 0500969

Please sign in to comment.