mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Remove dot syntax.
This commit is contained in:
parent
7e9c3138b6
commit
b8eaa8634e
@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cloudcfg
|
package cloudcfg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -22,7 +23,7 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
)
|
)
|
||||||
@ -41,18 +42,18 @@ type Action struct {
|
|||||||
|
|
||||||
type FakeKubeClient struct {
|
type FakeKubeClient struct {
|
||||||
actions []Action
|
actions []Action
|
||||||
pods PodList
|
pods api.PodList
|
||||||
ctrl ReplicationController
|
ctrl api.ReplicationController
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) ListPods(labelQuery map[string]string) (PodList, error) {
|
func (client *FakeKubeClient) ListPods(labelQuery map[string]string) (api.PodList, error) {
|
||||||
client.actions = append(client.actions, Action{action: "list-pods"})
|
client.actions = append(client.actions, Action{action: "list-pods"})
|
||||||
return client.pods, nil
|
return client.pods, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) GetPod(name string) (Pod, error) {
|
func (client *FakeKubeClient) GetPod(name string) (api.Pod, error) {
|
||||||
client.actions = append(client.actions, Action{action: "get-pod", value: name})
|
client.actions = append(client.actions, Action{action: "get-pod", value: name})
|
||||||
return Pod{}, nil
|
return api.Pod{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) DeletePod(name string) error {
|
func (client *FakeKubeClient) DeletePod(name string) error {
|
||||||
@ -60,29 +61,29 @@ func (client *FakeKubeClient) DeletePod(name string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) CreatePod(pod Pod) (Pod, error) {
|
func (client *FakeKubeClient) CreatePod(pod api.Pod) (api.Pod, error) {
|
||||||
client.actions = append(client.actions, Action{action: "create-pod"})
|
client.actions = append(client.actions, Action{action: "create-pod"})
|
||||||
return Pod{}, nil
|
return api.Pod{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) UpdatePod(pod Pod) (Pod, error) {
|
func (client *FakeKubeClient) UpdatePod(pod api.Pod) (api.Pod, error) {
|
||||||
client.actions = append(client.actions, Action{action: "update-pod", value: pod.ID})
|
client.actions = append(client.actions, Action{action: "update-pod", value: pod.ID})
|
||||||
return Pod{}, nil
|
return api.Pod{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) GetReplicationController(name string) (ReplicationController, error) {
|
func (client *FakeKubeClient) GetReplicationController(name string) (api.ReplicationController, error) {
|
||||||
client.actions = append(client.actions, Action{action: "get-controller", value: name})
|
client.actions = append(client.actions, Action{action: "get-controller", value: name})
|
||||||
return client.ctrl, nil
|
return client.ctrl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) CreateReplicationController(controller ReplicationController) (ReplicationController, error) {
|
func (client *FakeKubeClient) CreateReplicationController(controller api.ReplicationController) (api.ReplicationController, error) {
|
||||||
client.actions = append(client.actions, Action{action: "create-controller", value: controller})
|
client.actions = append(client.actions, Action{action: "create-controller", value: controller})
|
||||||
return ReplicationController{}, nil
|
return api.ReplicationController{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) UpdateReplicationController(controller ReplicationController) (ReplicationController, error) {
|
func (client *FakeKubeClient) UpdateReplicationController(controller api.ReplicationController) (api.ReplicationController, error) {
|
||||||
client.actions = append(client.actions, Action{action: "update-controller", value: controller})
|
client.actions = append(client.actions, Action{action: "update-controller", value: controller})
|
||||||
return ReplicationController{}, nil
|
return api.ReplicationController{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) DeleteReplicationController(controller string) error {
|
func (client *FakeKubeClient) DeleteReplicationController(controller string) error {
|
||||||
@ -90,19 +91,19 @@ func (client *FakeKubeClient) DeleteReplicationController(controller string) err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) GetService(name string) (Service, error) {
|
func (client *FakeKubeClient) GetService(name string) (api.Service, error) {
|
||||||
client.actions = append(client.actions, Action{action: "get-controller", value: name})
|
client.actions = append(client.actions, Action{action: "get-controller", value: name})
|
||||||
return Service{}, nil
|
return api.Service{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) CreateService(controller Service) (Service, error) {
|
func (client *FakeKubeClient) CreateService(controller api.Service) (api.Service, error) {
|
||||||
client.actions = append(client.actions, Action{action: "create-service", value: controller})
|
client.actions = append(client.actions, Action{action: "create-service", value: controller})
|
||||||
return Service{}, nil
|
return api.Service{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) UpdateService(controller Service) (Service, error) {
|
func (client *FakeKubeClient) UpdateService(controller api.Service) (api.Service, error) {
|
||||||
client.actions = append(client.actions, Action{action: "update-service", value: controller})
|
client.actions = append(client.actions, Action{action: "update-service", value: controller})
|
||||||
return Service{}, nil
|
return api.Service{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *FakeKubeClient) DeleteService(controller string) error {
|
func (client *FakeKubeClient) DeleteService(controller string) error {
|
||||||
@ -118,10 +119,10 @@ func validateAction(expectedAction, actualAction Action, t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdateWithPods(t *testing.T) {
|
func TestUpdateWithPods(t *testing.T) {
|
||||||
client := FakeKubeClient{
|
client := FakeKubeClient{
|
||||||
pods: PodList{
|
pods: api.PodList{
|
||||||
Items: []Pod{
|
Items: []api.Pod{
|
||||||
{JSONBase: JSONBase{ID: "pod-1"}},
|
{JSONBase: api.JSONBase{ID: "pod-1"}},
|
||||||
{JSONBase: JSONBase{ID: "pod-2"}},
|
{JSONBase: api.JSONBase{ID: "pod-2"}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -177,7 +178,7 @@ func TestRunController(t *testing.T) {
|
|||||||
if len(fakeClient.actions) != 1 || fakeClient.actions[0].action != "create-controller" {
|
if len(fakeClient.actions) != 1 || fakeClient.actions[0].action != "create-controller" {
|
||||||
t.Errorf("Unexpected actions: %#v", fakeClient.actions)
|
t.Errorf("Unexpected actions: %#v", fakeClient.actions)
|
||||||
}
|
}
|
||||||
controller := fakeClient.actions[0].value.(ReplicationController)
|
controller := fakeClient.actions[0].value.(api.ReplicationController)
|
||||||
if controller.ID != name ||
|
if controller.ID != name ||
|
||||||
controller.DesiredState.Replicas != replicas ||
|
controller.DesiredState.Replicas != replicas ||
|
||||||
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image {
|
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image {
|
||||||
@ -196,7 +197,7 @@ func TestRunControllerWithService(t *testing.T) {
|
|||||||
fakeClient.actions[1].action != "create-service" {
|
fakeClient.actions[1].action != "create-service" {
|
||||||
t.Errorf("Unexpected actions: %#v", fakeClient.actions)
|
t.Errorf("Unexpected actions: %#v", fakeClient.actions)
|
||||||
}
|
}
|
||||||
controller := fakeClient.actions[0].value.(ReplicationController)
|
controller := fakeClient.actions[0].value.(api.ReplicationController)
|
||||||
if controller.ID != name ||
|
if controller.ID != name ||
|
||||||
controller.DesiredState.Replicas != replicas ||
|
controller.DesiredState.Replicas != replicas ||
|
||||||
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image {
|
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image {
|
||||||
@ -215,7 +216,7 @@ func TestStopController(t *testing.T) {
|
|||||||
fakeClient.actions[0].value.(string) != name {
|
fakeClient.actions[0].value.(string) != name {
|
||||||
t.Errorf("Unexpected action: %#v", fakeClient.actions[0])
|
t.Errorf("Unexpected action: %#v", fakeClient.actions[0])
|
||||||
}
|
}
|
||||||
controller := fakeClient.actions[1].value.(ReplicationController)
|
controller := fakeClient.actions[1].value.(api.ReplicationController)
|
||||||
if fakeClient.actions[1].action != "update-controller" ||
|
if fakeClient.actions[1].action != "update-controller" ||
|
||||||
controller.DesiredState.Replicas != 0 {
|
controller.DesiredState.Replicas != 0 {
|
||||||
t.Errorf("Unexpected action: %#v", fakeClient.actions[1])
|
t.Errorf("Unexpected action: %#v", fakeClient.actions[1])
|
||||||
@ -234,7 +235,7 @@ func TestResizeController(t *testing.T) {
|
|||||||
fakeClient.actions[0].value.(string) != name {
|
fakeClient.actions[0].value.(string) != name {
|
||||||
t.Errorf("Unexpected action: %#v", fakeClient.actions[0])
|
t.Errorf("Unexpected action: %#v", fakeClient.actions[0])
|
||||||
}
|
}
|
||||||
controller := fakeClient.actions[1].value.(ReplicationController)
|
controller := fakeClient.actions[1].value.(api.ReplicationController)
|
||||||
if fakeClient.actions[1].action != "update-controller" ||
|
if fakeClient.actions[1].action != "update-controller" ||
|
||||||
controller.DesiredState.Replicas != 17 {
|
controller.DesiredState.Replicas != 17 {
|
||||||
t.Errorf("Unexpected action: %#v", fakeClient.actions[1])
|
t.Errorf("Unexpected action: %#v", fakeClient.actions[1])
|
||||||
@ -261,8 +262,8 @@ func TestCloudCfgDeleteController(t *testing.T) {
|
|||||||
|
|
||||||
func TestCloudCfgDeleteControllerWithReplicas(t *testing.T) {
|
func TestCloudCfgDeleteControllerWithReplicas(t *testing.T) {
|
||||||
fakeClient := FakeKubeClient{
|
fakeClient := FakeKubeClient{
|
||||||
ctrl: ReplicationController{
|
ctrl: api.ReplicationController{
|
||||||
DesiredState: ReplicationControllerState{
|
DesiredState: api.ReplicationControllerState{
|
||||||
Replicas: 2,
|
Replicas: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -294,7 +295,7 @@ func TestRequestWithBodyNoSuchFile(t *testing.T) {
|
|||||||
func TestRequestWithBody(t *testing.T) {
|
func TestRequestWithBody(t *testing.T) {
|
||||||
file, err := ioutil.TempFile("", "foo")
|
file, err := ioutil.TempFile("", "foo")
|
||||||
expectNoError(t, err)
|
expectNoError(t, err)
|
||||||
data, err := json.Marshal(Pod{JSONBase: JSONBase{ID: "foo"}})
|
data, err := json.Marshal(api.Pod{JSONBase: api.JSONBase{ID: "foo"}})
|
||||||
expectNoError(t, err)
|
expectNoError(t, err)
|
||||||
_, err = file.Write(data)
|
_, err = file.Write(data)
|
||||||
expectNoError(t, err)
|
expectNoError(t, err)
|
||||||
@ -312,7 +313,7 @@ func TestRequestWithBody(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func validatePort(t *testing.T, p Port, external int, internal int) {
|
func validatePort(t *testing.T, p api.Port, external int, internal int) {
|
||||||
if p.HostPort != external || p.ContainerPort != internal {
|
if p.HostPort != external || p.ContainerPort != internal {
|
||||||
t.Errorf("Unexpected port: %#v != (%d, %d)", p, external, internal)
|
t.Errorf("Unexpected port: %#v != (%d, %d)", p, external, internal)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user