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
162e4983
Commit
162e4983
authored
Nov 21, 2014
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2527 from erictune/cleanup2
Remove unused return value. Make stuff private.
parents
29e8faef
7d3e00c6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
25 deletions
+22
-25
etcd.go
pkg/kubelet/config/etcd.go
+4
-5
file.go
pkg/kubelet/config/file.go
+5
-6
file_test.go
pkg/kubelet/config/file_test.go
+5
-5
http.go
pkg/kubelet/config/http.go
+5
-6
http_test.go
pkg/kubelet/config/http_test.go
+3
-3
No files found.
pkg/kubelet/config/etcd.go
View file @
162e4983
...
@@ -37,30 +37,29 @@ func EtcdKeyForHost(hostname string) string {
...
@@ -37,30 +37,29 @@ func EtcdKeyForHost(hostname string) string {
return
path
.
Join
(
"/"
,
"registry"
,
"nodes"
,
hostname
,
"boundpods"
)
return
path
.
Join
(
"/"
,
"registry"
,
"nodes"
,
hostname
,
"boundpods"
)
}
}
type
S
ourceEtcd
struct
{
type
s
ourceEtcd
struct
{
key
string
key
string
helper
tools
.
EtcdHelper
helper
tools
.
EtcdHelper
updates
chan
<-
interface
{}
updates
chan
<-
interface
{}
}
}
// NewSourceEtcd creates a config source that watches and pulls from a key in etcd
// NewSourceEtcd creates a config source that watches and pulls from a key in etcd
func
NewSourceEtcd
(
key
string
,
client
tools
.
EtcdClient
,
updates
chan
<-
interface
{})
*
SourceEtcd
{
func
NewSourceEtcd
(
key
string
,
client
tools
.
EtcdClient
,
updates
chan
<-
interface
{})
{
helper
:=
tools
.
EtcdHelper
{
helper
:=
tools
.
EtcdHelper
{
client
,
client
,
latest
.
Codec
,
latest
.
Codec
,
tools
.
RuntimeVersionAdapter
{
latest
.
ResourceVersioner
},
tools
.
RuntimeVersionAdapter
{
latest
.
ResourceVersioner
},
}
}
source
:=
&
S
ourceEtcd
{
source
:=
&
s
ourceEtcd
{
key
:
key
,
key
:
key
,
helper
:
helper
,
helper
:
helper
,
updates
:
updates
,
updates
:
updates
,
}
}
glog
.
V
(
1
)
.
Infof
(
"Watching etcd for %s"
,
key
)
glog
.
V
(
1
)
.
Infof
(
"Watching etcd for %s"
,
key
)
go
util
.
Forever
(
source
.
run
,
time
.
Second
)
go
util
.
Forever
(
source
.
run
,
time
.
Second
)
return
source
}
}
func
(
s
*
S
ourceEtcd
)
run
()
{
func
(
s
*
s
ourceEtcd
)
run
()
{
watching
:=
s
.
helper
.
Watch
(
s
.
key
,
0
)
watching
:=
s
.
helper
.
Watch
(
s
.
key
,
0
)
for
{
for
{
select
{
select
{
...
...
pkg/kubelet/config/file.go
View file @
162e4983
...
@@ -37,28 +37,27 @@ import (
...
@@ -37,28 +37,27 @@ import (
"gopkg.in/v1/yaml"
"gopkg.in/v1/yaml"
)
)
type
S
ourceFile
struct
{
type
s
ourceFile
struct
{
path
string
path
string
updates
chan
<-
interface
{}
updates
chan
<-
interface
{}
}
}
func
NewSourceFile
(
path
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
*
SourceFile
{
func
NewSourceFile
(
path
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
{
config
:=
&
S
ourceFile
{
config
:=
&
s
ourceFile
{
path
:
path
,
path
:
path
,
updates
:
updates
,
updates
:
updates
,
}
}
glog
.
V
(
1
)
.
Infof
(
"Watching path %q"
,
path
)
glog
.
V
(
1
)
.
Infof
(
"Watching path %q"
,
path
)
go
util
.
Forever
(
config
.
run
,
period
)
go
util
.
Forever
(
config
.
run
,
period
)
return
config
}
}
func
(
s
*
S
ourceFile
)
run
()
{
func
(
s
*
s
ourceFile
)
run
()
{
if
err
:=
s
.
extractFromPath
();
err
!=
nil
{
if
err
:=
s
.
extractFromPath
();
err
!=
nil
{
glog
.
Errorf
(
"Unable to read config path %q: %v"
,
s
.
path
,
err
)
glog
.
Errorf
(
"Unable to read config path %q: %v"
,
s
.
path
,
err
)
}
}
}
}
func
(
s
*
S
ourceFile
)
extractFromPath
()
error
{
func
(
s
*
s
ourceFile
)
extractFromPath
()
error
{
path
:=
s
.
path
path
:=
s
.
path
statInfo
,
err
:=
os
.
Stat
(
path
)
statInfo
,
err
:=
os
.
Stat
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/kubelet/config/file_test.go
View file @
162e4983
...
@@ -81,7 +81,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
...
@@ -81,7 +81,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
func
TestExtractFromNonExistentFile
(
t
*
testing
.
T
)
{
func
TestExtractFromNonExistentFile
(
t
*
testing
.
T
)
{
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
"/some/fake/file"
,
ch
}
c
:=
s
ourceFile
{
"/some/fake/file"
,
ch
}
err
:=
c
.
extractFromPath
()
err
:=
c
.
extractFromPath
()
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"Expected error"
)
t
.
Errorf
(
"Expected error"
)
...
@@ -143,7 +143,7 @@ func TestExtractFromBadDataFile(t *testing.T) {
...
@@ -143,7 +143,7 @@ func TestExtractFromBadDataFile(t *testing.T) {
defer
os
.
Remove
(
file
.
Name
())
defer
os
.
Remove
(
file
.
Name
())
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
file
.
Name
(),
ch
}
c
:=
s
ourceFile
{
file
.
Name
(),
ch
}
err
:=
c
.
extractFromPath
()
err
:=
c
.
extractFromPath
()
if
err
==
nil
{
if
err
==
nil
{
t
.
Fatalf
(
"Expected error"
)
t
.
Fatalf
(
"Expected error"
)
...
@@ -164,7 +164,7 @@ func TestExtractFromValidDataFile(t *testing.T) {
...
@@ -164,7 +164,7 @@ func TestExtractFromValidDataFile(t *testing.T) {
expectedPod
.
Name
=
simpleSubdomainSafeHash
(
file
.
Name
())
expectedPod
.
Name
=
simpleSubdomainSafeHash
(
file
.
Name
())
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
file
.
Name
(),
ch
}
c
:=
s
ourceFile
{
file
.
Name
(),
ch
}
err
=
c
.
extractFromPath
()
err
=
c
.
extractFromPath
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
...
@@ -184,7 +184,7 @@ func TestExtractFromEmptyDir(t *testing.T) {
...
@@ -184,7 +184,7 @@ func TestExtractFromEmptyDir(t *testing.T) {
defer
os
.
RemoveAll
(
dirName
)
defer
os
.
RemoveAll
(
dirName
)
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
dirName
,
ch
}
c
:=
s
ourceFile
{
dirName
,
ch
}
err
=
c
.
extractFromPath
()
err
=
c
.
extractFromPath
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
...
@@ -232,7 +232,7 @@ func TestExtractFromDir(t *testing.T) {
...
@@ -232,7 +232,7 @@ func TestExtractFromDir(t *testing.T) {
}
}
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
dirName
,
ch
}
c
:=
s
ourceFile
{
dirName
,
ch
}
err
=
c
.
extractFromPath
()
err
=
c
.
extractFromPath
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
...
...
pkg/kubelet/config/http.go
View file @
162e4983
...
@@ -33,30 +33,29 @@ import (
...
@@ -33,30 +33,29 @@ import (
"gopkg.in/v1/yaml"
"gopkg.in/v1/yaml"
)
)
type
S
ourceURL
struct
{
type
s
ourceURL
struct
{
url
string
url
string
updates
chan
<-
interface
{}
updates
chan
<-
interface
{}
data
[]
byte
data
[]
byte
}
}
func
NewSourceURL
(
url
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
*
SourceURL
{
func
NewSourceURL
(
url
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
{
config
:=
&
S
ourceURL
{
config
:=
&
s
ourceURL
{
url
:
url
,
url
:
url
,
updates
:
updates
,
updates
:
updates
,
data
:
nil
,
data
:
nil
,
}
}
glog
.
V
(
1
)
.
Infof
(
"Watching URL %s"
,
url
)
glog
.
V
(
1
)
.
Infof
(
"Watching URL %s"
,
url
)
go
util
.
Forever
(
config
.
run
,
period
)
go
util
.
Forever
(
config
.
run
,
period
)
return
config
}
}
func
(
s
*
S
ourceURL
)
run
()
{
func
(
s
*
s
ourceURL
)
run
()
{
if
err
:=
s
.
extractFromURL
();
err
!=
nil
{
if
err
:=
s
.
extractFromURL
();
err
!=
nil
{
glog
.
Errorf
(
"Failed to read URL: %v"
,
err
)
glog
.
Errorf
(
"Failed to read URL: %v"
,
err
)
}
}
}
}
func
(
s
*
S
ourceURL
)
extractFromURL
()
error
{
func
(
s
*
s
ourceURL
)
extractFromURL
()
error
{
resp
,
err
:=
http
.
Get
(
s
.
url
)
resp
,
err
:=
http
.
Get
(
s
.
url
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
pkg/kubelet/config/http_test.go
View file @
162e4983
...
@@ -41,7 +41,7 @@ func TestURLErrorNotExistNoUpdate(t *testing.T) {
...
@@ -41,7 +41,7 @@ func TestURLErrorNotExistNoUpdate(t *testing.T) {
func
TestExtractFromHttpBadness
(
t
*
testing
.
T
)
{
func
TestExtractFromHttpBadness
(
t
*
testing
.
T
)
{
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceURL
{
"http://localhost:49575/_not_found_"
,
ch
,
nil
}
c
:=
s
ourceURL
{
"http://localhost:49575/_not_found_"
,
ch
,
nil
}
if
err
:=
c
.
extractFromURL
();
err
==
nil
{
if
err
:=
c
.
extractFromURL
();
err
==
nil
{
t
.
Errorf
(
"Expected error"
)
t
.
Errorf
(
"Expected error"
)
}
}
...
@@ -107,7 +107,7 @@ func TestExtractInvalidManifest(t *testing.T) {
...
@@ -107,7 +107,7 @@ func TestExtractInvalidManifest(t *testing.T) {
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
defer
testServer
.
Close
()
defer
testServer
.
Close
()
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceURL
{
testServer
.
URL
,
ch
,
nil
}
c
:=
s
ourceURL
{
testServer
.
URL
,
ch
,
nil
}
if
err
:=
c
.
extractFromURL
();
err
==
nil
{
if
err
:=
c
.
extractFromURL
();
err
==
nil
{
t
.
Errorf
(
"%s: Expected error"
,
testCase
.
desc
)
t
.
Errorf
(
"%s: Expected error"
,
testCase
.
desc
)
}
}
...
@@ -184,7 +184,7 @@ func TestExtractFromHTTP(t *testing.T) {
...
@@ -184,7 +184,7 @@ func TestExtractFromHTTP(t *testing.T) {
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
defer
testServer
.
Close
()
defer
testServer
.
Close
()
ch
:=
make
(
chan
interface
{},
1
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceURL
{
testServer
.
URL
,
ch
,
nil
}
c
:=
s
ourceURL
{
testServer
.
URL
,
ch
,
nil
}
if
err
:=
c
.
extractFromURL
();
err
!=
nil
{
if
err
:=
c
.
extractFromURL
();
err
!=
nil
{
t
.
Errorf
(
"%s: Unexpected error: %v"
,
testCase
.
desc
,
err
)
t
.
Errorf
(
"%s: Unexpected error: %v"
,
testCase
.
desc
,
err
)
continue
continue
...
...
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