Skip to content

Commit

Permalink
Fix antctl segment fault when kubeconfig cannot be resolved (antrea-i…
Browse files Browse the repository at this point in the history
…o#560)

Return an error when failed to load in-cluster config, when kubeconfig
file is not specified, and the default path does not exist.
  • Loading branch information
jianjuns authored Mar 29, 2020
1 parent a4d7541 commit 9c67768
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/antctl/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func (c *client) resolveKubeconfig(opt *requestOption) (*rest.Config, error) {
var kubeconfig *rest.Config
if _, err = os.Stat(opt.kubeconfig); opt.kubeconfig == clientcmd.RecommendedHomeFile && os.IsNotExist(err) {
kubeconfig, err = rest.InClusterConfig()
err = nil
if err != nil {
err = fmt.Errorf("Unable to resolve in-cluster configuration: %v. Please specify the kubeconfig file", err)
}
} else {
kubeconfig, err = clientcmd.BuildConfigFromFlags("", opt.kubeconfig)
}
Expand Down

0 comments on commit 9c67768

Please sign in to comment.