1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-15 04:57:56 +00:00

Replace improper usage of filepath.Join with path.Join

In JSON and kubernetes API object names we want to use slashes instead
of the OS dependent file path separator.
This commit is contained in:
Markus Lehtonen 2021-02-10 12:49:23 +02:00
parent f0513eeda0
commit 76b95b6c55
2 changed files with 5 additions and 5 deletions

View file

@ -17,7 +17,7 @@ limitations under the License.
package apihelper
import (
"path/filepath"
"path"
"strings"
)
@ -29,6 +29,6 @@ type JsonPatch struct {
}
// NewJsonPatch returns a new JsonPatch object
func NewJsonPatch(verb string, path string, key string, value string) JsonPatch {
return JsonPatch{verb, filepath.Join(path, strings.ReplaceAll(key, "/", "~1")), value}
func NewJsonPatch(verb string, jsonpath string, key string, value string) JsonPatch {
return JsonPatch{verb, path.Join(jsonpath, strings.ReplaceAll(key, "/", "~1")), value}
}

View file

@ -24,7 +24,7 @@ import (
"log"
"net"
"os"
"path/filepath"
"path"
"regexp"
"sort"
"strconv"
@ -500,7 +500,7 @@ func addNs(src string, nsToAdd string) string {
if strings.Contains(src, "/") {
return src
}
return filepath.Join(nsToAdd, src)
return path.Join(nsToAdd, src)
}
// splitNs splits a name into its namespace and name parts