mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #125 from brendandburns/dot
Remove dot import syntax from cloudcfg.
This commit is contained in:
commit
a089096468
@ -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
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cloudcfg
|
||||
|
||||
import (
|
||||
@ -22,7 +23,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
. "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||
)
|
||||
@ -41,18 +42,18 @@ type Action struct {
|
||||
|
||||
type FakeKubeClient struct {
|
||||
actions []Action
|
||||
pods PodList
|
||||
ctrl ReplicationController
|
||||
pods api.PodList
|
||||
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"})
|
||||
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})
|
||||
return Pod{}, nil
|
||||
return api.Pod{}, nil
|
||||
}
|
||||
|
||||
func (client *FakeKubeClient) DeletePod(name string) error {
|
||||
@ -60,29 +61,29 @@ func (client *FakeKubeClient) DeletePod(name string) error {
|
||||
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"})
|
||||
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})
|
||||
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})
|
||||
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})
|
||||
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})
|
||||
return ReplicationController{}, nil
|
||||
return api.ReplicationController{}, nil
|
||||
}
|
||||
|
||||
func (client *FakeKubeClient) DeleteReplicationController(controller string) error {
|
||||
@ -90,19 +91,19 @@ func (client *FakeKubeClient) DeleteReplicationController(controller string) err
|
||||
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})
|
||||
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})
|
||||
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})
|
||||
return Service{}, nil
|
||||
return api.Service{}, nil
|
||||
}
|
||||
|
||||
func (client *FakeKubeClient) DeleteService(controller string) error {
|
||||
@ -118,10 +119,10 @@ func validateAction(expectedAction, actualAction Action, t *testing.T) {
|
||||
|
||||
func TestUpdateWithPods(t *testing.T) {
|
||||
client := FakeKubeClient{
|
||||
pods: PodList{
|
||||
Items: []Pod{
|
||||
{JSONBase: JSONBase{ID: "pod-1"}},
|
||||
{JSONBase: JSONBase{ID: "pod-2"}},
|
||||
pods: api.PodList{
|
||||
Items: []api.Pod{
|
||||
{JSONBase: api.JSONBase{ID: "pod-1"}},
|
||||
{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" {
|
||||
t.Errorf("Unexpected actions: %#v", fakeClient.actions)
|
||||
}
|
||||
controller := fakeClient.actions[0].value.(ReplicationController)
|
||||
controller := fakeClient.actions[0].value.(api.ReplicationController)
|
||||
if controller.ID != name ||
|
||||
controller.DesiredState.Replicas != replicas ||
|
||||
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image {
|
||||
@ -196,7 +197,7 @@ func TestRunControllerWithService(t *testing.T) {
|
||||
fakeClient.actions[1].action != "create-service" {
|
||||
t.Errorf("Unexpected actions: %#v", fakeClient.actions)
|
||||
}
|
||||
controller := fakeClient.actions[0].value.(ReplicationController)
|
||||
controller := fakeClient.actions[0].value.(api.ReplicationController)
|
||||
if controller.ID != name ||
|
||||
controller.DesiredState.Replicas != replicas ||
|
||||
controller.DesiredState.PodTemplate.DesiredState.Manifest.Containers[0].Image != image {
|
||||
@ -215,7 +216,7 @@ func TestStopController(t *testing.T) {
|
||||
fakeClient.actions[0].value.(string) != name {
|
||||
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" ||
|
||||
controller.DesiredState.Replicas != 0 {
|
||||
t.Errorf("Unexpected action: %#v", fakeClient.actions[1])
|
||||
@ -234,7 +235,7 @@ func TestResizeController(t *testing.T) {
|
||||
fakeClient.actions[0].value.(string) != name {
|
||||
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" ||
|
||||
controller.DesiredState.Replicas != 17 {
|
||||
t.Errorf("Unexpected action: %#v", fakeClient.actions[1])
|
||||
@ -261,8 +262,8 @@ func TestCloudCfgDeleteController(t *testing.T) {
|
||||
|
||||
func TestCloudCfgDeleteControllerWithReplicas(t *testing.T) {
|
||||
fakeClient := FakeKubeClient{
|
||||
ctrl: ReplicationController{
|
||||
DesiredState: ReplicationControllerState{
|
||||
ctrl: api.ReplicationController{
|
||||
DesiredState: api.ReplicationControllerState{
|
||||
Replicas: 2,
|
||||
},
|
||||
},
|
||||
@ -294,7 +295,7 @@ func TestRequestWithBodyNoSuchFile(t *testing.T) {
|
||||
func TestRequestWithBody(t *testing.T) {
|
||||
file, err := ioutil.TempFile("", "foo")
|
||||
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)
|
||||
_, err = file.Write(data)
|
||||
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 {
|
||||
t.Errorf("Unexpected port: %#v != (%d, %d)", p, external, internal)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user