Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0ecff590
Commit
0ecff590
authored
Sep 12, 2018
by
tanshanshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix golint for some of pkg/util
parent
ee434665
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
38 deletions
+35
-38
.golint_failures
hack/.golint_failures
+0
-3
dbus_test.go
pkg/util/dbus/dbus_test.go
+1
-2
fake_dbus.go
pkg/util/dbus/fake_dbus.go
+24
-25
node.go
pkg/util/node/node.go
+4
-2
strings.go
pkg/util/strings/strings.go
+1
-1
prometheus.go
pkg/util/workqueue/prometheus/prometheus.go
+5
-5
No files found.
hack/.golint_failures
View file @
0ecff590
...
@@ -374,7 +374,6 @@ pkg/ssh
...
@@ -374,7 +374,6 @@ pkg/ssh
pkg/util/bandwidth
pkg/util/bandwidth
pkg/util/config
pkg/util/config
pkg/util/configz
pkg/util/configz
pkg/util/dbus
pkg/util/ebtables
pkg/util/ebtables
pkg/util/env
pkg/util/env
pkg/util/file
pkg/util/file
...
@@ -386,7 +385,6 @@ pkg/util/iptables/testing
...
@@ -386,7 +385,6 @@ pkg/util/iptables/testing
pkg/util/labels
pkg/util/labels
pkg/util/mount
pkg/util/mount
pkg/util/netsh/testing
pkg/util/netsh/testing
pkg/util/node
pkg/util/normalizer
pkg/util/normalizer
pkg/util/oom
pkg/util/oom
pkg/util/parsers
pkg/util/parsers
...
@@ -400,7 +398,6 @@ pkg/util/sysctl/testing
...
@@ -400,7 +398,6 @@ pkg/util/sysctl/testing
pkg/util/system
pkg/util/system
pkg/util/taints
pkg/util/taints
pkg/util/tolerations
pkg/util/tolerations
pkg/util/workqueue/prometheus
pkg/version/verflag
pkg/version/verflag
pkg/volume
pkg/volume
pkg/volume/azure_dd
pkg/volume/azure_dd
...
...
pkg/util/dbus/dbus_test.go
View file @
0ecff590
...
@@ -209,9 +209,8 @@ func TestFakeDBus(t *testing.T) {
...
@@ -209,9 +209,8 @@ func TestFakeDBus(t *testing.T) {
checkName
:=
args
[
0
]
.
(
string
)
checkName
:=
args
[
0
]
.
(
string
)
if
checkName
!=
ownedName
{
if
checkName
!=
ownedName
{
return
nil
,
godbus
.
Error
{
Name
:
"org.freedesktop.DBus.Error.NameHasNoOwner"
,
Body
:
nil
}
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"
{
}
else
if
method
==
"org.freedesktop.DBus.RequestName"
{
reqName
:=
args
[
0
]
.
(
string
)
reqName
:=
args
[
0
]
.
(
string
)
_
=
args
[
1
]
.
(
uint32
)
_
=
args
[
1
]
.
(
uint32
)
...
...
pkg/util/dbus/fake_dbus.go
View file @
0ecff590
...
@@ -23,25 +23,25 @@ import (
...
@@ -23,25 +23,25 @@ import (
godbus
"github.com/godbus/dbus"
godbus
"github.com/godbus/dbus"
)
)
//
DBus
Fake is a simple fake Interface type.
// Fake is a simple fake Interface type.
type
DBus
Fake
struct
{
type
Fake
struct
{
systemBus
*
DBus
FakeConnection
systemBus
*
FakeConnection
sessionBus
*
DBus
FakeConnection
sessionBus
*
FakeConnection
}
}
//
DBus
FakeConnection represents a fake D-Bus connection
// FakeConnection represents a fake D-Bus connection
type
DBus
FakeConnection
struct
{
type
FakeConnection
struct
{
lock
sync
.
Mutex
lock
sync
.
Mutex
busObject
*
fakeObject
busObject
*
fakeObject
objects
map
[
string
]
*
fakeObject
objects
map
[
string
]
*
fakeObject
signalHandlers
[]
chan
<-
*
godbus
.
Signal
signalHandlers
[]
chan
<-
*
godbus
.
Signal
}
}
//
DBus
FakeHandler is used to handle fake D-Bus method calls
// FakeHandler is used to handle fake D-Bus method calls
type
DBus
FakeHandler
func
(
method
string
,
args
...
interface
{})
([]
interface
{},
error
)
type
FakeHandler
func
(
method
string
,
args
...
interface
{})
([]
interface
{},
error
)
type
fakeObject
struct
{
type
fakeObject
struct
{
handler
DBus
FakeHandler
handler
FakeHandler
}
}
type
fakeCall
struct
{
type
fakeCall
struct
{
...
@@ -50,46 +50,45 @@ type fakeCall struct {
...
@@ -50,46 +50,45 @@ type fakeCall struct {
}
}
// NewFake returns a new Interface which will fake talking to D-Bus
// NewFake returns a new Interface which will fake talking to D-Bus
func
NewFake
(
systemBus
*
DBusFakeConnection
,
sessionBus
*
DBusFakeConnection
)
*
DBus
Fake
{
func
NewFake
(
systemBus
*
FakeConnection
,
sessionBus
*
FakeConnection
)
*
Fake
{
return
&
DBus
Fake
{
systemBus
,
sessionBus
}
return
&
Fake
{
systemBus
,
sessionBus
}
}
}
func
NewFakeConnection
()
*
DBusFakeConnection
{
// NewFakeConnection returns a FakeConnection Interface
return
&
DBusFakeConnection
{
func
NewFakeConnection
()
*
FakeConnection
{
return
&
FakeConnection
{
objects
:
make
(
map
[
string
]
*
fakeObject
),
objects
:
make
(
map
[
string
]
*
fakeObject
),
}
}
}
}
// SystemBus is part of Interface
// SystemBus is part of Interface
func
(
db
*
DBus
Fake
)
SystemBus
()
(
Connection
,
error
)
{
func
(
db
*
Fake
)
SystemBus
()
(
Connection
,
error
)
{
if
db
.
systemBus
!=
nil
{
if
db
.
systemBus
!=
nil
{
return
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
// SessionBus is part of Interface
func
(
db
*
DBus
Fake
)
SessionBus
()
(
Connection
,
error
)
{
func
(
db
*
Fake
)
SessionBus
()
(
Connection
,
error
)
{
if
db
.
sessionBus
!=
nil
{
if
db
.
sessionBus
!=
nil
{
return
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
// BusObject is part of the Connection interface
func
(
conn
*
DBus
FakeConnection
)
BusObject
()
Object
{
func
(
conn
*
FakeConnection
)
BusObject
()
Object
{
return
conn
.
busObject
return
conn
.
busObject
}
}
// Object is part of the Connection interface
// Object is part of the Connection interface
func
(
conn
*
DBus
FakeConnection
)
Object
(
name
,
path
string
)
Object
{
func
(
conn
*
FakeConnection
)
Object
(
name
,
path
string
)
Object
{
return
conn
.
objects
[
name
+
path
]
return
conn
.
objects
[
name
+
path
]
}
}
// Signal is part of the Connection interface
// Signal is part of the Connection interface
func
(
conn
*
DBus
FakeConnection
)
Signal
(
ch
chan
<-
*
godbus
.
Signal
)
{
func
(
conn
*
FakeConnection
)
Signal
(
ch
chan
<-
*
godbus
.
Signal
)
{
conn
.
lock
.
Lock
()
conn
.
lock
.
Lock
()
defer
conn
.
lock
.
Unlock
()
defer
conn
.
lock
.
Unlock
()
for
i
:=
range
conn
.
signalHandlers
{
for
i
:=
range
conn
.
signalHandlers
{
...
@@ -102,17 +101,17 @@ func (conn *DBusFakeConnection) Signal(ch chan<- *godbus.Signal) {
...
@@ -102,17 +101,17 @@ func (conn *DBusFakeConnection) Signal(ch chan<- *godbus.Signal) {
}
}
// SetBusObject sets the handler for the BusObject of conn
// SetBusObject sets the handler for the BusObject of conn
func
(
conn
*
DBusFakeConnection
)
SetBusObject
(
handler
DBus
FakeHandler
)
{
func
(
conn
*
FakeConnection
)
SetBusObject
(
handler
FakeHandler
)
{
conn
.
busObject
=
&
fakeObject
{
handler
}
conn
.
busObject
=
&
fakeObject
{
handler
}
}
}
// AddObject adds a handler for the Object at name and path
// AddObject adds a handler for the Object at name and path
func
(
conn
*
DBusFakeConnection
)
AddObject
(
name
,
path
string
,
handler
DBus
FakeHandler
)
{
func
(
conn
*
FakeConnection
)
AddObject
(
name
,
path
string
,
handler
FakeHandler
)
{
conn
.
objects
[
name
+
path
]
=
&
fakeObject
{
handler
}
conn
.
objects
[
name
+
path
]
=
&
fakeObject
{
handler
}
}
}
// EmitSignal emits a signal on conn
// EmitSignal emits a signal on conn
func
(
conn
*
DBus
FakeConnection
)
EmitSignal
(
name
,
path
,
iface
,
signal
string
,
args
...
interface
{})
{
func
(
conn
*
FakeConnection
)
EmitSignal
(
name
,
path
,
iface
,
signal
string
,
args
...
interface
{})
{
conn
.
lock
.
Lock
()
conn
.
lock
.
Lock
()
defer
conn
.
lock
.
Unlock
()
defer
conn
.
lock
.
Unlock
()
sig
:=
&
godbus
.
Signal
{
sig
:=
&
godbus
.
Signal
{
...
...
pkg/util/node/node.go
View file @
0ecff590
...
@@ -36,9 +36,11 @@ import (
...
@@ -36,9 +36,11 @@ import (
)
)
const
(
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.
// on the node it is (was) running.
NodeUnreachablePodReason
=
"NodeLost"
NodeUnreachablePodMessage
=
"Node %v which was running pod %v is unresponsive"
NodeUnreachablePodMessage
=
"Node %v which was running pod %v is unresponsive"
)
)
...
...
pkg/util/strings/strings.go
View file @
0ecff590
...
@@ -22,7 +22,7 @@ import (
...
@@ -22,7 +22,7 @@ import (
"unicode"
"unicode"
)
)
// SplitQualifiedName
S
plits a fully qualified name and returns its namespace and name.
// SplitQualifiedName
s
plits a fully qualified name and returns its namespace and name.
// Assumes that the input 'str' has been validated.
// Assumes that the input 'str' has been validated.
func
SplitQualifiedName
(
str
string
)
(
string
,
string
)
{
func
SplitQualifiedName
(
str
string
)
(
string
,
string
)
{
parts
:=
strings
.
Split
(
str
,
"/"
)
parts
:=
strings
.
Split
(
str
,
"/"
)
...
...
pkg/util/workqueue/prometheus/prometheus.go
View file @
0ecff590
...
@@ -31,7 +31,7 @@ func init() {
...
@@ -31,7 +31,7 @@ func init() {
type
prometheusMetricsProvider
struct
{}
type
prometheusMetricsProvider
struct
{}
func
(
_
prometheusMetricsProvider
)
NewDepthMetric
(
name
string
)
workqueue
.
GaugeMetric
{
func
(
prometheusMetricsProvider
)
NewDepthMetric
(
name
string
)
workqueue
.
GaugeMetric
{
depth
:=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
depth
:=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Subsystem
:
name
,
Subsystem
:
name
,
Name
:
"depth"
,
Name
:
"depth"
,
...
@@ -41,7 +41,7 @@ func (_ prometheusMetricsProvider) NewDepthMetric(name string) workqueue.GaugeMe
...
@@ -41,7 +41,7 @@ func (_ prometheusMetricsProvider) NewDepthMetric(name string) workqueue.GaugeMe
return
depth
return
depth
}
}
func
(
_
prometheusMetricsProvider
)
NewAddsMetric
(
name
string
)
workqueue
.
CounterMetric
{
func
(
prometheusMetricsProvider
)
NewAddsMetric
(
name
string
)
workqueue
.
CounterMetric
{
adds
:=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
adds
:=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Subsystem
:
name
,
Subsystem
:
name
,
Name
:
"adds"
,
Name
:
"adds"
,
...
@@ -51,7 +51,7 @@ func (_ prometheusMetricsProvider) NewAddsMetric(name string) workqueue.CounterM
...
@@ -51,7 +51,7 @@ func (_ prometheusMetricsProvider) NewAddsMetric(name string) workqueue.CounterM
return
adds
return
adds
}
}
func
(
_
prometheusMetricsProvider
)
NewLatencyMetric
(
name
string
)
workqueue
.
SummaryMetric
{
func
(
prometheusMetricsProvider
)
NewLatencyMetric
(
name
string
)
workqueue
.
SummaryMetric
{
latency
:=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
latency
:=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Subsystem
:
name
,
Subsystem
:
name
,
Name
:
"queue_latency"
,
Name
:
"queue_latency"
,
...
@@ -61,7 +61,7 @@ func (_ prometheusMetricsProvider) NewLatencyMetric(name string) workqueue.Summa
...
@@ -61,7 +61,7 @@ func (_ prometheusMetricsProvider) NewLatencyMetric(name string) workqueue.Summa
return
latency
return
latency
}
}
func
(
_
prometheusMetricsProvider
)
NewWorkDurationMetric
(
name
string
)
workqueue
.
SummaryMetric
{
func
(
prometheusMetricsProvider
)
NewWorkDurationMetric
(
name
string
)
workqueue
.
SummaryMetric
{
workDuration
:=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
workDuration
:=
prometheus
.
NewSummary
(
prometheus
.
SummaryOpts
{
Subsystem
:
name
,
Subsystem
:
name
,
Name
:
"work_duration"
,
Name
:
"work_duration"
,
...
@@ -71,7 +71,7 @@ func (_ prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.
...
@@ -71,7 +71,7 @@ func (_ prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.
return
workDuration
return
workDuration
}
}
func
(
_
prometheusMetricsProvider
)
NewRetriesMetric
(
name
string
)
workqueue
.
CounterMetric
{
func
(
prometheusMetricsProvider
)
NewRetriesMetric
(
name
string
)
workqueue
.
CounterMetric
{
retries
:=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
retries
:=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Subsystem
:
name
,
Subsystem
:
name
,
Name
:
"retries"
,
Name
:
"retries"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment