Merge pull request #68544 from tanshanshan/lint912-2

fix golint for pkg/util/dbus, node, strings, workqueue/prometheus
This commit is contained in:
k8s-ci-robot 2018-10-23 16:44:31 -07:00 committed by GitHub
commit e7e6c8a95c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 38 deletions

View File

@ -375,7 +375,6 @@ pkg/ssh
pkg/util/bandwidth
pkg/util/config
pkg/util/configz
pkg/util/dbus
pkg/util/ebtables
pkg/util/env
pkg/util/file
@ -387,7 +386,6 @@ pkg/util/iptables/testing
pkg/util/labels
pkg/util/mount
pkg/util/netsh/testing
pkg/util/node
pkg/util/normalizer
pkg/util/oom
pkg/util/parsers
@ -401,7 +399,6 @@ pkg/util/sysctl/testing
pkg/util/system
pkg/util/taints
pkg/util/tolerations
pkg/util/workqueue/prometheus
pkg/version/verflag
pkg/volume
pkg/volume/azure_dd

View File

@ -209,9 +209,8 @@ func TestFakeDBus(t *testing.T) {
checkName := args[0].(string)
if checkName != ownedName {
return nil, godbus.Error{Name: "org.freedesktop.DBus.Error.NameHasNoOwner", Body: nil}
} else {
return []interface{}{uniqueName}, nil
}
return []interface{}{uniqueName}, nil
} else if method == "org.freedesktop.DBus.RequestName" {
reqName := args[0].(string)
_ = args[1].(uint32)

View File

@ -23,25 +23,25 @@ import (
godbus "github.com/godbus/dbus"
)
// DBusFake is a simple fake Interface type.
type DBusFake struct {
systemBus *DBusFakeConnection
sessionBus *DBusFakeConnection
// Fake is a simple fake Interface type.
type Fake struct {
systemBus *FakeConnection
sessionBus *FakeConnection
}
// DBusFakeConnection represents a fake D-Bus connection
type DBusFakeConnection struct {
// FakeConnection represents a fake D-Bus connection
type FakeConnection struct {
lock sync.Mutex
busObject *fakeObject
objects map[string]*fakeObject
signalHandlers []chan<- *godbus.Signal
}
// DBusFakeHandler is used to handle fake D-Bus method calls
type DBusFakeHandler func(method string, args ...interface{}) ([]interface{}, error)
// FakeHandler is used to handle fake D-Bus method calls
type FakeHandler func(method string, args ...interface{}) ([]interface{}, error)
type fakeObject struct {
handler DBusFakeHandler
handler FakeHandler
}
type fakeCall struct {
@ -50,46 +50,45 @@ type fakeCall struct {
}
// NewFake returns a new Interface which will fake talking to D-Bus
func NewFake(systemBus *DBusFakeConnection, sessionBus *DBusFakeConnection) *DBusFake {
return &DBusFake{systemBus, sessionBus}
func NewFake(systemBus *FakeConnection, sessionBus *FakeConnection) *Fake {
return &Fake{systemBus, sessionBus}
}
func NewFakeConnection() *DBusFakeConnection {
return &DBusFakeConnection{
// NewFakeConnection returns a FakeConnection Interface
func NewFakeConnection() *FakeConnection {
return &FakeConnection{
objects: make(map[string]*fakeObject),
}
}
// SystemBus is part of Interface
func (db *DBusFake) SystemBus() (Connection, error) {
func (db *Fake) SystemBus() (Connection, error) {
if db.systemBus != nil {
return db.systemBus, nil
} else {
return nil, fmt.Errorf("DBus is not running")
}
return nil, fmt.Errorf("DBus is not running")
}
// SessionBus is part of Interface
func (db *DBusFake) SessionBus() (Connection, error) {
func (db *Fake) SessionBus() (Connection, error) {
if db.sessionBus != nil {
return db.sessionBus, nil
} else {
return nil, fmt.Errorf("DBus is not running")
}
return nil, fmt.Errorf("DBus is not running")
}
// BusObject is part of the Connection interface
func (conn *DBusFakeConnection) BusObject() Object {
func (conn *FakeConnection) BusObject() Object {
return conn.busObject
}
// Object is part of the Connection interface
func (conn *DBusFakeConnection) Object(name, path string) Object {
func (conn *FakeConnection) Object(name, path string) Object {
return conn.objects[name+path]
}
// Signal is part of the Connection interface
func (conn *DBusFakeConnection) Signal(ch chan<- *godbus.Signal) {
func (conn *FakeConnection) Signal(ch chan<- *godbus.Signal) {
conn.lock.Lock()
defer conn.lock.Unlock()
for i := range conn.signalHandlers {
@ -102,17 +101,17 @@ func (conn *DBusFakeConnection) Signal(ch chan<- *godbus.Signal) {
}
// SetBusObject sets the handler for the BusObject of conn
func (conn *DBusFakeConnection) SetBusObject(handler DBusFakeHandler) {
func (conn *FakeConnection) SetBusObject(handler FakeHandler) {
conn.busObject = &fakeObject{handler}
}
// AddObject adds a handler for the Object at name and path
func (conn *DBusFakeConnection) AddObject(name, path string, handler DBusFakeHandler) {
func (conn *FakeConnection) AddObject(name, path string, handler FakeHandler) {
conn.objects[name+path] = &fakeObject{handler}
}
// EmitSignal emits a signal on conn
func (conn *DBusFakeConnection) EmitSignal(name, path, iface, signal string, args ...interface{}) {
func (conn *FakeConnection) EmitSignal(name, path, iface, signal string, args ...interface{}) {
conn.lock.Lock()
defer conn.lock.Unlock()
sig := &godbus.Signal{

View File

@ -36,9 +36,11 @@ import (
)
const (
// The reason and message set on a pod when its state cannot be confirmed as kubelet is unresponsive
// NodeUnreachablePodReason is the reason on a pod when its state cannot be confirmed as kubelet is unresponsive
// on the node it is (was) running.
NodeUnreachablePodReason = "NodeLost"
// NodeUnreachablePodMessage is the message on a pod when its state cannot be confirmed as kubelet is unresponsive
// on the node it is (was) running.
NodeUnreachablePodReason = "NodeLost"
NodeUnreachablePodMessage = "Node %v which was running pod %v is unresponsive"
)

View File

@ -22,7 +22,7 @@ import (
"unicode"
)
// SplitQualifiedName Splits a fully qualified name and returns its namespace and name.
// SplitQualifiedName splits a fully qualified name and returns its namespace and name.
// Assumes that the input 'str' has been validated.
func SplitQualifiedName(str string) (string, string) {
parts := strings.Split(str, "/")

View File

@ -31,7 +31,7 @@ func init() {
type prometheusMetricsProvider struct{}
func (_ prometheusMetricsProvider) NewDepthMetric(name string) workqueue.GaugeMetric {
func (prometheusMetricsProvider) NewDepthMetric(name string) workqueue.GaugeMetric {
depth := prometheus.NewGauge(prometheus.GaugeOpts{
Subsystem: name,
Name: "depth",
@ -41,7 +41,7 @@ func (_ prometheusMetricsProvider) NewDepthMetric(name string) workqueue.GaugeMe
return depth
}
func (_ prometheusMetricsProvider) NewAddsMetric(name string) workqueue.CounterMetric {
func (prometheusMetricsProvider) NewAddsMetric(name string) workqueue.CounterMetric {
adds := prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: name,
Name: "adds",
@ -51,7 +51,7 @@ func (_ prometheusMetricsProvider) NewAddsMetric(name string) workqueue.CounterM
return adds
}
func (_ prometheusMetricsProvider) NewLatencyMetric(name string) workqueue.SummaryMetric {
func (prometheusMetricsProvider) NewLatencyMetric(name string) workqueue.SummaryMetric {
latency := prometheus.NewSummary(prometheus.SummaryOpts{
Subsystem: name,
Name: "queue_latency",
@ -61,7 +61,7 @@ func (_ prometheusMetricsProvider) NewLatencyMetric(name string) workqueue.Summa
return latency
}
func (_ prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.SummaryMetric {
func (prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.SummaryMetric {
workDuration := prometheus.NewSummary(prometheus.SummaryOpts{
Subsystem: name,
Name: "work_duration",
@ -71,7 +71,7 @@ func (_ prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.
return workDuration
}
func (_ prometheusMetricsProvider) NewRetriesMetric(name string) workqueue.CounterMetric {
func (prometheusMetricsProvider) NewRetriesMetric(name string) workqueue.CounterMetric {
retries := prometheus.NewCounter(prometheus.CounterOpts{
Subsystem: name,
Name: "retries",