Add Gocritic
This also fixes the issues laid out by gocritic
This commit is contained in:
@@ -24,17 +24,7 @@ func ClientsetFromEnv(kubeConfigPath string) (*kubernetes.Clientset, error) {
|
||||
)
|
||||
|
||||
if kubeConfigPath != "" {
|
||||
_, err = os.Stat(kubeConfigPath)
|
||||
if err == nil {
|
||||
config, err = clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeConfigPath},
|
||||
&clientcmd.ConfigOverrides{},
|
||||
).ClientConfig()
|
||||
} else if os.IsNotExist(err) {
|
||||
config, err = rest.InClusterConfig()
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
config, err = clientsetFromEnvKubeConfigPath(kubeConfigPath)
|
||||
} else {
|
||||
config, err = rest.InClusterConfig()
|
||||
}
|
||||
@@ -46,6 +36,20 @@ func ClientsetFromEnv(kubeConfigPath string) (*kubernetes.Clientset, error) {
|
||||
return kubernetes.NewForConfig(config)
|
||||
}
|
||||
|
||||
func clientsetFromEnvKubeConfigPath(kubeConfigPath string) (*rest.Config, error) {
|
||||
_, err := os.Stat(kubeConfigPath)
|
||||
if os.IsNotExist(err) {
|
||||
return rest.InClusterConfig()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeConfigPath},
|
||||
&clientcmd.ConfigOverrides{},
|
||||
).ClientConfig()
|
||||
}
|
||||
|
||||
// PodInformerFilter is a filter that you should use when creating a pod informer for use with the pod controller.
|
||||
func PodInformerFilter(node string) kubeinformers.SharedInformerOption {
|
||||
return kubeinformers.WithTweakListOptions(func(options *metav1.ListOptions) {
|
||||
|
||||
Reference in New Issue
Block a user