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
bd7b7199
Commit
bd7b7199
authored
Apr 15, 2015
by
Dan Mace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make default impls private
parent
312ccad3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
30 deletions
+38
-30
rollingupdate.go
pkg/kubectl/cmd/rollingupdate.go
+1
-1
factory.go
pkg/kubectl/cmd/util/factory.go
+1
-1
resize.go
pkg/kubectl/resize.go
+13
-9
resize_test.go
pkg/kubectl/resize_test.go
+3
-3
rolling_updater.go
pkg/kubectl/rolling_updater.go
+17
-13
rolling_updater_test.go
pkg/kubectl/rolling_updater_test.go
+2
-2
stop.go
pkg/kubectl/stop.go
+1
-1
No files found.
pkg/kubectl/cmd/rollingupdate.go
View file @
bd7b7199
...
...
@@ -111,7 +111,7 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
return
err
}
updater
:=
kubectl
.
NewRollingUpdater
(
newRc
.
Namespace
,
&
kubectl
.
RealRollingUpdaterClient
{
client
}
)
updater
:=
kubectl
.
NewRollingUpdater
(
newRc
.
Namespace
,
kubectl
.
NewRollingUpdaterClient
(
client
)
)
// fetch rc
oldRc
,
err
:=
client
.
ReplicationControllers
(
newRc
.
Namespace
)
.
Get
(
oldName
)
...
...
pkg/kubectl/cmd/util/factory.go
View file @
bd7b7199
...
...
@@ -197,7 +197,7 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
if
err
!=
nil
{
return
nil
,
err
}
return
kubectl
.
ResizerFor
(
mapping
.
Kind
,
&
kubectl
.
RealResizerClient
{
client
}
)
return
kubectl
.
ResizerFor
(
mapping
.
Kind
,
kubectl
.
NewResizerClient
(
client
)
)
},
Reaper
:
func
(
mapping
*
meta
.
RESTMapping
)
(
kubectl
.
Reaper
,
error
)
{
client
,
err
:=
clients
.
ClientForVersion
(
mapping
.
APIVersion
)
...
...
pkg/kubectl/resize.go
View file @
bd7b7199
...
...
@@ -172,19 +172,23 @@ type ResizerClient interface {
ControllerHasDesiredReplicas
(
rc
*
api
.
ReplicationController
)
wait
.
ConditionFunc
}
// RealResizerClient is a ResizerClient which uses a Kube client.
type
RealResizerClient
struct
{
Client
client
.
Interface
func
NewResizerClient
(
c
client
.
Interface
)
ResizerClient
{
return
&
realResizerClient
{
c
}
}
func
(
c
*
RealResizerClient
)
GetReplicationController
(
namespace
,
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
Client
.
ReplicationControllers
(
namespace
)
.
Get
(
name
)
// realResizerClient is a ResizerClient which uses a Kube client.
type
realResizerClient
struct
{
client
client
.
Interface
}
func
(
c
*
RealResizerClient
)
UpdateReplicationController
(
namespace
string
,
rc
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
Client
.
ReplicationControllers
(
namespace
)
.
Update
(
rc
)
func
(
c
*
realResizerClient
)
GetReplicationController
(
namespace
,
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
client
.
ReplicationControllers
(
namespace
)
.
Get
(
name
)
}
func
(
c
*
RealResizerClient
)
ControllerHasDesiredReplicas
(
rc
*
api
.
ReplicationController
)
wait
.
ConditionFunc
{
return
client
.
ControllerHasDesiredReplicas
(
c
.
Client
,
rc
)
func
(
c
*
realResizerClient
)
UpdateReplicationController
(
namespace
string
,
rc
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
client
.
ReplicationControllers
(
namespace
)
.
Update
(
rc
)
}
func
(
c
*
realResizerClient
)
ControllerHasDesiredReplicas
(
rc
*
api
.
ReplicationController
)
wait
.
ConditionFunc
{
return
client
.
ControllerHasDesiredReplicas
(
c
.
client
,
rc
)
}
pkg/kubectl/resize_test.go
View file @
bd7b7199
...
...
@@ -43,7 +43,7 @@ func (c *ErrorReplicationControllerClient) ReplicationControllers(namespace stri
func
TestReplicationControllerResizeRetry
(
t
*
testing
.
T
)
{
fake
:=
&
ErrorReplicationControllerClient
{
Fake
:
testclient
.
Fake
{}}
resizer
:=
ReplicationControllerResizer
{
&
RealResizerClient
{
fake
}
}
resizer
:=
ReplicationControllerResizer
{
NewResizerClient
(
fake
)
}
preconditions
:=
ResizePrecondition
{
-
1
,
""
}
count
:=
uint
(
3
)
name
:=
"foo"
...
...
@@ -67,7 +67,7 @@ func TestReplicationControllerResizeRetry(t *testing.T) {
func
TestReplicationControllerResize
(
t
*
testing
.
T
)
{
fake
:=
&
testclient
.
Fake
{}
resizer
:=
ReplicationControllerResizer
{
&
RealResizerClient
{
fake
}
}
resizer
:=
ReplicationControllerResizer
{
NewResizerClient
(
fake
)
}
preconditions
:=
ResizePrecondition
{
-
1
,
""
}
count
:=
uint
(
3
)
name
:=
"foo"
...
...
@@ -90,7 +90,7 @@ func TestReplicationControllerResizeFailsPreconditions(t *testing.T) {
Replicas
:
10
,
},
})
resizer
:=
ReplicationControllerResizer
{
&
RealResizerClient
{
fake
}
}
resizer
:=
ReplicationControllerResizer
{
NewResizerClient
(
fake
)
}
preconditions
:=
ResizePrecondition
{
2
,
""
}
count
:=
uint
(
3
)
name
:=
"foo"
...
...
pkg/kubectl/rolling_updater.go
View file @
bd7b7199
...
...
@@ -207,27 +207,31 @@ type RollingUpdaterClient interface {
ControllerHasDesiredReplicas
(
rc
*
api
.
ReplicationController
)
wait
.
ConditionFunc
}
// RealRollingUpdaterClient is a RollingUpdaterClient which uses a Kube client.
type
RealRollingUpdaterClient
struct
{
Client
client
.
Interface
func
NewRollingUpdaterClient
(
c
client
.
Interface
)
RollingUpdaterClient
{
return
&
realRollingUpdaterClient
{
c
}
}
func
(
c
*
RealRollingUpdaterClient
)
GetReplicationController
(
namespace
,
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
Client
.
ReplicationControllers
(
namespace
)
.
Get
(
name
)
// realRollingUpdaterClient is a RollingUpdaterClient which uses a Kube client.
type
realRollingUpdaterClient
struct
{
client
client
.
Interface
}
func
(
c
*
RealRollingUpdaterClient
)
UpdateReplicationController
(
namespace
string
,
rc
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
Client
.
ReplicationControllers
(
namespace
)
.
Update
(
rc
)
func
(
c
*
realRollingUpdaterClient
)
GetReplicationController
(
namespace
,
name
string
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
client
.
ReplicationControllers
(
namespace
)
.
Get
(
name
)
}
func
(
c
*
RealRollingUpdaterClient
)
Cre
ateReplicationController
(
namespace
string
,
rc
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
Client
.
ReplicationControllers
(
namespace
)
.
Cre
ate
(
rc
)
func
(
c
*
realRollingUpdaterClient
)
Upd
ateReplicationController
(
namespace
string
,
rc
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
client
.
ReplicationControllers
(
namespace
)
.
Upd
ate
(
rc
)
}
func
(
c
*
RealRollingUpdaterClient
)
DeleteReplicationController
(
namespace
,
name
string
)
error
{
return
c
.
Client
.
ReplicationControllers
(
namespace
)
.
Delete
(
name
)
func
(
c
*
realRollingUpdaterClient
)
CreateReplicationController
(
namespace
string
,
rc
*
api
.
ReplicationController
)
(
*
api
.
ReplicationController
,
error
)
{
return
c
.
client
.
ReplicationControllers
(
namespace
)
.
Create
(
rc
)
}
func
(
c
*
RealRollingUpdaterClient
)
ControllerHasDesiredReplicas
(
rc
*
api
.
ReplicationController
)
wait
.
ConditionFunc
{
return
client
.
ControllerHasDesiredReplicas
(
c
.
Client
,
rc
)
func
(
c
*
realRollingUpdaterClient
)
DeleteReplicationController
(
namespace
,
name
string
)
error
{
return
c
.
client
.
ReplicationControllers
(
namespace
)
.
Delete
(
name
)
}
func
(
c
*
realRollingUpdaterClient
)
ControllerHasDesiredReplicas
(
rc
*
api
.
ReplicationController
)
wait
.
ConditionFunc
{
return
client
.
ControllerHasDesiredReplicas
(
c
.
client
,
rc
)
}
pkg/kubectl/rolling_updater_test.go
View file @
bd7b7199
...
...
@@ -253,7 +253,7 @@ Update succeeded. Deleting foo-v1
for
_
,
test
:=
range
tests
{
updater
:=
RollingUpdater
{
&
RealRollingUpdaterClient
{
fakeClientFor
(
"default"
,
test
.
responses
)}
,
NewRollingUpdaterClient
(
fakeClientFor
(
"default"
,
test
.
responses
))
,
"default"
,
}
var
buffer
bytes
.
Buffer
...
...
@@ -296,7 +296,7 @@ Update succeeded. Deleting foo-v1
{
newRc
(
3
,
3
),
nil
},
{
newRc
(
3
,
3
),
nil
},
}
updater
:=
RollingUpdater
{
&
RealRollingUpdaterClient
{
fakeClientFor
(
"default"
,
responses
)}
,
"default"
}
updater
:=
RollingUpdater
{
NewRollingUpdaterClient
(
fakeClientFor
(
"default"
,
responses
))
,
"default"
}
var
buffer
bytes
.
Buffer
if
err
:=
updater
.
Update
(
&
buffer
,
rc
,
rcExisting
,
0
,
time
.
Millisecond
,
time
.
Millisecond
);
err
!=
nil
{
...
...
pkg/kubectl/stop.go
View file @
bd7b7199
...
...
@@ -65,7 +65,7 @@ type objInterface interface {
func
(
reaper
*
ReplicationControllerReaper
)
Stop
(
namespace
,
name
string
)
(
string
,
error
)
{
rc
:=
reaper
.
ReplicationControllers
(
namespace
)
resizer
,
err
:=
ResizerFor
(
"ReplicationController"
,
&
RealResizerClient
{
*
reaper
}
)
resizer
,
err
:=
ResizerFor
(
"ReplicationController"
,
NewResizerClient
(
*
reaper
)
)
if
err
!=
nil
{
return
""
,
err
}
...
...
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