mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Make default impls private
This commit is contained in:
parent
312ccad3c1
commit
bd7b719944
@ -111,7 +111,7 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
updater := kubectl.NewRollingUpdater(newRc.Namespace, &kubectl.RealRollingUpdaterClient{client})
|
updater := kubectl.NewRollingUpdater(newRc.Namespace, kubectl.NewRollingUpdaterClient(client))
|
||||||
|
|
||||||
// fetch rc
|
// fetch rc
|
||||||
oldRc, err := client.ReplicationControllers(newRc.Namespace).Get(oldName)
|
oldRc, err := client.ReplicationControllers(newRc.Namespace).Get(oldName)
|
||||||
|
@ -197,7 +197,7 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
Reaper: func(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
|
||||||
client, err := clients.ClientForVersion(mapping.APIVersion)
|
client, err := clients.ClientForVersion(mapping.APIVersion)
|
||||||
|
@ -172,19 +172,23 @@ type ResizerClient interface {
|
|||||||
ControllerHasDesiredReplicas(rc *api.ReplicationController) wait.ConditionFunc
|
ControllerHasDesiredReplicas(rc *api.ReplicationController) wait.ConditionFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// RealResizerClient is a ResizerClient which uses a Kube client.
|
func NewResizerClient(c client.Interface) ResizerClient {
|
||||||
type RealResizerClient struct {
|
return &realResizerClient{c}
|
||||||
Client client.Interface
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RealResizerClient) GetReplicationController(namespace, name string) (*api.ReplicationController, error) {
|
// realResizerClient is a ResizerClient which uses a Kube client.
|
||||||
return c.Client.ReplicationControllers(namespace).Get(name)
|
type realResizerClient struct {
|
||||||
|
client client.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RealResizerClient) UpdateReplicationController(namespace string, rc *api.ReplicationController) (*api.ReplicationController, error) {
|
func (c *realResizerClient) GetReplicationController(namespace, name string) (*api.ReplicationController, error) {
|
||||||
return c.Client.ReplicationControllers(namespace).Update(rc)
|
return c.client.ReplicationControllers(namespace).Get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RealResizerClient) ControllerHasDesiredReplicas(rc *api.ReplicationController) wait.ConditionFunc {
|
func (c *realResizerClient) UpdateReplicationController(namespace string, rc *api.ReplicationController) (*api.ReplicationController, error) {
|
||||||
return client.ControllerHasDesiredReplicas(c.Client, rc)
|
return c.client.ReplicationControllers(namespace).Update(rc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *realResizerClient) ControllerHasDesiredReplicas(rc *api.ReplicationController) wait.ConditionFunc {
|
||||||
|
return client.ControllerHasDesiredReplicas(c.client, rc)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func (c *ErrorReplicationControllerClient) ReplicationControllers(namespace stri
|
|||||||
|
|
||||||
func TestReplicationControllerResizeRetry(t *testing.T) {
|
func TestReplicationControllerResizeRetry(t *testing.T) {
|
||||||
fake := &ErrorReplicationControllerClient{Fake: testclient.Fake{}}
|
fake := &ErrorReplicationControllerClient{Fake: testclient.Fake{}}
|
||||||
resizer := ReplicationControllerResizer{&RealResizerClient{fake}}
|
resizer := ReplicationControllerResizer{NewResizerClient(fake)}
|
||||||
preconditions := ResizePrecondition{-1, ""}
|
preconditions := ResizePrecondition{-1, ""}
|
||||||
count := uint(3)
|
count := uint(3)
|
||||||
name := "foo"
|
name := "foo"
|
||||||
@ -67,7 +67,7 @@ func TestReplicationControllerResizeRetry(t *testing.T) {
|
|||||||
|
|
||||||
func TestReplicationControllerResize(t *testing.T) {
|
func TestReplicationControllerResize(t *testing.T) {
|
||||||
fake := &testclient.Fake{}
|
fake := &testclient.Fake{}
|
||||||
resizer := ReplicationControllerResizer{&RealResizerClient{fake}}
|
resizer := ReplicationControllerResizer{NewResizerClient(fake)}
|
||||||
preconditions := ResizePrecondition{-1, ""}
|
preconditions := ResizePrecondition{-1, ""}
|
||||||
count := uint(3)
|
count := uint(3)
|
||||||
name := "foo"
|
name := "foo"
|
||||||
@ -90,7 +90,7 @@ func TestReplicationControllerResizeFailsPreconditions(t *testing.T) {
|
|||||||
Replicas: 10,
|
Replicas: 10,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
resizer := ReplicationControllerResizer{&RealResizerClient{fake}}
|
resizer := ReplicationControllerResizer{NewResizerClient(fake)}
|
||||||
preconditions := ResizePrecondition{2, ""}
|
preconditions := ResizePrecondition{2, ""}
|
||||||
count := uint(3)
|
count := uint(3)
|
||||||
name := "foo"
|
name := "foo"
|
||||||
|
@ -207,27 +207,31 @@ type RollingUpdaterClient interface {
|
|||||||
ControllerHasDesiredReplicas(rc *api.ReplicationController) wait.ConditionFunc
|
ControllerHasDesiredReplicas(rc *api.ReplicationController) wait.ConditionFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// RealRollingUpdaterClient is a RollingUpdaterClient which uses a Kube client.
|
func NewRollingUpdaterClient(c client.Interface) RollingUpdaterClient {
|
||||||
type RealRollingUpdaterClient struct {
|
return &realRollingUpdaterClient{c}
|
||||||
Client client.Interface
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RealRollingUpdaterClient) GetReplicationController(namespace, name string) (*api.ReplicationController, error) {
|
// realRollingUpdaterClient is a RollingUpdaterClient which uses a Kube client.
|
||||||
return c.Client.ReplicationControllers(namespace).Get(name)
|
type realRollingUpdaterClient struct {
|
||||||
|
client client.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RealRollingUpdaterClient) UpdateReplicationController(namespace string, rc *api.ReplicationController) (*api.ReplicationController, error) {
|
func (c *realRollingUpdaterClient) GetReplicationController(namespace, name string) (*api.ReplicationController, error) {
|
||||||
return c.Client.ReplicationControllers(namespace).Update(rc)
|
return c.client.ReplicationControllers(namespace).Get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RealRollingUpdaterClient) CreateReplicationController(namespace string, rc *api.ReplicationController) (*api.ReplicationController, error) {
|
func (c *realRollingUpdaterClient) UpdateReplicationController(namespace string, rc *api.ReplicationController) (*api.ReplicationController, error) {
|
||||||
return c.Client.ReplicationControllers(namespace).Create(rc)
|
return c.client.ReplicationControllers(namespace).Update(rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RealRollingUpdaterClient) DeleteReplicationController(namespace, name string) error {
|
func (c *realRollingUpdaterClient) CreateReplicationController(namespace string, rc *api.ReplicationController) (*api.ReplicationController, error) {
|
||||||
return c.Client.ReplicationControllers(namespace).Delete(name)
|
return c.client.ReplicationControllers(namespace).Create(rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RealRollingUpdaterClient) ControllerHasDesiredReplicas(rc *api.ReplicationController) wait.ConditionFunc {
|
func (c *realRollingUpdaterClient) DeleteReplicationController(namespace, name string) error {
|
||||||
return client.ControllerHasDesiredReplicas(c.Client, rc)
|
return c.client.ReplicationControllers(namespace).Delete(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *realRollingUpdaterClient) ControllerHasDesiredReplicas(rc *api.ReplicationController) wait.ConditionFunc {
|
||||||
|
return client.ControllerHasDesiredReplicas(c.client, rc)
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ Update succeeded. Deleting foo-v1
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
updater := RollingUpdater{
|
updater := RollingUpdater{
|
||||||
&RealRollingUpdaterClient{fakeClientFor("default", test.responses)},
|
NewRollingUpdaterClient(fakeClientFor("default", test.responses)),
|
||||||
"default",
|
"default",
|
||||||
}
|
}
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
@ -296,7 +296,7 @@ Update succeeded. Deleting foo-v1
|
|||||||
{newRc(3, 3), nil},
|
{newRc(3, 3), nil},
|
||||||
{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
|
var buffer bytes.Buffer
|
||||||
if err := updater.Update(&buffer, rc, rcExisting, 0, time.Millisecond, time.Millisecond); err != nil {
|
if err := updater.Update(&buffer, rc, rcExisting, 0, time.Millisecond, time.Millisecond); err != nil {
|
||||||
|
@ -65,7 +65,7 @@ type objInterface interface {
|
|||||||
|
|
||||||
func (reaper *ReplicationControllerReaper) Stop(namespace, name string) (string, error) {
|
func (reaper *ReplicationControllerReaper) Stop(namespace, name string) (string, error) {
|
||||||
rc := reaper.ReplicationControllers(namespace)
|
rc := reaper.ReplicationControllers(namespace)
|
||||||
resizer, err := ResizerFor("ReplicationController", &RealResizerClient{*reaper})
|
resizer, err := ResizerFor("ReplicationController", NewResizerClient(*reaper))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user