Skip to content

Commit

Permalink
Run make format
Browse files Browse the repository at this point in the history
  • Loading branch information
Claes Mogren committed Apr 20, 2020
1 parent 3bf7c47 commit 7765440
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 38 deletions.
3 changes: 1 addition & 2 deletions cmd/aws-k8s-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ const binaryName = "ipamd"

var version string


func main() {
os.Exit(_main())
}

func _main() int {
//Do not add anything before initializing logger
logConfig := logger.Configuration{
BinaryName: binaryName,
BinaryName: binaryName,
}
log := logger.New(&logConfig)

Expand Down
6 changes: 3 additions & 3 deletions cmd/routed-eni-cni-plugin/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ func LoadNetConf(bytes []byte) (*NetConf, logger.Logger, error) {

//logConfig
logConfig := logger.Configuration{
BinaryName: conf.Name,
LogLevel: conf.PluginLogLevel,
LogLocation: conf.PluginLogFile,
BinaryName: conf.Name,
LogLevel: conf.PluginLogLevel,
LogLocation: conf.PluginLogFile,
}
log := logger.New(&logConfig)

Expand Down
18 changes: 9 additions & 9 deletions cmd/routed-eni-cni-plugin/cni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ import (
)

const (
containerID = "test-container"
netNS = "/proc/ns/1234"
ifName = "eth0"
cniVersion = "1.0"
cniName = "aws-cni"
containerID = "test-container"
netNS = "/proc/ns/1234"
ifName = "eth0"
cniVersion = "1.0"
cniName = "aws-cni"
pluginLogLevel = "Debug"
pluginLogFile = "/var/log/aws-routed-eni/plugin.log"
cniType = "aws-cni"
ipAddr = "10.0.1.15"
devNum = 4
pluginLogFile = "/var/log/aws-routed-eni/plugin.log"
cniType = "aws-cni"
ipAddr = "10.0.1.15"
devNum = 4
)

var netConf = &NetConf{CNIVersion: cniVersion,
Expand Down
9 changes: 5 additions & 4 deletions cmd/routed-eni-cni-plugin/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ package driver

import (
"errors"
"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"
"net"
"os"
"testing"

"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

Expand All @@ -45,9 +46,9 @@ const (
)

var logConfig = logger.Configuration{
BinaryName: "aws-cni",
LogLevel: "Debug",
LogLocation: "/var/log/test.log",
BinaryName: "aws-cni",
LogLevel: "Debug",
LogLocation: "/var/log/test.log",
}

var log = logger.New(&logConfig)
Expand Down
3 changes: 2 additions & 1 deletion cmd/routed-eni-cni-plugin/driver/mocks/driver_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/awsutils/gen_vpc_ip_limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
package main

import (
"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"
"os"
"sort"
"text/template"
"time"

"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"

"github.com/aws/aws-sdk-go/aws"

"github.com/aws/aws-sdk-go/aws/session"
Expand Down
8 changes: 4 additions & 4 deletions pkg/ipamd/datastore/data_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type ENIIPPool struct {
// IsPrimary indicates whether ENI is a primary ENI
IsPrimary bool
ID string
// DeviceNumber is the device number of ENI
// DeviceNumber is the device number of ENI (0 means the primary ENI)
DeviceNumber int
// AssignedIPv4Addresses is the number of IP addresses already been assigned
AssignedIPv4Addresses int
Expand All @@ -127,7 +127,7 @@ type PodKey struct {
type PodIPInfo struct {
// IP is the IP address of pod
IP string
// DeviceNumber is the device number of pod
// DeviceNumber is the device number of the ENI
DeviceNumber int
}

Expand All @@ -138,7 +138,7 @@ type DataStore struct {
eniIPPools map[string]*ENIIPPool
podsIP map[PodKey]PodIPInfo
lock sync.RWMutex
log logger.Logger
log logger.Logger
}

// PodInfos contains pods IP information which uses key name_namespace_sandbox
Expand Down Expand Up @@ -171,7 +171,7 @@ func NewDataStore(log logger.Logger) *DataStore {
return &DataStore{
eniIPPools: make(map[string]*ENIIPPool),
podsIP: make(map[PodKey]PodIPInfo),
log: log,
log: log,
}
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/ipamd/datastore/data_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
package datastore

import (
"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"
"testing"
"time"

"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/logger"

"github.com/aws/amazon-vpc-cni-k8s/pkg/k8sapi"
"github.com/stretchr/testify/assert"
)

var logConfig = logger.Configuration{
BinaryName: "aws-cni",
LogLevel: "Debug",
LogLocation: "/var/log/test.log",
BinaryName: "aws-cni",
LogLevel: "Debug",
LogLocation: "/var/log/test.log",
}

var log = logger.New(&logConfig)
Expand Down
4 changes: 2 additions & 2 deletions pkg/networkutils/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const (

var log = logger.Get()

// NetworkAPIs defines the host level and the eni level network related operations
// NetworkAPIs defines the host level and the ENI level network related operations
type NetworkAPIs interface {
// SetupNodeNetwork performs node level network configuration
SetupHostNetwork(vpcCIDR *net.IPNet, vpcCIDRs []*string, primaryMAC string, primaryAddr *net.IP) error
Expand Down Expand Up @@ -254,7 +254,7 @@ func (n *linuxNetwork) SetupHostNetwork(vpcCIDR *net.IPNet, vpcCIDRs []*string,
err = n.procSys.Set(primaryIntfRPFilter, rpFilterLoose)
if err != nil {
return errors.Wrapf(err, "failed to configure %s RPF check", primaryIntf)
}
}
} else {
log.Infof("Skip updating RPF for primary interface: %s", primaryIntfRPFilter)
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/utils/logger/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ const (
defaultLogFilePath = "/host/var/log/aws-routed-eni/ipamd.log"
defaultLogLevel = "Debug"
binaryName = "L-IPamD"
envLogLevel = "AWS_VPC_K8S_CNI_LOGLEVEL"
envLogFilePath = "AWS_VPC_K8S_CNI_LOG_FILE"
envLogLevel = "AWS_VPC_K8S_CNI_LOGLEVEL"
envLogFilePath = "AWS_VPC_K8S_CNI_LOG_FILE"
)

// Configuration stores the config for the logger
type Configuration struct {
BinaryName string
LogLevel string
LogLocation string
BinaryName string
LogLevel string
LogLocation string
}

func LoadLogConfig() *Configuration {
return &Configuration{
BinaryName: binaryName,
LogLevel: getLogLevel(),
return &Configuration{
BinaryName: binaryName,
LogLevel: getLogLevel(),
LogLocation: getLogFileLocation(),
}
}
Expand Down

0 comments on commit 7765440

Please sign in to comment.