Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1065 from qiujian16/host-config
Browse files Browse the repository at this point in the history
Get curretContext when host-cluster-context is empty
  • Loading branch information
k8s-ci-robot authored Jul 31, 2019
2 parents 610e80e + d91627b commit 5247f78
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/kubefedctl/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ func (j *joinFederation) Complete(args []string) error {

// Run is the implementation of the `join` command.
func (j *joinFederation) Run(cmdOut io.Writer, config util.FedConfig) error {
hostConfig, err := config.HostConfig(j.HostClusterContext, j.Kubeconfig)
hostClientConfig := config.GetClientConfig(j.HostClusterContext, j.Kubeconfig)
hostConfig, err := hostClientConfig.ClientConfig()
if err != nil {
// TODO(font): Return new error with this same text so it can be output
// by caller.
Expand All @@ -184,6 +185,16 @@ func (j *joinFederation) Run(cmdOut io.Writer, config util.FedConfig) error {
return err
}

// Set HostClusterContext as current context in kube config if it is not set
if j.HostClusterContext == "" {
rawConfig, err := hostClientConfig.RawConfig()
if err != nil {
klog.V(2).Infof("Failed to get current context in host client config")
return err
}
j.HostClusterContext = rawConfig.CurrentContext
}

hostClusterName := j.HostClusterContext
if j.HostClusterName != "" {
hostClusterName = j.HostClusterName
Expand Down

0 comments on commit 5247f78

Please sign in to comment.