Skip to content

Commit

Permalink
Error handling for RKE Detection Pre-requisites
Browse files Browse the repository at this point in the history
  • Loading branch information
KiranBodipi committed Nov 6, 2023
1 parent 8529fb9 commit 91e13e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,20 @@ Alternatively, you can specify the version with --version

func getKubeVersion() (*KubeVersion, error) {
kubeConfig, err := rest.InClusterConfig()

if err != nil {
glog.V(3).Infof("Error fetching cluster config: %s", err)
}
isRKE := false
if kubeConfig != nil {
if err == nil && kubeConfig != nil {
k8sClient, err := kubernetes.NewForConfig(kubeConfig)
isRKE, err = providers.IsRKE(context.Background(), k8sClient)
if err != nil {
glog.V(3).Infof("Error detecting RKE cluster: %s", err)
glog.V(3).Infof("Failed to fetch k8sClient object from kube config : %s", err)
}
if err == nil {
isRKE, err = providers.IsRKE(context.Background(), k8sClient)
if err != nil {
glog.V(3).Infof("Error detecting RKE cluster: %s", err)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ func Test_getPlatformNameFromKubectlOutput(t *testing.T) {
},
{
name: "rancher1",
args: args{s: " v1.25.13-rancher1-1"},
args: args{s: "v1.25.13-rancher1-1"},
want: Platform{Name: "rancher1", Version: "1.25"},
},
{
Expand Down

0 comments on commit 91e13e5

Please sign in to comment.