Skip to content

Commit

Permalink
Merge pull request #48 from BSWANG/GITHUB-PR-2019-7-2
Browse files Browse the repository at this point in the history
fix golint & goimports warnings
  • Loading branch information
sunyuan3 authored Jul 3, 2019
2 parents e2d3be3 + eed1ce1 commit 297aebe
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- run:
name: validate go code with gometalinter
command: |
gometalinter --disable-all --skip vendor -E goconst -E gofmt -E ineffassign -E misspell -E vet -d ./...
gometalinter --disable-all --skip vendor -E goconst -E gofmt -E ineffassign -E goimports -E golint -E misspell -E vet -d ./...
- run:
name: use opensource tool client9/misspell to correct commonly misspelled English words
command: |
Expand Down
11 changes: 6 additions & 5 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package daemon
import (
"encoding/json"
"fmt"
"io/ioutil"
"net"
"os"
"sync"
"time"

"github.com/AliyunContainerService/terway/pkg/aliyun"
"github.com/AliyunContainerService/terway/pkg/metric"
"github.com/AliyunContainerService/terway/pkg/pool"
Expand All @@ -12,13 +18,8 @@ import (
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"golang.org/x/net/context"
"io/ioutil"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"net"
"os"
"sync"
"time"
)

const (
Expand Down
16 changes: 8 additions & 8 deletions daemon/eni-multi-ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package daemon

import (
"fmt"
"sync"

"github.com/AliyunContainerService/terway/pkg/aliyun"
"github.com/AliyunContainerService/terway/pkg/pool"
"github.com/AliyunContainerService/terway/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"sync"
)

const (
maxEniOperating = 5
maxIpBacklog = 10
maxIPBacklog = 10
)

type eniIPFactory struct {
Expand Down Expand Up @@ -102,7 +103,7 @@ func (f *eniIPFactory) submit() error {
return nil
}
}
return errors.Errorf("trigger ENIIP throttle, max operating concurrent: %v", maxIpBacklog)
return errors.Errorf("trigger ENIIP throttle, max operating concurrent: %v", maxIPBacklog)
}

func (f *eniIPFactory) popResult() (ip *types.ENIIP, err error) {
Expand Down Expand Up @@ -138,9 +139,8 @@ func (f *eniIPFactory) Create() (ip types.NetworkResource, err error) {
if err == nil {
ip, err = f.popResult()
return
} else {
logrus.Debugf("allocate from exist eni error: %v, creating eni", err)
}
logrus.Debugf("allocate from exist eni error: %v, creating eni", err)

select {
case f.eniOperChan <- struct{}{}:
Expand All @@ -161,7 +161,7 @@ func (f *eniIPFactory) Create() (ip types.NetworkResource, err error) {
eni := &ENI{
ENI: eniObj,
ecs: f.eniFactory.ecs,
ipBacklog: make(chan struct{}, maxIpBacklog),
ipBacklog: make(chan struct{}, maxIPBacklog),
done: make(chan struct{}, 1),
}

Expand Down Expand Up @@ -271,7 +271,7 @@ func newENIIPResourceManager(poolConfig *types.PoolConfig, ecs aliyun.ECS, alloc
eniFactory: eniFactory,
enis: []*ENI{},
eniOperChan: make(chan struct{}, maxEniOperating),
ipResultChan: make(chan *ENIIP, maxIpBacklog),
ipResultChan: make(chan *ENIIP, maxIPBacklog),
}

capacity, err := ecs.GetInstanceMaxPrivateIP(poolConfig.InstanceID)
Expand Down Expand Up @@ -310,7 +310,7 @@ func newENIIPResourceManager(poolConfig *types.PoolConfig, ecs aliyun.ECS, alloc
ENI: eni,
ips: []*ENIIP{},
ecs: ecs,
ipBacklog: make(chan struct{}, maxIpBacklog),
ipBacklog: make(chan struct{}, maxIPBacklog),
done: make(chan struct{}, 1),
}
factory.enis = append(factory.enis, poolENI)
Expand Down
13 changes: 7 additions & 6 deletions daemon/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ package daemon
import (
"encoding/json"
"fmt"
"net"
"os"
"strconv"
"strings"
"time"
"unicode"

"github.com/AliyunContainerService/terway/deviceplugin"
"github.com/AliyunContainerService/terway/pkg/storage"
"github.com/pkg/errors"
Expand All @@ -12,12 +19,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/client-go/kubernetes"
"net"
"os"
"strconv"
"strings"
"time"
"unicode"
)

const (
Expand Down
9 changes: 6 additions & 3 deletions daemon/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ package daemon

import (
"fmt"
"io/ioutil"
"net"
"net/http"

"github.com/AliyunContainerService/terway/pkg/metric"
"github.com/AliyunContainerService/terway/rpc"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
"io/ioutil"
"net"
"net/http"

//import pprof for diagnose
_ "net/http/pprof"
"os"
"os/signal"
Expand Down
13 changes: 7 additions & 6 deletions daemon/veth.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ package daemon
import (
"context"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"strings"
"time"

"github.com/AliyunContainerService/terway/pkg/link"
"github.com/AliyunContainerService/terway/types"
"github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk"
dockerTypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
log "github.com/sirupsen/logrus"
"io/ioutil"
"net"
"os"
"path/filepath"
"strings"
"time"
)

const (
Expand Down
12 changes: 7 additions & 5 deletions deviceplugin/eni.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package deviceplugin

import (
"k8s.io/apimachinery/pkg/util/wait"
"net"
"os"
"time"

"k8s.io/apimachinery/pkg/util/wait"

"fmt"
log "github.com/sirupsen/logrus"
"golang.org/x/net/context"
"google.golang.org/grpc"
"io/ioutil"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1beta1"
"path"
"regexp"
"sync"
"syscall"

log "github.com/sirupsen/logrus"
"golang.org/x/net/context"
"google.golang.org/grpc"
pluginapi "k8s.io/kubernetes/pkg/kubelet/apis/deviceplugin/v1beta1"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions examples/maxpods/maxpods.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package main
import (
"flag"
"fmt"
"github.com/AliyunContainerService/terway/pkg/aliyun"
"github.com/denverdino/aliyungo/common"
"io/ioutil"
"log"

"github.com/AliyunContainerService/terway/pkg/aliyun"
"github.com/denverdino/aliyungo/common"
)

var (
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"flag"

"github.com/AliyunContainerService/terway/daemon"
log "github.com/sirupsen/logrus"
)
Expand Down
7 changes: 4 additions & 3 deletions pkg/aliyun/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package aliyun

import (
"fmt"
"net"
"sync"
"time"

"github.com/AliyunContainerService/terway/pkg/metric"
"github.com/AliyunContainerService/terway/types"
"github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/wait"
"net"
"sync"
"time"
)

// ECS the interface of ecs operation set
Expand Down
3 changes: 2 additions & 1 deletion pkg/aliyun/eni.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package aliyun
import (
"encoding/json"
"fmt"
"net"

"github.com/AliyunContainerService/terway/pkg/link"
"github.com/AliyunContainerService/terway/types"
"github.com/denverdino/aliyungo/common"
"github.com/denverdino/aliyungo/ecs"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"net"
)

// ENIInfoGetter interface to get eni information
Expand Down
5 changes: 3 additions & 2 deletions pkg/aliyun/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package aliyun

import (
"fmt"
"github.com/AliyunContainerService/terway/pkg/metric"
"github.com/denverdino/aliyungo/common"
"io/ioutil"
"net/http"
"strings"
"time"

"github.com/AliyunContainerService/terway/pkg/metric"
"github.com/denverdino/aliyungo/common"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion pkg/metric/util.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package metric

import (
"github.com/prometheus/client_golang/prometheus"
"time"

"github.com/prometheus/client_golang/prometheus"
)

// MsSince returns milliseconds since start.
Expand Down
5 changes: 3 additions & 2 deletions pkg/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"errors"
"fmt"
"github.com/AliyunContainerService/terway/types"
log "github.com/sirupsen/logrus"
"strings"
"sync"
"time"

"github.com/AliyunContainerService/terway/types"
log "github.com/sirupsen/logrus"
)

// Errors of pool
Expand Down
5 changes: 3 additions & 2 deletions pkg/pool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package pool
import (
"context"
"fmt"
"github.com/AliyunContainerService/terway/types"
"github.com/stretchr/testify/assert"
"sync"
"testing"
"time"

"github.com/AliyunContainerService/terway/types"
"github.com/stretchr/testify/assert"
)

type mockObjectFactory struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/pool/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package pool

import (
"fmt"
"github.com/AliyunContainerService/terway/types"
"github.com/stretchr/testify/assert"
"testing"
"time"

"github.com/AliyunContainerService/terway/types"
"github.com/stretchr/testify/assert"
)

func TestInit(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package storage

import (
"errors"
"sync"

"github.com/boltdb/bolt"
log "github.com/sirupsen/logrus"
"sync"
)

// ErrNotFound key not found in store
Expand Down
3 changes: 2 additions & 1 deletion pkg/tc/tc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package tc

import (
"fmt"
"math"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
"math"
)

// TrafficShapingRule the interface traffic shaping rule
Expand Down
7 changes: 4 additions & 3 deletions plugin/driver/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package driver

import (
"fmt"
"net"
"os"
"syscall"

"github.com/AliyunContainerService/terway/pkg/tc"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"
"net"
"os"
"syscall"
)

// drivers implement objects
Expand Down
3 changes: 2 additions & 1 deletion plugin/driver/ipvlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package driver

import (
"fmt"
"net"

"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"
"net"
)

type ipvlanDriver struct {
Expand Down
Loading

0 comments on commit 297aebe

Please sign in to comment.