Skip to content

Commit

Permalink
Slash and burn unused code
Browse files Browse the repository at this point in the history
.. guided by `honnef.co/go/tools/cmd/staticcheck` and
`staticcheck -unused.whole-program -tests ./...`
  • Loading branch information
anguslees authored and mogren committed Aug 5, 2020
1 parent be9ca94 commit a96bfe0
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 293 deletions.
1 change: 0 additions & 1 deletion pkg/awsutils/awsutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ type EC2InstanceMetadataCache struct {
localIPv4 string
instanceID string
instanceType string
vpcIPv4CIDR string
vpcIPv4CIDRs StringSet
primaryENI string
primaryENImac string
Expand Down
1 change: 0 additions & 1 deletion pkg/cninswrapper/generate_mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@

package cninswrapper

//go:generate go run github.com/golang/mock/mockgen -destination mocks/cninswrapper_mocks.go -copyright_file ../../scripts/copyright.txt . NS
//go:generate go run github.com/golang/mock/mockgen -destination mock_ns/netns_mocks.go -copyright_file ../../scripts/copyright.txt github.com/containernetworking/plugins/pkg/ns NetNS
78 changes: 0 additions & 78 deletions pkg/cninswrapper/mocks/cninswrapper_mocks.go

This file was deleted.

38 changes: 0 additions & 38 deletions pkg/cninswrapper/ns.go

This file was deleted.

30 changes: 0 additions & 30 deletions pkg/k8sapi/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ const (
cniPodName = "aws-node"
)

// K8SAPIs defines interface to use kubelet introspection API
type K8SAPIs interface {
K8SGetLocalPodIPs() ([]*K8SPodInfo, error)
}

// K8SPodInfo provides pod info
type K8SPodInfo struct {
// Name is pod's name
Expand All @@ -54,9 +49,6 @@ type K8SPodInfo struct {

var log = logger.Get()

// ErrInformerNotSynced indicates that it has not synced with API server yet
var ErrInformerNotSynced = errors.New("discovery: informer not synced")

// Controller defines global context for discovery controller
type Controller struct {
workerPods map[string]*K8SPodInfo
Expand Down Expand Up @@ -162,28 +154,6 @@ func (d *Controller) DiscoverK8SPods(podListWatcher *cache.ListWatch) {
select {}
}

// K8SGetLocalPodIPs return the list of pods running on the local nodes
func (d *Controller) K8SGetLocalPodIPs() ([]*K8SPodInfo, error) {
var localPods []*K8SPodInfo

if !d.synced {
log.Info("GetLocalPods: informer not synced yet")
return nil, ErrInformerNotSynced
}

log.Debug("GetLocalPods start ...")
d.workerPodsLock.Lock()
defer d.workerPodsLock.Unlock()

for _, pod := range d.workerPods {
log.Infof("K8SGetLocalPodIPs discovered local Pods: %s %s %s %s",
pod.Name, pod.Namespace, pod.IP, pod.UID)
localPods = append(localPods, pod)
}

return localPods, nil
}

// The rest of logic/code are taken from kubernetes/client-go/examples/workqueue
func newController(queue workqueue.RateLimitingInterface, indexer cache.Indexer, informer cache.Controller) *controller {
return &controller{
Expand Down
16 changes: 0 additions & 16 deletions pkg/k8sapi/generate_mocks.go

This file was deleted.

64 changes: 0 additions & 64 deletions pkg/k8sapi/mocks/k8sapi_mocks.go

This file was deleted.

20 changes: 0 additions & 20 deletions pkg/netlinkwrapper/netlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,3 @@ func IsNotExistsError(err error) bool {
}
return false
}

// IsRouteExistsError returns true if the error type is syscall.EEXIST
// This helps us determine if we should ignore this error as the route
// we want to add has been added already in routing table
func IsRouteExistsError(err error) bool {
if errno, ok := err.(syscall.Errno); ok {
return errno == syscall.EEXIST
}
return false
}

// IsNetworkUnreachableError returns true if the error type is syscall.ENETUNREACH
// This helps us determine if we should ignore this error as the route the call
// depends on is not plumbed ready yet
func IsNetworkUnreachableError(err error) bool {
if errno, ok := err.(syscall.Errno); ok {
return errno == syscall.ENETUNREACH
}
return false
}
27 changes: 0 additions & 27 deletions pkg/utils/retry/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

package retry

import (
"fmt"
"strings"
)

type Retriable interface {
Retry() bool
}
Expand Down Expand Up @@ -52,25 +47,3 @@ func NewRetriableError(retriable Retriable, err error) RetriableError {
err,
}
}

type AttributeError struct {
err string
}

func (e AttributeError) Error() string {
return e.err
}

// MultiErr Implements error
type MultiErr struct {
errors []error
}

func (me MultiErr) Error() string {
ret := make([]string, len(me.errors)+1)
ret[0] = "Multiple error:"
for ndx, err := range me.errors {
ret[ndx+1] = fmt.Sprintf("\t%d: %s", ndx, err.Error())
}
return strings.Join(ret, "\n")
}
18 changes: 0 additions & 18 deletions pkg/utils/ttime/ttime.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ type Timer interface {
// DefaultTime is a Time that behaves normally
type DefaultTime struct{}

var _time Time = &DefaultTime{}

// Now returns the current time
func (*DefaultTime) Now() time.Time {
return time.Now()
Expand All @@ -42,19 +40,3 @@ func (*DefaultTime) After(d time.Duration) <-chan time.Time {
func (*DefaultTime) AfterFunc(d time.Duration, f func()) Timer {
return time.AfterFunc(d, f)
}

// SetTime configures what 'Time' implementation to use for each of the
// package-level methods.
func SetTime(t Time) {
_time = t
}

// Now returns the implementation's current time
func Now() time.Time {
return _time.Now()
}

// Since returns the time different from Now and the given time t
func Since(t time.Time) time.Duration {
return _time.Now().Sub(t)
}

0 comments on commit a96bfe0

Please sign in to comment.