-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
kubeadm: Make a separate util package for kubeconfig logic #41603
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ import ( | |
"github.com/spf13/cobra" | ||
|
||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" | ||
"k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig" | ||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my last comment. I really dislike how many package alias we use. Why can't we just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that some of the package aliases are bad, but I think this one makes sense as well. |
||
"k8s.io/kubernetes/cmd/kubeadm/app/preflight" | ||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util" | ||
"k8s.io/kubernetes/pkg/util/initsystem" | ||
|
@@ -150,7 +150,7 @@ func drainAndRemoveNode(removeNode bool) error { | |
hostname = strings.ToLower(hostname) | ||
|
||
// TODO: Use the "native" k8s client for this once we're confident the versioned is working | ||
kubeConfigPath := filepath.Join(kubeadmapi.GlobalEnvParams.KubernetesDir, kubeconfig.KubeletKubeConfigFileName) | ||
kubeConfigPath := filepath.Join(kubeadmapi.GlobalEnvParams.KubernetesDir, kubeadmconstants.KubeletKubeConfigFileName) | ||
|
||
getNodesCmd := fmt.Sprintf("kubectl --kubeconfig %s get nodes | grep %s", kubeConfigPath, hostname) | ||
output, err := exec.Command("sh", "-c", getNodesCmd).Output() | ||
|
@@ -221,8 +221,8 @@ func resetConfigDir(configPathDir, pkiPathDir string) { | |
} | ||
|
||
filesToClean := []string{ | ||
filepath.Join(configPathDir, kubeconfig.AdminKubeConfigFileName), | ||
filepath.Join(configPathDir, kubeconfig.KubeletKubeConfigFileName), | ||
filepath.Join(configPathDir, kubeadmconstants.AdminKubeConfigFileName), | ||
filepath.Join(configPathDir, kubeadmconstants.KubeletKubeConfigFileName), | ||
} | ||
fmt.Printf("[reset] Deleting files: %v\n", filesToClean) | ||
for _, path := range filesToClean { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you should have a pkgs alias here. kubeconfig doesn't seem to collide with anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think it's much better to throw
util
at the end so one knows for sure that it's question about a generic helpers lib.If the name was kubeconfig, I'd think it the question was about the kubeconfig phase for example, or a k8s-generic factory or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, and here is why: https://blog.golang.org/package-names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pires, @jbeda, @mikedanese what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be kubeconfig for that reason for instance.
Further, that doc said there should be no package named
util
and I'm trying to move things away fromkubeadmutil
(the "generic" one) as much as possible.What's your suggestion here other than kubeconfig?