Skip to content

Commit

Permalink
Merge pull request #113257 from claudiubelu/path-filepath-update-staging
Browse files Browse the repository at this point in the history
Replaces path.Operation with filepath.Operation (staging)

Kubernetes-commit: 80542ca2e318f6f82429822b267497570b7ecca5
  • Loading branch information
k8s-publishing-bot committed Apr 18, 2024
2 parents 3407442 + 79c893d commit 506bc53
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ require (
golang.org/x/term v0.18.0
golang.org/x/time v0.3.0
google.golang.org/protobuf v1.33.0
k8s.io/api v0.0.0-20240418093414-76b6c7ce02a4
k8s.io/apimachinery v0.0.0-20240418133208-ea31e5150286
k8s.io/api v0.0.0-20240418133400-98d0c7a1b77e
k8s.io/apimachinery v0.0.0-20240418133208-0ee3e6150890
k8s.io/klog/v2 v2.120.1
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.0.0-20240418093414-76b6c7ce02a4 h1:Aoz6y1eO+GKFC27cTyO+VJkbaEyQsGec2IhAYYaN7IU=
k8s.io/api v0.0.0-20240418093414-76b6c7ce02a4/go.mod h1:sbi+6EMV/95qn9kNfIj4HSNs4jcBqkcBxEAD+AKHUHY=
k8s.io/apimachinery v0.0.0-20240418133208-ea31e5150286 h1:pGpFsAFMSxtFe98HpTcgDgblsARQhckNfASAgCmlXS4=
k8s.io/apimachinery v0.0.0-20240418133208-ea31e5150286/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
k8s.io/api v0.0.0-20240418133400-98d0c7a1b77e h1:aMC4qrBMfXPVWNvK5a9JWrPqAYF7IqaEil4veyTpq14=
k8s.io/api v0.0.0-20240418133400-98d0c7a1b77e/go.mod h1:aiyYpZwHjPqNTHVIbcUReEDsDv1bLzwNhSENZpETJiA=
k8s.io/apimachinery v0.0.0-20240418133208-0ee3e6150890 h1:QnCWgLriYnSGYNYeDsMidsvvh4zidzUylhjQeKRajk4=
k8s.io/apimachinery v0.0.0-20240418133208-0ee3e6150890/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
Expand Down
5 changes: 2 additions & 3 deletions tools/clientcmd/api/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"fmt"
"os"
"path"
"path/filepath"
"reflect"
"strings"
Expand Down Expand Up @@ -115,7 +114,7 @@ func ShortenConfig(config *Config) {
// FlattenConfig changes the config object into a self-contained config (useful for making secrets)
func FlattenConfig(config *Config) error {
for key, authInfo := range config.AuthInfos {
baseDir, err := MakeAbs(path.Dir(authInfo.LocationOfOrigin), "")
baseDir, err := MakeAbs(filepath.Dir(authInfo.LocationOfOrigin), "")
if err != nil {
return err
}
Expand All @@ -130,7 +129,7 @@ func FlattenConfig(config *Config) error {
config.AuthInfos[key] = authInfo
}
for key, cluster := range config.Clusters {
baseDir, err := MakeAbs(path.Dir(cluster.LocationOfOrigin), "")
baseDir, err := MakeAbs(filepath.Dir(cluster.LocationOfOrigin), "")
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions tools/clientcmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package clientcmd
import (
"errors"
"os"
"path"
"path/filepath"
"reflect"
"sort"
Expand Down Expand Up @@ -148,7 +147,7 @@ func NewDefaultPathOptions() *PathOptions {
EnvVar: RecommendedConfigPathEnvVar,
ExplicitFileFlag: RecommendedConfigPathFlag,

GlobalFileSubpath: path.Join(RecommendedHomeDir, RecommendedFileName),
GlobalFileSubpath: filepath.Join(RecommendedHomeDir, RecommendedFileName),

LoadingRules: NewDefaultClientConfigLoadingRules(),
}
Expand Down
19 changes: 9 additions & 10 deletions tools/clientcmd/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"flag"
"fmt"
"os"
"path"
"path/filepath"
"reflect"
"strings"
Expand Down Expand Up @@ -539,13 +538,13 @@ func TestResolveRelativePaths(t *testing.T) {

configDir1, _ := os.MkdirTemp("", "")
defer os.RemoveAll(configDir1)
configFile1 := path.Join(configDir1, ".kubeconfig")
configFile1 := filepath.Join(configDir1, ".kubeconfig")
configDir1, _ = filepath.Abs(configDir1)

configDir2, _ := os.MkdirTemp("", "")
defer os.RemoveAll(configDir2)
configDir2, _ = os.MkdirTemp(configDir2, "")
configFile2 := path.Join(configDir2, ".kubeconfig")
configFile2 := filepath.Join(configDir2, ".kubeconfig")
configDir2, _ = filepath.Abs(configDir2)

WriteToFile(pathResolutionConfig1, configFile1)
Expand All @@ -564,11 +563,11 @@ func TestResolveRelativePaths(t *testing.T) {
for key, cluster := range mergedConfig.Clusters {
if key == "relative-server-1" {
foundClusterCount++
matchStringArg(path.Join(configDir1, pathResolutionConfig1.Clusters["relative-server-1"].CertificateAuthority), cluster.CertificateAuthority, t)
matchStringArg(filepath.Join(configDir1, pathResolutionConfig1.Clusters["relative-server-1"].CertificateAuthority), cluster.CertificateAuthority, t)
}
if key == "relative-server-2" {
foundClusterCount++
matchStringArg(path.Join(configDir2, pathResolutionConfig2.Clusters["relative-server-2"].CertificateAuthority), cluster.CertificateAuthority, t)
matchStringArg(filepath.Join(configDir2, pathResolutionConfig2.Clusters["relative-server-2"].CertificateAuthority), cluster.CertificateAuthority, t)
}
if key == "absolute-server-1" {
foundClusterCount++
Expand All @@ -587,13 +586,13 @@ func TestResolveRelativePaths(t *testing.T) {
for key, authInfo := range mergedConfig.AuthInfos {
if key == "relative-user-1" {
foundAuthInfoCount++
matchStringArg(path.Join(configDir1, pathResolutionConfig1.AuthInfos["relative-user-1"].ClientCertificate), authInfo.ClientCertificate, t)
matchStringArg(path.Join(configDir1, pathResolutionConfig1.AuthInfos["relative-user-1"].ClientKey), authInfo.ClientKey, t)
matchStringArg(filepath.Join(configDir1, pathResolutionConfig1.AuthInfos["relative-user-1"].ClientCertificate), authInfo.ClientCertificate, t)
matchStringArg(filepath.Join(configDir1, pathResolutionConfig1.AuthInfos["relative-user-1"].ClientKey), authInfo.ClientKey, t)
}
if key == "relative-user-2" {
foundAuthInfoCount++
matchStringArg(path.Join(configDir2, pathResolutionConfig2.AuthInfos["relative-user-2"].ClientCertificate), authInfo.ClientCertificate, t)
matchStringArg(path.Join(configDir2, pathResolutionConfig2.AuthInfos["relative-user-2"].ClientKey), authInfo.ClientKey, t)
matchStringArg(filepath.Join(configDir2, pathResolutionConfig2.AuthInfos["relative-user-2"].ClientCertificate), authInfo.ClientCertificate, t)
matchStringArg(filepath.Join(configDir2, pathResolutionConfig2.AuthInfos["relative-user-2"].ClientKey), authInfo.ClientKey, t)
}
if key == "absolute-user-1" {
foundAuthInfoCount++
Expand All @@ -607,7 +606,7 @@ func TestResolveRelativePaths(t *testing.T) {
}
if key == "relative-cmd-1" {
foundAuthInfoCount++
matchStringArg(path.Join(configDir1, pathResolutionConfig1.AuthInfos[key].Exec.Command), authInfo.Exec.Command, t)
matchStringArg(filepath.Join(configDir1, pathResolutionConfig1.AuthInfos[key].Exec.Command), authInfo.Exec.Command, t)
}
if key == "absolute-cmd-1" {
foundAuthInfoCount++
Expand Down

0 comments on commit 506bc53

Please sign in to comment.