| ... | ... |
@@ -13,22 +13,22 @@ import ( |
| 13 | 13 |
|
| 14 | 14 |
type okOsClient struct{}
|
| 15 | 15 |
|
| 16 |
-func (_ *okOsClient) ListBuilds(selector labels.Selector) (api.BuildList, error) {
|
|
| 17 |
- return api.BuildList{}, nil
|
|
| 16 |
+func (_ *okOsClient) ListBuilds(selector labels.Selector) (*api.BuildList, error) {
|
|
| 17 |
+ return &api.BuildList{}, nil
|
|
| 18 | 18 |
} |
| 19 | 19 |
|
| 20 |
-func (_ *okOsClient) UpdateBuild(api.Build) (api.Build, error) {
|
|
| 21 |
- return api.Build{}, nil
|
|
| 20 |
+func (_ *okOsClient) UpdateBuild(*api.Build) (*api.Build, error) {
|
|
| 21 |
+ return &api.Build{}, nil
|
|
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 | 24 |
type errOsClient struct{}
|
| 25 | 25 |
|
| 26 |
-func (_ *errOsClient) ListBuilds(selector labels.Selector) (api.BuildList, error) {
|
|
| 27 |
- return api.BuildList{}, errors.New("ListBuild error!")
|
|
| 26 |
+func (_ *errOsClient) ListBuilds(selector labels.Selector) (*api.BuildList, error) {
|
|
| 27 |
+ return &api.BuildList{}, errors.New("ListBuild error!")
|
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
-func (_ *errOsClient) UpdateBuild(build api.Build) (api.Build, error) {
|
|
| 31 |
- return api.Build{}, errors.New("UpdateBuild error!")
|
|
| 30 |
+func (_ *errOsClient) UpdateBuild(build *api.Build) (*api.Build, error) {
|
|
| 31 |
+ return &api.Build{}, errors.New("UpdateBuild error!")
|
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 | 34 |
type okStrategy struct{}
|
| ... | ... |
@@ -41,20 +41,20 @@ type errKubeClient struct {
|
| 41 | 41 |
kubeclient.Fake |
| 42 | 42 |
} |
| 43 | 43 |
|
| 44 |
-func (_ *errKubeClient) CreatePod(pod kubeapi.Pod) (kubeapi.Pod, error) {
|
|
| 45 |
- return kubeapi.Pod{}, errors.New("CreatePod error!")
|
|
| 44 |
+func (_ *errKubeClient) CreatePod(pod *kubeapi.Pod) (*kubeapi.Pod, error) {
|
|
| 45 |
+ return &kubeapi.Pod{}, errors.New("CreatePod error!")
|
|
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 |
-func (_ *errKubeClient) GetPod(name string) (kubeapi.Pod, error) {
|
|
| 49 |
- return kubeapi.Pod{}, errors.New("GedPod error!")
|
|
| 48 |
+func (_ *errKubeClient) GetPod(name string) (*kubeapi.Pod, error) {
|
|
| 49 |
+ return &kubeapi.Pod{}, errors.New("GedPod error!")
|
|
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 | 52 |
type okKubeClient struct {
|
| 53 | 53 |
kubeclient.Fake |
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 |
-func (_ *okKubeClient) GetPod(name string) (kubeapi.Pod, error) {
|
|
| 57 |
- return kubeapi.Pod{
|
|
| 56 |
+func (_ *okKubeClient) GetPod(name string) (*kubeapi.Pod, error) {
|
|
| 57 |
+ return &kubeapi.Pod{
|
|
| 58 | 58 |
CurrentState: kubeapi.PodState{Status: kubeapi.PodTerminated},
|
| 59 | 59 |
}, nil |
| 60 | 60 |
} |
| ... | ... |
@@ -10,11 +10,11 @@ import ( |
| 10 | 10 |
|
| 11 | 11 |
kubeapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
| 12 | 12 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" |
| 13 |
- _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" |
|
| 13 |
+ _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" |
|
| 14 | 14 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" |
| 15 |
- "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" |
|
| 15 |
+ |
|
| 16 |
+ "github.com/openshift/origin/pkg/api/latest" |
|
| 16 | 17 |
"github.com/openshift/origin/pkg/build/api" |
| 17 |
- _ "github.com/openshift/origin/pkg/build/api/v1beta1" |
|
| 18 | 18 |
"github.com/openshift/origin/pkg/build/registry/test" |
| 19 | 19 |
) |
| 20 | 20 |
|
| ... | ... |
@@ -107,7 +107,7 @@ func TestListBuildsError(t *testing.T) {
|
| 107 | 107 |
Err: fmt.Errorf("test error"),
|
| 108 | 108 |
} |
| 109 | 109 |
storage := REST{&mockRegistry}
|
| 110 |
- builds, err := storage.List(nil) |
|
| 110 |
+ builds, err := storage.List(nil, nil) |
|
| 111 | 111 |
if err != mockRegistry.Err {
|
| 112 | 112 |
t.Errorf("Expected %#v, Got %#v", mockRegistry.Err, err)
|
| 113 | 113 |
} |
| ... | ... |
@@ -119,7 +119,7 @@ func TestListBuildsError(t *testing.T) {
|
| 119 | 119 |
func TestListEmptyBuildList(t *testing.T) {
|
| 120 | 120 |
mockRegistry := test.BuildRegistry{Builds: &api.BuildList{JSONBase: kubeapi.JSONBase{ResourceVersion: 1}}}
|
| 121 | 121 |
storage := REST{&mockRegistry}
|
| 122 |
- builds, err := storage.List(labels.Everything()) |
|
| 122 |
+ builds, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 123 | 123 |
if err != nil {
|
| 124 | 124 |
t.Errorf("unexpected error: %v", err)
|
| 125 | 125 |
} |
| ... | ... |
@@ -150,7 +150,7 @@ func TestListBuilds(t *testing.T) {
|
| 150 | 150 |
}, |
| 151 | 151 |
} |
| 152 | 152 |
storage := REST{registry: &mockRegistry}
|
| 153 |
- buildsObj, err := storage.List(labels.Everything()) |
|
| 153 |
+ buildsObj, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 154 | 154 |
builds := buildsObj.(*api.BuildList) |
| 155 | 155 |
if err != nil {
|
| 156 | 156 |
t.Errorf("unexpected error: %v", err)
|
| ... | ... |
@@ -175,13 +175,13 @@ func TestBuildDecode(t *testing.T) {
|
| 175 | 175 |
ID: "foo", |
| 176 | 176 |
}, |
| 177 | 177 |
} |
| 178 |
- body, err := runtime.Encode(build) |
|
| 178 |
+ body, err := latest.Codec.Encode(build) |
|
| 179 | 179 |
if err != nil {
|
| 180 | 180 |
t.Errorf("unexpected error: %v", err)
|
| 181 | 181 |
} |
| 182 | 182 |
|
| 183 | 183 |
buildOut := storage.New() |
| 184 |
- if err := runtime.DecodeInto(body, buildOut); err != nil {
|
|
| 184 |
+ if err := latest.Codec.DecodeInto(body, buildOut); err != nil {
|
|
| 185 | 185 |
t.Errorf("unexpected error: %v", err)
|
| 186 | 186 |
} |
| 187 | 187 |
|
| ... | ... |
@@ -12,9 +12,9 @@ import ( |
| 12 | 12 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" |
| 13 | 13 |
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" |
| 14 | 14 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" |
| 15 |
- "github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" |
|
| 15 |
+ |
|
| 16 |
+ "github.com/openshift/origin/pkg/api/latest" |
|
| 16 | 17 |
"github.com/openshift/origin/pkg/build/api" |
| 17 |
- _ "github.com/openshift/origin/pkg/build/api/v1beta1" |
|
| 18 | 18 |
"github.com/openshift/origin/pkg/build/registry/test" |
| 19 | 19 |
) |
| 20 | 20 |
|
| ... | ... |
@@ -107,7 +107,7 @@ func TestListConfigsError(t *testing.T) {
|
| 107 | 107 |
Err: fmt.Errorf("test error"),
|
| 108 | 108 |
} |
| 109 | 109 |
storage := REST{&mockRegistry}
|
| 110 |
- configs, err := storage.List(nil) |
|
| 110 |
+ configs, err := storage.List(nil, nil) |
|
| 111 | 111 |
if err != mockRegistry.Err {
|
| 112 | 112 |
t.Errorf("Expected %#v, Got %#v", mockRegistry.Err, err)
|
| 113 | 113 |
} |
| ... | ... |
@@ -119,7 +119,7 @@ func TestListConfigsError(t *testing.T) {
|
| 119 | 119 |
func TestListEmptyConfigList(t *testing.T) {
|
| 120 | 120 |
mockRegistry := test.BuildConfigRegistry{BuildConfigs: &api.BuildConfigList{JSONBase: kubeapi.JSONBase{ResourceVersion: 1}}}
|
| 121 | 121 |
storage := REST{&mockRegistry}
|
| 122 |
- buildConfigs, err := storage.List(labels.Everything()) |
|
| 122 |
+ buildConfigs, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 123 | 123 |
if err != nil {
|
| 124 | 124 |
t.Errorf("unexpected error: %v", err)
|
| 125 | 125 |
} |
| ... | ... |
@@ -150,7 +150,7 @@ func TestListConfigs(t *testing.T) {
|
| 150 | 150 |
}, |
| 151 | 151 |
} |
| 152 | 152 |
storage := REST{&mockRegistry}
|
| 153 |
- configsObj, err := storage.List(labels.Everything()) |
|
| 153 |
+ configsObj, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 154 | 154 |
configs := configsObj.(*api.BuildConfigList) |
| 155 | 155 |
if err != nil {
|
| 156 | 156 |
t.Errorf("unexpected error: %v", err)
|
| ... | ... |
@@ -174,13 +174,13 @@ func TestBuildConfigDecode(t *testing.T) {
|
| 174 | 174 |
ID: "foo", |
| 175 | 175 |
}, |
| 176 | 176 |
} |
| 177 |
- body, err := runtime.Encode(buildConfig) |
|
| 177 |
+ body, err := latest.Codec.Encode(buildConfig) |
|
| 178 | 178 |
if err != nil {
|
| 179 | 179 |
t.Errorf("unexpected error: %v", err)
|
| 180 | 180 |
} |
| 181 | 181 |
|
| 182 | 182 |
buildConfigOut := storage.New() |
| 183 |
- if err := runtime.DecodeInto(body, buildConfigOut); err != nil {
|
|
| 183 |
+ if err := latest.Codec.DecodeInto(body, buildConfigOut); err != nil {
|
|
| 184 | 184 |
t.Errorf("unexpected error: %v", err)
|
| 185 | 185 |
} |
| 186 | 186 |
|
| ... | ... |
@@ -9,20 +9,19 @@ import ( |
| 9 | 9 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" |
| 10 | 10 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools" |
| 11 | 11 |
|
| 12 |
+ "github.com/openshift/origin/pkg/api/latest" |
|
| 12 | 13 |
"github.com/openshift/origin/pkg/build/api" |
| 13 |
- _ "github.com/openshift/origin/pkg/build/api/v1beta1" |
|
| 14 | 14 |
|
| 15 | 15 |
"github.com/coreos/go-etcd/etcd" |
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
func NewTestEtcd(client tools.EtcdClient) *Etcd {
|
| 19 |
- registry := NewEtcd(client) |
|
| 20 |
- return registry |
|
| 19 |
+ return New(tools.EtcdHelper{client, latest.Codec, latest.ResourceVersioner})
|
|
| 21 | 20 |
} |
| 22 | 21 |
|
| 23 | 22 |
func TestEtcdGetBuild(t *testing.T) {
|
| 24 | 23 |
fakeClient := tools.NewFakeEtcdClient(t) |
| 25 |
- fakeClient.Set("/registry/builds/foo", runtime.EncodeOrDie(api.Build{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 24 |
+ fakeClient.Set("/registry/builds/foo", runtime.EncodeOrDie(latest.Codec, &api.Build{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 26 | 25 |
registry := NewTestEtcd(fakeClient) |
| 27 | 26 |
build, err := registry.GetBuild("foo")
|
| 28 | 27 |
if err != nil {
|
| ... | ... |
@@ -81,7 +80,7 @@ func TestEtcdCreateBuild(t *testing.T) {
|
| 81 | 81 |
t.Fatalf("Unexpected error %v", err)
|
| 82 | 82 |
} |
| 83 | 83 |
var build api.Build |
| 84 |
- err = runtime.DecodeInto([]byte(resp.Node.Value), &build) |
|
| 84 |
+ err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &build) |
|
| 85 | 85 |
if err != nil {
|
| 86 | 86 |
t.Errorf("unexpected error: %v", err)
|
| 87 | 87 |
} |
| ... | ... |
@@ -96,7 +95,7 @@ func TestEtcdCreateBuildAlreadyExisting(t *testing.T) {
|
| 96 | 96 |
fakeClient.Data["/registry/builds/foo"] = tools.EtcdResponseWithError{
|
| 97 | 97 |
R: &etcd.Response{
|
| 98 | 98 |
Node: &etcd.Node{
|
| 99 |
- Value: runtime.EncodeOrDie(api.Build{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 99 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Build{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 100 | 100 |
}, |
| 101 | 101 |
}, |
| 102 | 102 |
E: nil, |
| ... | ... |
@@ -117,7 +116,7 @@ func TestEtcdDeleteBuild(t *testing.T) {
|
| 117 | 117 |
fakeClient.TestIndex = true |
| 118 | 118 |
|
| 119 | 119 |
key := "/registry/builds/foo" |
| 120 |
- fakeClient.Set(key, runtime.EncodeOrDie(api.Build{
|
|
| 120 |
+ fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Build{
|
|
| 121 | 121 |
JSONBase: kubeapi.JSONBase{ID: "foo"},
|
| 122 | 122 |
}), 0) |
| 123 | 123 |
registry := NewTestEtcd(fakeClient) |
| ... | ... |
@@ -163,12 +162,12 @@ func TestEtcdListBuilds(t *testing.T) {
|
| 163 | 163 |
Node: &etcd.Node{
|
| 164 | 164 |
Nodes: []*etcd.Node{
|
| 165 | 165 |
{
|
| 166 |
- Value: runtime.EncodeOrDie(api.Build{
|
|
| 166 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Build{
|
|
| 167 | 167 |
JSONBase: kubeapi.JSONBase{ID: "foo"},
|
| 168 | 168 |
}), |
| 169 | 169 |
}, |
| 170 | 170 |
{
|
| 171 |
- Value: runtime.EncodeOrDie(api.Build{
|
|
| 171 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Build{
|
|
| 172 | 172 |
JSONBase: kubeapi.JSONBase{ID: "bar"},
|
| 173 | 173 |
}), |
| 174 | 174 |
}, |
| ... | ... |
@@ -190,7 +189,7 @@ func TestEtcdListBuilds(t *testing.T) {
|
| 190 | 190 |
|
| 191 | 191 |
func TestEtcdGetBuildConfig(t *testing.T) {
|
| 192 | 192 |
fakeClient := tools.NewFakeEtcdClient(t) |
| 193 |
- fakeClient.Set("/registry/build-configs/foo", runtime.EncodeOrDie(api.BuildConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 193 |
+ fakeClient.Set("/registry/build-configs/foo", runtime.EncodeOrDie(latest.Codec, &api.BuildConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 194 | 194 |
registry := NewTestEtcd(fakeClient) |
| 195 | 195 |
buildConfig, err := registry.GetBuildConfig("foo")
|
| 196 | 196 |
if err != nil {
|
| ... | ... |
@@ -247,7 +246,7 @@ func TestEtcdCreateBuildConfig(t *testing.T) {
|
| 247 | 247 |
t.Fatalf("Unexpected error %v", err)
|
| 248 | 248 |
} |
| 249 | 249 |
var buildConfig api.BuildConfig |
| 250 |
- err = runtime.DecodeInto([]byte(resp.Node.Value), &buildConfig) |
|
| 250 |
+ err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &buildConfig) |
|
| 251 | 251 |
if err != nil {
|
| 252 | 252 |
t.Errorf("unexpected error: %v", err)
|
| 253 | 253 |
} |
| ... | ... |
@@ -262,7 +261,7 @@ func TestEtcdCreateBuildConfigAlreadyExisting(t *testing.T) {
|
| 262 | 262 |
fakeClient.Data["/registry/build-configs/foo"] = tools.EtcdResponseWithError{
|
| 263 | 263 |
R: &etcd.Response{
|
| 264 | 264 |
Node: &etcd.Node{
|
| 265 |
- Value: runtime.EncodeOrDie(api.BuildConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 265 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.BuildConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 266 | 266 |
}, |
| 267 | 267 |
}, |
| 268 | 268 |
E: nil, |
| ... | ... |
@@ -283,7 +282,7 @@ func TestEtcdDeleteBuildConfig(t *testing.T) {
|
| 283 | 283 |
fakeClient.TestIndex = true |
| 284 | 284 |
|
| 285 | 285 |
key := "/registry/build-configs/foo" |
| 286 |
- fakeClient.Set(key, runtime.EncodeOrDie(api.BuildConfig{
|
|
| 286 |
+ fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.BuildConfig{
|
|
| 287 | 287 |
JSONBase: kubeapi.JSONBase{ID: "foo"},
|
| 288 | 288 |
}), 0) |
| 289 | 289 |
registry := NewTestEtcd(fakeClient) |
| ... | ... |
@@ -329,12 +328,12 @@ func TestEtcdListBuildConfigs(t *testing.T) {
|
| 329 | 329 |
Node: &etcd.Node{
|
| 330 | 330 |
Nodes: []*etcd.Node{
|
| 331 | 331 |
{
|
| 332 |
- Value: runtime.EncodeOrDie(api.BuildConfig{
|
|
| 332 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.BuildConfig{
|
|
| 333 | 333 |
JSONBase: kubeapi.JSONBase{ID: "foo"},
|
| 334 | 334 |
}), |
| 335 | 335 |
}, |
| 336 | 336 |
{
|
| 337 |
- Value: runtime.EncodeOrDie(api.BuildConfig{
|
|
| 337 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.BuildConfig{
|
|
| 338 | 338 |
JSONBase: kubeapi.JSONBase{ID: "bar"},
|
| 339 | 339 |
}), |
| 340 | 340 |
}, |
| ... | ... |
@@ -27,8 +27,8 @@ func TestDockerCreateBuildPod(t *testing.T) {
|
| 27 | 27 |
t.Errorf("Expected %s image, got %s!", container.Image,
|
| 28 | 28 |
strategy.dockerBuilderImage) |
| 29 | 29 |
} |
| 30 |
- if container.RestartPolicy != "runOnce" {
|
|
| 31 |
- t.Errorf("Expected runOnce, but got %s!", container.RestartPolicy)
|
|
| 30 |
+ if actual.DesiredState.Manifest.RestartPolicy.Never == nil {
|
|
| 31 |
+ t.Errorf("Expected never, got %#v", actual.DesiredState.Manifest.RestartPolicy)
|
|
| 32 | 32 |
} |
| 33 | 33 |
if e := container.Env[0]; e.Name != "BUILD_TAG" && e.Value != expected.Input.ImageTag {
|
| 34 | 34 |
t.Errorf("Expected %s, got %s:%s!", expected.Input.ImageTag, e.Name, e.Value)
|
| ... | ... |
@@ -33,8 +33,8 @@ func TestSTICreateBuildPod(t *testing.T) {
|
| 33 | 33 |
t.Errorf("Expected %s image, got %s!", container.Image,
|
| 34 | 34 |
strategy.stiBuilderImage) |
| 35 | 35 |
} |
| 36 |
- if container.RestartPolicy != "runOnce" {
|
|
| 37 |
- t.Errorf("Expected runOnce, but got %s!", container.RestartPolicy)
|
|
| 36 |
+ if actual.DesiredState.Manifest.RestartPolicy.Never == nil {
|
|
| 37 |
+ t.Errorf("Expected never, got %#v", actual.DesiredState.Manifest.RestartPolicy)
|
|
| 38 | 38 |
} |
| 39 | 39 |
if e := container.Env[0]; e.Name != "BUILD_TAG" || e.Value != expected.Input.ImageTag {
|
| 40 | 40 |
t.Errorf("Expected %s, got %s:%s!", expected.Input.ImageTag, e.Name, e.Value)
|
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"io/ioutil" |
| 6 | 6 |
"testing" |
| 7 | 7 |
|
| 8 |
+ klatest "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" |
|
| 8 | 9 |
kubeclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client" |
| 9 | 10 |
clientapi "github.com/openshift/origin/pkg/cmd/client/api" |
| 10 | 11 |
) |
| ... | ... |
@@ -40,10 +41,10 @@ func TestApply(t *testing.T) {
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 | 42 |
func TestGetClientAndPath(t *testing.T) {
|
| 43 |
- kubeClient, _ := kubeclient.New("127.0.0.1", nil)
|
|
| 43 |
+ kubeClient, _ := kubeclient.New("127.0.0.1", "", nil)
|
|
| 44 | 44 |
testClientMappings := clientapi.ClientMappings{
|
| 45 |
- "pods": {"Pod", kubeClient.RESTClient},
|
|
| 46 |
- "services": {"Service", kubeClient.RESTClient},
|
|
| 45 |
+ "pods": {"Pod", kubeClient.RESTClient, klatest.Codec},
|
|
| 46 |
+ "services": {"Service", kubeClient.RESTClient, klatest.Codec},
|
|
| 47 | 47 |
} |
| 48 | 48 |
client, path := getClientAndPath("Service", testClientMappings)
|
| 49 | 49 |
if client != kubeClient.RESTClient {
|
| ... | ... |
@@ -55,10 +56,10 @@ func TestGetClientAndPath(t *testing.T) {
|
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 | 57 |
func ExampleApply() {
|
| 58 |
- kubeClient, _ := kubeclient.New("127.0.0.1", nil)
|
|
| 58 |
+ kubeClient, _ := kubeclient.New("127.0.0.1", "", nil)
|
|
| 59 | 59 |
testClientMappings := clientapi.ClientMappings{
|
| 60 |
- "pods": {"Pod", kubeClient.RESTClient},
|
|
| 61 |
- "services": {"Service", kubeClient.RESTClient},
|
|
| 60 |
+ "pods": {"Pod", kubeClient.RESTClient, klatest.Codec},
|
|
| 61 |
+ "services": {"Service", kubeClient.RESTClient, klatest.Codec},
|
|
| 62 | 62 |
} |
| 63 | 63 |
data, _ := ioutil.ReadFile("config_test.json")
|
| 64 | 64 |
Apply(data, testClientMappings) |
| ... | ... |
@@ -20,7 +20,7 @@ func TestListDeploymentsError(t *testing.T) {
|
| 20 | 20 |
registry: mockRegistry, |
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
- deployments, err := storage.List(nil) |
|
| 23 |
+ deployments, err := storage.List(nil, nil) |
|
| 24 | 24 |
if err != mockRegistry.Err {
|
| 25 | 25 |
t.Errorf("Expected %#v, Got %#v", mockRegistry.Err, err)
|
| 26 | 26 |
} |
| ... | ... |
@@ -40,7 +40,7 @@ func TestListDeploymentsEmptyList(t *testing.T) {
|
| 40 | 40 |
registry: mockRegistry, |
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 |
- deployments, err := storage.List(labels.Everything()) |
|
| 43 |
+ deployments, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 44 | 44 |
if err != nil {
|
| 45 | 45 |
t.Errorf("Unexpected non-nil error: %#v", err)
|
| 46 | 46 |
} |
| ... | ... |
@@ -71,7 +71,7 @@ func TestListDeploymentsPopulatedList(t *testing.T) {
|
| 71 | 71 |
registry: mockRegistry, |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
- list, err := storage.List(labels.Everything()) |
|
| 74 |
+ list, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 75 | 75 |
if err != nil {
|
| 76 | 76 |
t.Errorf("Unexpected non-nil error: %#v", err)
|
| 77 | 77 |
} |
| ... | ... |
@@ -86,7 +86,7 @@ func TestListDeploymentsPopulatedList(t *testing.T) {
|
| 86 | 86 |
func TestCreateDeploymentBadObject(t *testing.T) {
|
| 87 | 87 |
storage := REST{}
|
| 88 | 88 |
|
| 89 |
- channel, err := storage.Create("hello")
|
|
| 89 |
+ channel, err := storage.Create(&api.DeploymentList{})
|
|
| 90 | 90 |
if channel != nil {
|
| 91 | 91 |
t.Errorf("Expected nil, got %v", channel)
|
| 92 | 92 |
} |
| ... | ... |
@@ -205,7 +205,7 @@ func TestGetDeploymentOK(t *testing.T) {
|
| 205 | 205 |
func TestUpdateDeploymentBadObject(t *testing.T) {
|
| 206 | 206 |
storage := REST{}
|
| 207 | 207 |
|
| 208 |
- channel, err := storage.Update("hello")
|
|
| 208 |
+ channel, err := storage.Update(&api.DeploymentConfig{})
|
|
| 209 | 209 |
if channel != nil {
|
| 210 | 210 |
t.Errorf("Expected nil, got %v", channel)
|
| 211 | 211 |
} |
| ... | ... |
@@ -20,7 +20,7 @@ func TestListDeploymentConfigsError(t *testing.T) {
|
| 20 | 20 |
registry: mockRegistry, |
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
- deploymentConfigs, err := storage.List(nil) |
|
| 23 |
+ deploymentConfigs, err := storage.List(nil, nil) |
|
| 24 | 24 |
if err != mockRegistry.Err {
|
| 25 | 25 |
t.Errorf("Expected %#v, Got %#v", mockRegistry.Err, err)
|
| 26 | 26 |
} |
| ... | ... |
@@ -40,7 +40,7 @@ func TestListDeploymentConfigsEmptyList(t *testing.T) {
|
| 40 | 40 |
registry: mockRegistry, |
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 |
- deploymentConfigs, err := storage.List(labels.Everything()) |
|
| 43 |
+ deploymentConfigs, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 44 | 44 |
if err != nil {
|
| 45 | 45 |
t.Errorf("Unexpected non-nil error: %#v", err)
|
| 46 | 46 |
} |
| ... | ... |
@@ -71,7 +71,7 @@ func TestListDeploymentConfigsPopulatedList(t *testing.T) {
|
| 71 | 71 |
registry: mockRegistry, |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
- list, err := storage.List(labels.Everything()) |
|
| 74 |
+ list, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 75 | 75 |
if err != nil {
|
| 76 | 76 |
t.Errorf("Unexpected non-nil error: %#v", err)
|
| 77 | 77 |
} |
| ... | ... |
@@ -86,7 +86,7 @@ func TestListDeploymentConfigsPopulatedList(t *testing.T) {
|
| 86 | 86 |
func TestCreateDeploymentConfigBadObject(t *testing.T) {
|
| 87 | 87 |
storage := REST{}
|
| 88 | 88 |
|
| 89 |
- channel, err := storage.Create("hello")
|
|
| 89 |
+ channel, err := storage.Create(&api.DeploymentList{})
|
|
| 90 | 90 |
if channel != nil {
|
| 91 | 91 |
t.Errorf("Expected nil, got %v", channel)
|
| 92 | 92 |
} |
| ... | ... |
@@ -190,7 +190,7 @@ func TestGetDeploymentConfigOK(t *testing.T) {
|
| 190 | 190 |
func TestUpdateDeploymentConfigBadObject(t *testing.T) {
|
| 191 | 191 |
storage := REST{}
|
| 192 | 192 |
|
| 193 |
- channel, err := storage.Update("hello")
|
|
| 193 |
+ channel, err := storage.Update(&api.DeploymentList{})
|
|
| 194 | 194 |
if channel != nil {
|
| 195 | 195 |
t.Errorf("Expected nil, got %v", channel)
|
| 196 | 196 |
} |
| ... | ... |
@@ -10,13 +10,13 @@ import ( |
| 10 | 10 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime" |
| 11 | 11 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools" |
| 12 | 12 |
"github.com/coreos/go-etcd/etcd" |
| 13 |
- "github.com/openshift/origin/pkg/deploy/api" |
|
| 14 | 13 |
|
| 15 |
- _ "github.com/openshift/origin/pkg/deploy/api/v1beta1" |
|
| 14 |
+ "github.com/openshift/origin/pkg/api/latest" |
|
| 15 |
+ "github.com/openshift/origin/pkg/deploy/api" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
func NewTestEtcd(client tools.EtcdClient) *Etcd {
|
| 19 |
- return NewEtcd(client) |
|
| 19 |
+ return New(tools.EtcdHelper{client, latest.Codec, latest.ResourceVersioner})
|
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 | 22 |
func TestEtcdListEmptyDeployments(t *testing.T) {
|
| ... | ... |
@@ -69,10 +69,10 @@ func TestEtcdListEverythingDeployments(t *testing.T) {
|
| 69 | 69 |
Node: &etcd.Node{
|
| 70 | 70 |
Nodes: []*etcd.Node{
|
| 71 | 71 |
{
|
| 72 |
- Value: runtime.EncodeOrDie(api.Deployment{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 72 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Deployment{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 73 | 73 |
}, |
| 74 | 74 |
{
|
| 75 |
- Value: runtime.EncodeOrDie(api.Deployment{JSONBase: kubeapi.JSONBase{ID: "bar"}}),
|
|
| 75 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Deployment{JSONBase: kubeapi.JSONBase{ID: "bar"}}),
|
|
| 76 | 76 |
}, |
| 77 | 77 |
}, |
| 78 | 78 |
}, |
| ... | ... |
@@ -98,13 +98,13 @@ func TestEtcdListFilteredDeployments(t *testing.T) {
|
| 98 | 98 |
Node: &etcd.Node{
|
| 99 | 99 |
Nodes: []*etcd.Node{
|
| 100 | 100 |
{
|
| 101 |
- Value: runtime.EncodeOrDie(api.Deployment{
|
|
| 101 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Deployment{
|
|
| 102 | 102 |
JSONBase: kubeapi.JSONBase{ID: "foo"},
|
| 103 | 103 |
Labels: map[string]string{"env": "prod"},
|
| 104 | 104 |
}), |
| 105 | 105 |
}, |
| 106 | 106 |
{
|
| 107 |
- Value: runtime.EncodeOrDie(api.Deployment{
|
|
| 107 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Deployment{
|
|
| 108 | 108 |
JSONBase: kubeapi.JSONBase{ID: "bar"},
|
| 109 | 109 |
Labels: map[string]string{"env": "dev"},
|
| 110 | 110 |
}), |
| ... | ... |
@@ -127,7 +127,7 @@ func TestEtcdListFilteredDeployments(t *testing.T) {
|
| 127 | 127 |
|
| 128 | 128 |
func TestEtcdGetDeployments(t *testing.T) {
|
| 129 | 129 |
fakeClient := tools.NewFakeEtcdClient(t) |
| 130 |
- fakeClient.Set("/deployments/foo", runtime.EncodeOrDie(api.Deployment{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 130 |
+ fakeClient.Set("/deployments/foo", runtime.EncodeOrDie(latest.Codec, &api.Deployment{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 131 | 131 |
registry := NewTestEtcd(fakeClient) |
| 132 | 132 |
deployment, err := registry.GetDeployment("foo")
|
| 133 | 133 |
if err != nil {
|
| ... | ... |
@@ -181,7 +181,7 @@ func TestEtcdCreateDeployments(t *testing.T) {
|
| 181 | 181 |
t.Fatalf("Unexpected error %v", err)
|
| 182 | 182 |
} |
| 183 | 183 |
var deployment api.Deployment |
| 184 |
- err = runtime.DecodeInto([]byte(resp.Node.Value), &deployment) |
|
| 184 |
+ err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &deployment) |
|
| 185 | 185 |
if err != nil {
|
| 186 | 186 |
t.Errorf("unexpected error: %v", err)
|
| 187 | 187 |
} |
| ... | ... |
@@ -196,7 +196,7 @@ func TestEtcdCreateAlreadyExistsDeployments(t *testing.T) {
|
| 196 | 196 |
fakeClient.Data["/deployments/foo"] = tools.EtcdResponseWithError{
|
| 197 | 197 |
R: &etcd.Response{
|
| 198 | 198 |
Node: &etcd.Node{
|
| 199 |
- Value: runtime.EncodeOrDie(api.Deployment{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 199 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Deployment{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 200 | 200 |
}, |
| 201 | 201 |
}, |
| 202 | 202 |
E: nil, |
| ... | ... |
@@ -312,10 +312,10 @@ func TestEtcdListEverythingDeploymentConfig(t *testing.T) {
|
| 312 | 312 |
Node: &etcd.Node{
|
| 313 | 313 |
Nodes: []*etcd.Node{
|
| 314 | 314 |
{
|
| 315 |
- Value: runtime.EncodeOrDie(api.DeploymentConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 315 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 316 | 316 |
}, |
| 317 | 317 |
{
|
| 318 |
- Value: runtime.EncodeOrDie(api.DeploymentConfig{JSONBase: kubeapi.JSONBase{ID: "bar"}}),
|
|
| 318 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{JSONBase: kubeapi.JSONBase{ID: "bar"}}),
|
|
| 319 | 319 |
}, |
| 320 | 320 |
}, |
| 321 | 321 |
}, |
| ... | ... |
@@ -341,13 +341,13 @@ func TestEtcdListFilteredDeploymentConfig(t *testing.T) {
|
| 341 | 341 |
Node: &etcd.Node{
|
| 342 | 342 |
Nodes: []*etcd.Node{
|
| 343 | 343 |
{
|
| 344 |
- Value: runtime.EncodeOrDie(api.DeploymentConfig{
|
|
| 344 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{
|
|
| 345 | 345 |
JSONBase: kubeapi.JSONBase{ID: "foo"},
|
| 346 | 346 |
Labels: map[string]string{"env": "prod"},
|
| 347 | 347 |
}), |
| 348 | 348 |
}, |
| 349 | 349 |
{
|
| 350 |
- Value: runtime.EncodeOrDie(api.DeploymentConfig{
|
|
| 350 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{
|
|
| 351 | 351 |
JSONBase: kubeapi.JSONBase{ID: "bar"},
|
| 352 | 352 |
Labels: map[string]string{"env": "dev"},
|
| 353 | 353 |
}), |
| ... | ... |
@@ -370,7 +370,7 @@ func TestEtcdListFilteredDeploymentConfig(t *testing.T) {
|
| 370 | 370 |
|
| 371 | 371 |
func TestEtcdGetDeploymentConfig(t *testing.T) {
|
| 372 | 372 |
fakeClient := tools.NewFakeEtcdClient(t) |
| 373 |
- fakeClient.Set("/deploymentConfigs/foo", runtime.EncodeOrDie(api.DeploymentConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 373 |
+ fakeClient.Set("/deploymentConfigs/foo", runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 374 | 374 |
registry := NewTestEtcd(fakeClient) |
| 375 | 375 |
deployment, err := registry.GetDeploymentConfig("foo")
|
| 376 | 376 |
if err != nil {
|
| ... | ... |
@@ -424,7 +424,7 @@ func TestEtcdCreateDeploymentConfig(t *testing.T) {
|
| 424 | 424 |
t.Fatalf("Unexpected error %v", err)
|
| 425 | 425 |
} |
| 426 | 426 |
var d api.DeploymentConfig |
| 427 |
- err = runtime.DecodeInto([]byte(resp.Node.Value), &d) |
|
| 427 |
+ err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &d) |
|
| 428 | 428 |
if err != nil {
|
| 429 | 429 |
t.Errorf("unexpected error: %v", err)
|
| 430 | 430 |
} |
| ... | ... |
@@ -439,7 +439,7 @@ func TestEtcdCreateAlreadyExistsDeploymentConfig(t *testing.T) {
|
| 439 | 439 |
fakeClient.Data["/deploymentConfigs/foo"] = tools.EtcdResponseWithError{
|
| 440 | 440 |
R: &etcd.Response{
|
| 441 | 441 |
Node: &etcd.Node{
|
| 442 |
- Value: runtime.EncodeOrDie(api.DeploymentConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 442 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.DeploymentConfig{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 443 | 443 |
}, |
| 444 | 444 |
}, |
| 445 | 445 |
E: nil, |
| ... | ... |
@@ -13,12 +13,13 @@ import ( |
| 13 | 13 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch" |
| 14 | 14 |
"github.com/coreos/go-etcd/etcd" |
| 15 | 15 |
"github.com/fsouza/go-dockerclient" |
| 16 |
+ |
|
| 17 |
+ "github.com/openshift/origin/pkg/api/latest" |
|
| 16 | 18 |
"github.com/openshift/origin/pkg/image/api" |
| 17 |
- _ "github.com/openshift/origin/pkg/image/api/v1beta1" |
|
| 18 | 19 |
) |
| 19 | 20 |
|
| 20 | 21 |
func NewTestEtcd(client tools.EtcdClient) *Etcd {
|
| 21 |
- return NewEtcd(client) |
|
| 22 |
+ return New(tools.EtcdHelper{client, latest.Codec, latest.ResourceVersioner})
|
|
| 22 | 23 |
} |
| 23 | 24 |
|
| 24 | 25 |
func TestEtcdListImagesEmpty(t *testing.T) {
|
| ... | ... |
@@ -71,10 +72,10 @@ func TestEtcdListImagesEverything(t *testing.T) {
|
| 71 | 71 |
Node: &etcd.Node{
|
| 72 | 72 |
Nodes: []*etcd.Node{
|
| 73 | 73 |
{
|
| 74 |
- Value: runtime.EncodeOrDie(api.Image{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 74 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Image{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 75 | 75 |
}, |
| 76 | 76 |
{
|
| 77 |
- Value: runtime.EncodeOrDie(api.Image{JSONBase: kubeapi.JSONBase{ID: "bar"}}),
|
|
| 77 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Image{JSONBase: kubeapi.JSONBase{ID: "bar"}}),
|
|
| 78 | 78 |
}, |
| 79 | 79 |
}, |
| 80 | 80 |
}, |
| ... | ... |
@@ -100,13 +101,13 @@ func TestEtcdListImagesFiltered(t *testing.T) {
|
| 100 | 100 |
Node: &etcd.Node{
|
| 101 | 101 |
Nodes: []*etcd.Node{
|
| 102 | 102 |
{
|
| 103 |
- Value: runtime.EncodeOrDie(api.Image{
|
|
| 103 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Image{
|
|
| 104 | 104 |
JSONBase: kubeapi.JSONBase{ID: "foo"},
|
| 105 | 105 |
Labels: map[string]string{"env": "prod"},
|
| 106 | 106 |
}), |
| 107 | 107 |
}, |
| 108 | 108 |
{
|
| 109 |
- Value: runtime.EncodeOrDie(api.Image{
|
|
| 109 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Image{
|
|
| 110 | 110 |
JSONBase: kubeapi.JSONBase{ID: "bar"},
|
| 111 | 111 |
Labels: map[string]string{"env": "dev"},
|
| 112 | 112 |
}), |
| ... | ... |
@@ -129,7 +130,7 @@ func TestEtcdListImagesFiltered(t *testing.T) {
|
| 129 | 129 |
|
| 130 | 130 |
func TestEtcdGetImage(t *testing.T) {
|
| 131 | 131 |
fakeClient := tools.NewFakeEtcdClient(t) |
| 132 |
- fakeClient.Set("/images/foo", runtime.EncodeOrDie(api.Image{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 132 |
+ fakeClient.Set("/images/foo", runtime.EncodeOrDie(latest.Codec, &api.Image{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 133 | 133 |
registry := NewTestEtcd(fakeClient) |
| 134 | 134 |
image, err := registry.GetImage("foo")
|
| 135 | 135 |
if err != nil {
|
| ... | ... |
@@ -187,7 +188,7 @@ func TestEtcdCreateImage(t *testing.T) {
|
| 187 | 187 |
t.Fatalf("Unexpected error %v", err)
|
| 188 | 188 |
} |
| 189 | 189 |
var image api.Image |
| 190 |
- err = runtime.DecodeInto([]byte(resp.Node.Value), &image) |
|
| 190 |
+ err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &image) |
|
| 191 | 191 |
if err != nil {
|
| 192 | 192 |
t.Errorf("unexpected error: %v", err)
|
| 193 | 193 |
} |
| ... | ... |
@@ -210,7 +211,7 @@ func TestEtcdCreateImageAlreadyExists(t *testing.T) {
|
| 210 | 210 |
fakeClient.Data["/images/foo"] = tools.EtcdResponseWithError{
|
| 211 | 211 |
R: &etcd.Response{
|
| 212 | 212 |
Node: &etcd.Node{
|
| 213 |
- Value: runtime.EncodeOrDie(api.Image{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 213 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.Image{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 214 | 214 |
}, |
| 215 | 215 |
}, |
| 216 | 216 |
E: nil, |
| ... | ... |
@@ -326,10 +327,10 @@ func TestEtcdListImageRepositoriesEverything(t *testing.T) {
|
| 326 | 326 |
Node: &etcd.Node{
|
| 327 | 327 |
Nodes: []*etcd.Node{
|
| 328 | 328 |
{
|
| 329 |
- Value: runtime.EncodeOrDie(api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 329 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 330 | 330 |
}, |
| 331 | 331 |
{
|
| 332 |
- Value: runtime.EncodeOrDie(api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "bar"}}),
|
|
| 332 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "bar"}}),
|
|
| 333 | 333 |
}, |
| 334 | 334 |
}, |
| 335 | 335 |
}, |
| ... | ... |
@@ -355,13 +356,13 @@ func TestEtcdListImageRepositoriesFiltered(t *testing.T) {
|
| 355 | 355 |
Node: &etcd.Node{
|
| 356 | 356 |
Nodes: []*etcd.Node{
|
| 357 | 357 |
{
|
| 358 |
- Value: runtime.EncodeOrDie(api.ImageRepository{
|
|
| 358 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.ImageRepository{
|
|
| 359 | 359 |
JSONBase: kubeapi.JSONBase{ID: "foo"},
|
| 360 | 360 |
Labels: map[string]string{"env": "prod"},
|
| 361 | 361 |
}), |
| 362 | 362 |
}, |
| 363 | 363 |
{
|
| 364 |
- Value: runtime.EncodeOrDie(api.ImageRepository{
|
|
| 364 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.ImageRepository{
|
|
| 365 | 365 |
JSONBase: kubeapi.JSONBase{ID: "bar"},
|
| 366 | 366 |
Labels: map[string]string{"env": "dev"},
|
| 367 | 367 |
}), |
| ... | ... |
@@ -384,7 +385,7 @@ func TestEtcdListImageRepositoriesFiltered(t *testing.T) {
|
| 384 | 384 |
|
| 385 | 385 |
func TestEtcdGetImageRepository(t *testing.T) {
|
| 386 | 386 |
fakeClient := tools.NewFakeEtcdClient(t) |
| 387 |
- fakeClient.Set("/imageRepositories/foo", runtime.EncodeOrDie(api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 387 |
+ fakeClient.Set("/imageRepositories/foo", runtime.EncodeOrDie(latest.Codec, &api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 388 | 388 |
registry := NewTestEtcd(fakeClient) |
| 389 | 389 |
repo, err := registry.GetImageRepository("foo")
|
| 390 | 390 |
if err != nil {
|
| ... | ... |
@@ -441,7 +442,7 @@ func TestEtcdCreateImageRepository(t *testing.T) {
|
| 441 | 441 |
t.Fatalf("Unexpected error %v", err)
|
| 442 | 442 |
} |
| 443 | 443 |
var repo api.ImageRepository |
| 444 |
- err = runtime.DecodeInto([]byte(resp.Node.Value), &repo) |
|
| 444 |
+ err = latest.Codec.DecodeInto([]byte(resp.Node.Value), &repo) |
|
| 445 | 445 |
if err != nil {
|
| 446 | 446 |
t.Errorf("unexpected error: %v", err)
|
| 447 | 447 |
} |
| ... | ... |
@@ -468,7 +469,7 @@ func TestEtcdCreateImageRepositoryAlreadyExists(t *testing.T) {
|
| 468 | 468 |
fakeClient.Data["/imageRepositories/foo"] = tools.EtcdResponseWithError{
|
| 469 | 469 |
R: &etcd.Response{
|
| 470 | 470 |
Node: &etcd.Node{
|
| 471 |
- Value: runtime.EncodeOrDie(api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 471 |
+ Value: runtime.EncodeOrDie(latest.Codec, &api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "foo"}}),
|
|
| 472 | 472 |
}, |
| 473 | 473 |
}, |
| 474 | 474 |
E: nil, |
| ... | ... |
@@ -491,7 +492,7 @@ func TestEtcdUpdateImageRepository(t *testing.T) {
|
| 491 | 491 |
fakeClient := tools.NewFakeEtcdClient(t) |
| 492 | 492 |
fakeClient.TestIndex = true |
| 493 | 493 |
|
| 494 |
- resp, _ := fakeClient.Set("/imageRepositories/foo", runtime.EncodeOrDie(api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 494 |
+ resp, _ := fakeClient.Set("/imageRepositories/foo", runtime.EncodeOrDie(latest.Codec, &api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "foo"}}), 0)
|
|
| 495 | 495 |
registry := NewTestEtcd(fakeClient) |
| 496 | 496 |
err := registry.UpdateImageRepository(&api.ImageRepository{
|
| 497 | 497 |
JSONBase: kubeapi.JSONBase{ID: "foo", ResourceVersion: resp.Node.ModifiedIndex},
|
| ... | ... |
@@ -562,7 +563,7 @@ func TestEtcdWatchImageRepositories(t *testing.T) {
|
| 562 | 562 |
fakeClient.WaitForWatchCompletion() |
| 563 | 563 |
|
| 564 | 564 |
repo := &api.ImageRepository{JSONBase: kubeapi.JSONBase{ID: "foo"}}
|
| 565 |
- repoBytes, _ := runtime.Codec.Encode(repo) |
|
| 565 |
+ repoBytes, _ := latest.Codec.Encode(repo) |
|
| 566 | 566 |
fakeClient.WatchResponse <- &etcd.Response{
|
| 567 | 567 |
Action: "set", |
| 568 | 568 |
Node: &etcd.Node{
|
| ... | ... |
@@ -21,7 +21,7 @@ func TestListImagesError(t *testing.T) {
|
| 21 | 21 |
registry: mockRegistry, |
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 |
- images, err := storage.List(nil) |
|
| 24 |
+ images, err := storage.List(nil, nil) |
|
| 25 | 25 |
if err != mockRegistry.Err {
|
| 26 | 26 |
t.Errorf("Expected %#v, Got %#v", mockRegistry.Err, err)
|
| 27 | 27 |
} |
| ... | ... |
@@ -41,7 +41,7 @@ func TestListImagesEmptyList(t *testing.T) {
|
| 41 | 41 |
registry: mockRegistry, |
| 42 | 42 |
} |
| 43 | 43 |
|
| 44 |
- images, err := storage.List(labels.Everything()) |
|
| 44 |
+ images, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 45 | 45 |
if err != nil {
|
| 46 | 46 |
t.Errorf("Unexpected non-nil error: %#v", err)
|
| 47 | 47 |
} |
| ... | ... |
@@ -72,7 +72,7 @@ func TestListImagesPopulatedList(t *testing.T) {
|
| 72 | 72 |
registry: mockRegistry, |
| 73 | 73 |
} |
| 74 | 74 |
|
| 75 |
- list, err := storage.List(labels.Everything()) |
|
| 75 |
+ list, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 76 | 76 |
if err != nil {
|
| 77 | 77 |
t.Errorf("Unexpected non-nil error: %#v", err)
|
| 78 | 78 |
} |
| ... | ... |
@@ -87,7 +87,7 @@ func TestListImagesPopulatedList(t *testing.T) {
|
| 87 | 87 |
func TestCreateImageBadObject(t *testing.T) {
|
| 88 | 88 |
storage := REST{}
|
| 89 | 89 |
|
| 90 |
- channel, err := storage.Create("hello")
|
|
| 90 |
+ channel, err := storage.Create(&api.ImageList{})
|
|
| 91 | 91 |
if channel != nil {
|
| 92 | 92 |
t.Errorf("Expected nil, got %v", channel)
|
| 93 | 93 |
} |
| ... | ... |
@@ -54,7 +54,7 @@ func TestListImageRepositoriesError(t *testing.T) {
|
| 54 | 54 |
registry: mockRepositoryRegistry, |
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 |
- imageRepositories, err := storage.List(nil) |
|
| 57 |
+ imageRepositories, err := storage.List(nil, nil) |
|
| 58 | 58 |
if err != mockRepositoryRegistry.Err {
|
| 59 | 59 |
t.Errorf("Expected %#v, Got %#v", mockRepositoryRegistry.Err, err)
|
| 60 | 60 |
} |
| ... | ... |
@@ -74,7 +74,7 @@ func TestListImageRepositoriesEmptyList(t *testing.T) {
|
| 74 | 74 |
registry: mockRepositoryRegistry, |
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 |
- imageRepositories, err := storage.List(labels.Everything()) |
|
| 77 |
+ imageRepositories, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 78 | 78 |
if err != nil {
|
| 79 | 79 |
t.Errorf("Unexpected non-nil error: %#v", err)
|
| 80 | 80 |
} |
| ... | ... |
@@ -105,7 +105,7 @@ func TestListImageRepositoriesPopulatedList(t *testing.T) {
|
| 105 | 105 |
registry: mockRepositoryRegistry, |
| 106 | 106 |
} |
| 107 | 107 |
|
| 108 |
- list, err := storage.List(labels.Everything()) |
|
| 108 |
+ list, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 109 | 109 |
if err != nil {
|
| 110 | 110 |
t.Errorf("Unexpected non-nil error: %#v", err)
|
| 111 | 111 |
} |
| ... | ... |
@@ -120,7 +120,7 @@ func TestListImageRepositoriesPopulatedList(t *testing.T) {
|
| 120 | 120 |
func TestCreateImageRepositoryBadObject(t *testing.T) {
|
| 121 | 121 |
storage := REST{}
|
| 122 | 122 |
|
| 123 |
- channel, err := storage.Create("hello")
|
|
| 123 |
+ channel, err := storage.Create(&api.ImageList{})
|
|
| 124 | 124 |
if channel != nil {
|
| 125 | 125 |
t.Errorf("Expected nil, got %v", channel)
|
| 126 | 126 |
} |
| ... | ... |
@@ -173,7 +173,7 @@ func TestCreateRegistryErrorSaving(t *testing.T) {
|
| 173 | 173 |
func TestUpdateImageRepositoryBadObject(t *testing.T) {
|
| 174 | 174 |
storage := REST{}
|
| 175 | 175 |
|
| 176 |
- channel, err := storage.Update("hello")
|
|
| 176 |
+ channel, err := storage.Update(&api.ImageList{})
|
|
| 177 | 177 |
if channel != nil {
|
| 178 | 178 |
t.Errorf("Expected nil, got %v", channel)
|
| 179 | 179 |
} |
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" |
| 11 | 11 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" |
| 12 | 12 |
"github.com/fsouza/go-dockerclient" |
| 13 |
+ |
|
| 13 | 14 |
"github.com/openshift/origin/pkg/image/api" |
| 14 | 15 |
"github.com/openshift/origin/pkg/image/registry/test" |
| 15 | 16 |
) |
| ... | ... |
@@ -36,7 +37,7 @@ func TestListImageRepositoryMappings(t *testing.T) {
|
| 36 | 36 |
imageRepositoryRegistry := test.NewImageRepositoryRegistry() |
| 37 | 37 |
storage := &REST{imageRegistry, imageRepositoryRegistry}
|
| 38 | 38 |
|
| 39 |
- list, err := storage.List(labels.Everything()) |
|
| 39 |
+ list, err := storage.List(labels.Everything(), labels.Everything()) |
|
| 40 | 40 |
if list != nil {
|
| 41 | 41 |
t.Errorf("Unexpected non-nil list %#v", list)
|
| 42 | 42 |
} |
| ... | ... |
@@ -70,7 +71,7 @@ func TestUpdateImageRepositoryMapping(t *testing.T) {
|
| 70 | 70 |
imageRepositoryRegistry := test.NewImageRepositoryRegistry() |
| 71 | 71 |
storage := &REST{imageRegistry, imageRepositoryRegistry}
|
| 72 | 72 |
|
| 73 |
- channel, err := storage.Update("repo1")
|
|
| 73 |
+ channel, err := storage.Update(&api.ImageList{})
|
|
| 74 | 74 |
if channel != nil {
|
| 75 | 75 |
t.Errorf("Unexpected non-nil channel %#v", channel)
|
| 76 | 76 |
} |
| ... | ... |
@@ -87,7 +88,7 @@ func TestCreateImageRepositoryMappingBadObject(t *testing.T) {
|
| 87 | 87 |
imageRepositoryRegistry := test.NewImageRepositoryRegistry() |
| 88 | 88 |
storage := &REST{imageRegistry, imageRepositoryRegistry}
|
| 89 | 89 |
|
| 90 |
- channel, err := storage.Create("bad object")
|
|
| 90 |
+ channel, err := storage.Create(&api.ImageList{})
|
|
| 91 | 91 |
if channel != nil {
|
| 92 | 92 |
t.Errorf("Unexpected non-nil channel %#v", channel)
|
| 93 | 93 |
} |
| ... | ... |
@@ -9,7 +9,7 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
func TestNewStorageInvalidType(t *testing.T) {
|
| 11 | 11 |
storage := NewStorage() |
| 12 |
- _, err := storage.Create("string")
|
|
| 12 |
+ _, err := storage.Create(&kubeapi.Pod{})
|
|
| 13 | 13 |
if err == nil {
|
| 14 | 14 |
t.Errorf("Expected type error.")
|
| 15 | 15 |
} |
| ... | ... |
@@ -18,7 +18,7 @@ func TestNewStorageInvalidType(t *testing.T) {
|
| 18 | 18 |
func TestStorageNotImplementedFunctions(t *testing.T) {
|
| 19 | 19 |
storage := NewStorage() |
| 20 | 20 |
|
| 21 |
- if _, err := storage.List(nil); err == nil {
|
|
| 21 |
+ if _, err := storage.List(nil, nil); err == nil {
|
|
| 22 | 22 |
t.Errorf("Expected not implemented error.")
|
| 23 | 23 |
} |
| 24 | 24 |
|
| ... | ... |
@@ -8,9 +8,10 @@ import ( |
| 8 | 8 |
"testing" |
| 9 | 9 |
"time" |
| 10 | 10 |
|
| 11 |
- _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/v1beta1" |
|
| 11 |
+ _ "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" |
|
| 12 | 12 |
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" |
| 13 | 13 |
|
| 14 |
+ "github.com/openshift/origin/pkg/api/latest" |
|
| 14 | 15 |
"github.com/openshift/origin/pkg/template/api" |
| 15 | 16 |
. "github.com/openshift/origin/pkg/template/generator" |
| 16 | 17 |
) |
| ... | ... |
@@ -59,7 +60,7 @@ func TestEmptyGenerators(t *testing.T) {
|
| 59 | 59 |
func ExampleProcessTemplateParameters() {
|
| 60 | 60 |
var template api.Template |
| 61 | 61 |
jsonData, _ := ioutil.ReadFile("../../examples/guestbook/template.json")
|
| 62 |
- json.Unmarshal(jsonData, &template) |
|
| 62 |
+ latest.Codec.DecodeInto(jsonData, &template) |
|
| 63 | 63 |
|
| 64 | 64 |
generators := map[string]Generator{
|
| 65 | 65 |
"expression": NewExpressionValueGenerator(rand.New(rand.NewSource(1337))), |
| ... | ... |
@@ -74,8 +75,8 @@ func ExampleProcessTemplateParameters() {
|
| 74 | 74 |
// Reset the timestamp for the output comparison |
| 75 | 75 |
config.CreationTimestamp = util.Date(1980, 1, 1, 0, 0, 0, 0, time.UTC) |
| 76 | 76 |
|
| 77 |
- result, _ := json.Marshal(config) |
|
| 77 |
+ result, _ := latest.Codec.Encode(config) |
|
| 78 | 78 |
fmt.Println(string(result)) |
| 79 | 79 |
// Output: |
| 80 |
- // {"kind":"Config","id":"guestbook","creationTimestamp":"1980-01-01T00:00:00Z","name":"guestbook-example","description":"Example shows how to build a simple multi-tier application using Kubernetes and Docker","items":[{"kind":"Service","id":"frontend","creationTimestamp":null,"apiVersion":"v1beta1","port":5432,"selector":{"name":"frontend"},"containerPort":0},{"kind":"Service","id":"redismaster","creationTimestamp":null,"apiVersion":"v1beta1","port":10000,"selector":{"name":"redis-master"},"containerPort":0},{"kind":"Service","id":"redisslave","creationTimestamp":null,"apiVersion":"v1beta1","port":10001,"labels":{"name":"redisslave"},"selector":{"name":"redisslave"},"containerPort":0},{"kind":"Pod","id":"redis-master-2","creationTimestamp":null,"apiVersion":"v1beta1","labels":{"name":"redis-master"},"desiredState":{"manifest":{"version":"v1beta1","id":"redis-master-2","volumes":null,"containers":[{"name":"master","image":"dockerfile/redis","ports":[{"containerPort":6379}],"env":[{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}]}]},"restartpolicy":{}},"currentState":{"manifest":{"version":"","id":"","volumes":null,"containers":null},"restartpolicy":{}}},{"kind":"ReplicationController","id":"frontendController","creationTimestamp":null,"apiVersion":"v1beta1","desiredState":{"replicas":3,"replicaSelector":{"name":"frontend"},"podTemplate":{"desiredState":{"manifest":{"version":"v1beta1","id":"frontendController","volumes":null,"containers":[{"name":"php-redis","image":"brendanburns/php-redis","ports":[{"hostPort":8000,"containerPort":80}],"env":[{"name":"ADMIN_USERNAME","key":"ADMIN_USERNAME","value":"adminQ3H"},{"name":"ADMIN_PASSWORD","key":"ADMIN_PASSWORD","value":"dwNJiJwW"},{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}]}]},"restartpolicy":{}},"labels":{"name":"frontend"}}},"labels":{"name":"frontend"}},{"kind":"ReplicationController","id":"redisSlaveController","creationTimestamp":null,"apiVersion":"v1beta1","desiredState":{"replicas":2,"replicaSelector":{"name":"redisslave"},"podTemplate":{"desiredState":{"manifest":{"version":"v1beta1","id":"redisSlaveController","volumes":null,"containers":[{"name":"slave","image":"brendanburns/redis-slave","ports":[{"hostPort":6380,"containerPort":6379}],"env":[{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}]}]},"restartpolicy":{}},"labels":{"name":"redisslave"}}},"labels":{"name":"redisslave"}}]}
|
|
| 80 |
+ //{"kind":"Config","id":"guestbook","creationTimestamp":"1980-01-01T00:00:00Z","apiVersion":"v1beta1","name":"guestbook-example","description":"Example shows how to build a simple multi-tier application using Kubernetes and Docker","items":[{"kind":"Service","id":"frontend","creationTimestamp":null,"apiVersion":"v1beta1","port":5432,"selector":{"name":"frontend"},"containerPort":0},{"kind":"Service","id":"redismaster","creationTimestamp":null,"apiVersion":"v1beta1","port":10000,"selector":{"name":"redis-master"},"containerPort":0},{"kind":"Service","id":"redisslave","creationTimestamp":null,"apiVersion":"v1beta1","port":10001,"labels":{"name":"redisslave"},"selector":{"name":"redisslave"},"containerPort":0},{"kind":"Pod","id":"redis-master-2","creationTimestamp":null,"apiVersion":"v1beta1","labels":{"name":"redis-master"},"desiredState":{"manifest":{"version":"v1beta1","id":"redis-master-2","volumes":null,"containers":[{"name":"master","image":"dockerfile/redis","ports":[{"containerPort":6379}],"env":[{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}]}],"restartPolicy":{}}},"currentState":{"manifest":{"version":"","id":"","volumes":null,"containers":null,"restartPolicy":{}}}},{"kind":"ReplicationController","id":"frontendController","creationTimestamp":null,"apiVersion":"v1beta1","desiredState":{"replicas":3,"replicaSelector":{"name":"frontend"},"podTemplate":{"desiredState":{"manifest":{"version":"v1beta1","id":"frontendController","volumes":null,"containers":[{"name":"php-redis","image":"brendanburns/php-redis","ports":[{"hostPort":8000,"containerPort":80}],"env":[{"name":"ADMIN_USERNAME","key":"ADMIN_USERNAME","value":"adminQ3H"},{"name":"ADMIN_PASSWORD","key":"ADMIN_PASSWORD","value":"dwNJiJwW"},{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}]}],"restartPolicy":{}}},"labels":{"name":"frontend"}}},"currentState":{"replicas":0,"podTemplate":{"desiredState":{"manifest":{"version":"","id":"","volumes":null,"containers":null,"restartPolicy":{}}}}},"labels":{"name":"frontend"}},{"kind":"ReplicationController","id":"redisSlaveController","creationTimestamp":null,"apiVersion":"v1beta1","desiredState":{"replicas":2,"replicaSelector":{"name":"redisslave"},"podTemplate":{"desiredState":{"manifest":{"version":"v1beta1","id":"redisSlaveController","volumes":null,"containers":[{"name":"slave","image":"brendanburns/redis-slave","ports":[{"hostPort":6380,"containerPort":6379}],"env":[{"name":"REDIS_PASSWORD","key":"REDIS_PASSWORD","value":"P8vxbV4C"}]}],"restartPolicy":{}}},"labels":{"name":"redisslave"}}},"currentState":{"replicas":0,"podTemplate":{"desiredState":{"manifest":{"version":"","id":"","volumes":null,"containers":null,"restartPolicy":{}}}}},"labels":{"name":"redisslave"}}]}
|
|
| 81 | 81 |
} |