Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path.Clean paths in GlobalEnvParams and remove unnecessary path.Join #38677

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/kubeadm/app/apis/kubeadm/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package kubeadm
import (
"fmt"
"os"
"path"
"runtime"
"strings"
)
Expand Down Expand Up @@ -46,9 +47,9 @@ func SetEnvParams() *EnvParams {
}

return &EnvParams{
KubernetesDir: envParams["kubernetes_dir"],
HostPKIPath: envParams["host_pki_path"],
HostEtcdPath: envParams["host_etcd_path"],
KubernetesDir: path.Clean(envParams["kubernetes_dir"]),
HostPKIPath: path.Clean(envParams["host_pki_path"]),
HostEtcdPath: path.Clean(envParams["host_etcd_path"]),
HyperkubeImage: envParams["hyperkube_image"],
RepositoryPrefix: envParams["repo_prefix"],
DiscoveryImage: envParams["discovery_image"],
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/master/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func encodeKubeDiscoverySecretData(cfg *kubeadmapi.MasterConfiguration, caCert *
func newKubeDiscoveryPodSpec(cfg *kubeadmapi.MasterConfiguration) v1.PodSpec {
return v1.PodSpec{
// We have to use host network namespace, as `HostPort`/`HostIP` are Docker's
// buisness and CNI support isn't quite there yet (except for kubenet)
// business and CNI support isn't quite there yet (except for kubenet)
// (see https://github.com/kubernetes/kubernetes/issues/31307)
// TODO update this when #31307 is resolved
HostNetwork: true,
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/master/pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func CreatePKIAssets(cfg *kubeadmapi.MasterConfiguration) (*rsa.PrivateKey, *x50
}
altNames.DNSNames = append(altNames.DNSNames, cfg.API.ExternalDNSNames...)

pkiPath := path.Join(kubeadmapi.GlobalEnvParams.HostPKIPath)
pkiPath := kubeadmapi.GlobalEnvParams.HostPKIPath
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't equivalent. path.Join will also clean the path. If you want to remove the Join, you should replace it with path.Clean. See: https://play.golang.org/p/jLUuVGBBSy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for correcting me! now i clean all paths in GlobalEnvParams inside SetEnvParams function in env.go. so path.Join now can be removed safely.


caKey, caCert, err := newCertificateAuthority()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/node/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func createClients(caCert []byte, endpoint, token string, nodeName types.NodeNam
return clientSet, nil
}

// check to see if there are other nodes in the cluster with identical node names.
// CheckForNodeNameDuplicates checks whether there are other nodes in the cluster with identical node names.
func CheckForNodeNameDuplicates(connection *ConnectionDetails) error {
hostName, err := os.Hostname()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/util/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestEmptyVersion(t *testing.T) {

ver, err := KubernetesReleaseVersion("")
if err == nil {
t.Error("KubernetesReleaseVersion returned succesfully, but error expected")
t.Error("KubernetesReleaseVersion returned successfully, but error expected")
}
if ver != "" {
t.Error("KubernetesReleaseVersion returned value, expected only error")
Expand Down