Add Gocritic
This also fixes the issues laid out by gocritic
This commit is contained in:
@@ -10,15 +10,15 @@ import (
|
||||
is "gotest.tools/assert/cmp"
|
||||
)
|
||||
|
||||
//func parseLogOptions(q url.Values) (opts ContainerLogOpts, err error)
|
||||
// func parseLogOptions(q url.Values) (opts ContainerLogOpts, err error)
|
||||
func TestParseLogOptions(t *testing.T) {
|
||||
//tailLines
|
||||
//follow
|
||||
//limitBytes
|
||||
//previous
|
||||
//sinceSeconds
|
||||
//sinceTime
|
||||
//timestamps
|
||||
// tailLines
|
||||
// follow
|
||||
// limitBytes
|
||||
// previous
|
||||
// sinceSeconds
|
||||
// sinceTime
|
||||
// timestamps
|
||||
sinceTime, _ := time.Parse(time.RFC3339, "2020-03-20T21:07:34Z")
|
||||
fmt.Printf("%+v\n", sinceTime)
|
||||
testCases := []struct {
|
||||
|
||||
@@ -46,7 +46,7 @@ const (
|
||||
//
|
||||
// Note: Implementers can choose to manage a node themselves, in which case
|
||||
// it is not needed to provide an implementation for this interface.
|
||||
type NodeProvider interface { //nolint:golint
|
||||
type NodeProvider interface {
|
||||
// Ping checks if the node is still active.
|
||||
// This is intended to be lightweight as it will be called periodically as a
|
||||
// heartbeat to keep the node marked as ready in Kubernetes.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -303,10 +303,9 @@ func (pc *PodController) Run(ctx context.Context, podSyncWorkers int) (retErr er
|
||||
// At this point we know that something in .metadata or .spec has changed, so we must proceed to sync the pod.
|
||||
if key, err := cache.MetaNamespaceKeyFunc(newPod); err != nil {
|
||||
log.G(ctx).Error(err)
|
||||
} else {
|
||||
if podShouldEnqueue(oldPod, newPod) {
|
||||
pc.k8sQ.AddRateLimited(key)
|
||||
}
|
||||
} else if podShouldEnqueue(oldPod, newPod) {
|
||||
pc.k8sQ.AddRateLimited(key)
|
||||
|
||||
}
|
||||
},
|
||||
DeleteFunc: func(pod interface{}) {
|
||||
|
||||
Reference in New Issue
Block a user