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 {
return
path
.
Join
(
"/"
,
"registry"
,
"nodes"
,
hostname
,
"boundpods"
)
}
type
S
ourceEtcd
struct
{
type
s
ourceEtcd
struct
{
key
string
helper
tools
.
EtcdHelper
updates
chan
<-
interface
{}
}
// 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
{
client
,
latest
.
Codec
,
tools
.
RuntimeVersionAdapter
{
latest
.
ResourceVersioner
},
}
source
:=
&
S
ourceEtcd
{
source
:=
&
s
ourceEtcd
{
key
:
key
,
helper
:
helper
,
updates
:
updates
,
}
glog
.
V
(
1
)
.
Infof
(
"Watching etcd for %s"
,
key
)
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
)
for
{
select
{
...
...
pkg/kubelet/config/file.go
View file @
162e4983
...
...
@@ -37,28 +37,27 @@ import (
"gopkg.in/v1/yaml"
)
type
S
ourceFile
struct
{
type
s
ourceFile
struct
{
path
string
updates
chan
<-
interface
{}
}
func
NewSourceFile
(
path
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
*
SourceFile
{
config
:=
&
S
ourceFile
{
func
NewSourceFile
(
path
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
{
config
:=
&
s
ourceFile
{
path
:
path
,
updates
:
updates
,
}
glog
.
V
(
1
)
.
Infof
(
"Watching path %q"
,
path
)
go
util
.
Forever
(
config
.
run
,
period
)
return
config
}
func
(
s
*
S
ourceFile
)
run
()
{
func
(
s
*
s
ourceFile
)
run
()
{
if
err
:=
s
.
extractFromPath
();
err
!=
nil
{
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
statInfo
,
err
:=
os
.
Stat
(
path
)
if
err
!=
nil
{
...
...
pkg/kubelet/config/file_test.go
View file @
162e4983
...
...
@@ -81,7 +81,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
func
TestExtractFromNonExistentFile
(
t
*
testing
.
T
)
{
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
"/some/fake/file"
,
ch
}
c
:=
s
ourceFile
{
"/some/fake/file"
,
ch
}
err
:=
c
.
extractFromPath
()
if
err
==
nil
{
t
.
Errorf
(
"Expected error"
)
...
...
@@ -143,7 +143,7 @@ func TestExtractFromBadDataFile(t *testing.T) {
defer
os
.
Remove
(
file
.
Name
())
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
file
.
Name
(),
ch
}
c
:=
s
ourceFile
{
file
.
Name
(),
ch
}
err
:=
c
.
extractFromPath
()
if
err
==
nil
{
t
.
Fatalf
(
"Expected error"
)
...
...
@@ -164,7 +164,7 @@ func TestExtractFromValidDataFile(t *testing.T) {
expectedPod
.
Name
=
simpleSubdomainSafeHash
(
file
.
Name
())
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
file
.
Name
(),
ch
}
c
:=
s
ourceFile
{
file
.
Name
(),
ch
}
err
=
c
.
extractFromPath
()
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
...
...
@@ -184,7 +184,7 @@ func TestExtractFromEmptyDir(t *testing.T) {
defer
os
.
RemoveAll
(
dirName
)
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
dirName
,
ch
}
c
:=
s
ourceFile
{
dirName
,
ch
}
err
=
c
.
extractFromPath
()
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
...
...
@@ -232,7 +232,7 @@ func TestExtractFromDir(t *testing.T) {
}
ch
:=
make
(
chan
interface
{},
1
)
c
:=
S
ourceFile
{
dirName
,
ch
}
c
:=
s
ourceFile
{
dirName
,
ch
}
err
=
c
.
extractFromPath
()
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error: %v"
,
err
)
...
...
pkg/kubelet/config/http.go
View file @
162e4983
...
...
@@ -33,30 +33,29 @@ import (
"gopkg.in/v1/yaml"
)
type
S
ourceURL
struct
{
type
s
ourceURL
struct
{
url
string
updates
chan
<-
interface
{}
data
[]
byte
}
func
NewSourceURL
(
url
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
*
SourceURL
{
config
:=
&
S
ourceURL
{
func
NewSourceURL
(
url
string
,
period
time
.
Duration
,
updates
chan
<-
interface
{})
{
config
:=
&
s
ourceURL
{
url
:
url
,
updates
:
updates
,
data
:
nil
,
}
glog
.
V
(
1
)
.
Infof
(
"Watching URL %s"
,
url
)
go
util
.
Forever
(
config
.
run
,
period
)
return
config
}
func
(
s
*
S
ourceURL
)
run
()
{
func
(
s
*
s
ourceURL
)
run
()
{
if
err
:=
s
.
extractFromURL
();
err
!=
nil
{
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
)
if
err
!=
nil
{
return
err
...
...
pkg/kubelet/config/http_test.go
View file @
162e4983
...
...
@@ -41,7 +41,7 @@ func TestURLErrorNotExistNoUpdate(t *testing.T) {
func
TestExtractFromHttpBadness
(
t
*
testing
.
T
)
{
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
{
t
.
Errorf
(
"Expected error"
)
}
...
...
@@ -107,7 +107,7 @@ func TestExtractInvalidManifest(t *testing.T) {
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
defer
testServer
.
Close
()
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
{
t
.
Errorf
(
"%s: Expected error"
,
testCase
.
desc
)
}
...
...
@@ -184,7 +184,7 @@ func TestExtractFromHTTP(t *testing.T) {
testServer
:=
httptest
.
NewServer
(
&
fakeHandler
)
defer
testServer
.
Close
()
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
{
t
.
Errorf
(
"%s: Unexpected error: %v"
,
testCase
.
desc
,
err
)
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