mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-16 22:53:22 +00:00
Remaining refactor for PodTemplateSpec and fixing test cases
This commit is contained in:
@@ -134,14 +134,14 @@ func Update(ctx api.Context, name string, client client.Interface, updatePeriod
|
||||
}
|
||||
|
||||
if len(imageName) != 0 {
|
||||
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image = imageName
|
||||
controller.Spec.Template.Spec.Containers[0].Image = imageName
|
||||
controller, err = client.ReplicationControllers(controller.Namespace).Update(controller)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
s := labels.Set(controller.DesiredState.ReplicaSelector).AsSelector()
|
||||
s := labels.Set(controller.Spec.Selector).AsSelector()
|
||||
|
||||
podList, err := client.Pods(api.Namespace(ctx)).List(s)
|
||||
if err != nil {
|
||||
@@ -181,7 +181,7 @@ func ResizeController(ctx api.Context, name string, replicas int, client client.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
controller.DesiredState.Replicas = replicas
|
||||
controller.Spec.Replicas = replicas
|
||||
controllerOut, err := client.ReplicationControllers(api.Namespace(ctx)).Update(controller)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -251,26 +251,25 @@ func RunController(ctx api.Context, image, name string, replicas int, client cli
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
},
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Spec: api.ReplicationControllerSpec{
|
||||
Replicas: replicas,
|
||||
ReplicaSelector: map[string]string{
|
||||
Selector: map[string]string{
|
||||
"name": name,
|
||||
},
|
||||
PodTemplate: api.PodTemplate{
|
||||
DesiredState: api.PodState{
|
||||
Manifest: api.ContainerManifest{
|
||||
Version: "v1beta2",
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: strings.ToLower(name),
|
||||
Image: image,
|
||||
Ports: ports,
|
||||
},
|
||||
},
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"name": name,
|
||||
},
|
||||
},
|
||||
Labels: map[string]string{
|
||||
"name": name,
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: strings.ToLower(name),
|
||||
Image: image,
|
||||
Ports: ports,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -328,8 +327,8 @@ func DeleteController(ctx api.Context, name string, client client.Interface) err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if controller.DesiredState.Replicas != 0 {
|
||||
return fmt.Errorf("controller has non-zero replicas (%d), please stop it first", controller.DesiredState.Replicas)
|
||||
if controller.Spec.Replicas != 0 {
|
||||
return fmt.Errorf("controller has non-zero replicas (%d), please stop it first", controller.Spec.Replicas)
|
||||
}
|
||||
return client.ReplicationControllers(api.Namespace(ctx)).Delete(name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user