| ... | ... |
@@ -15,7 +15,6 @@ import ( |
| 15 | 15 |
"k8s.io/kubernetes/pkg/runtime" |
| 16 | 16 |
"k8s.io/kubernetes/pkg/util/yaml" |
| 17 | 17 |
|
| 18 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 19 | 18 |
"github.com/openshift/origin/pkg/api/validation" |
| 20 | 19 |
buildapi "github.com/openshift/origin/pkg/build/api" |
| 21 | 20 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| ... | ... |
@@ -23,6 +22,11 @@ import ( |
| 23 | 23 |
projectapi "github.com/openshift/origin/pkg/project/api" |
| 24 | 24 |
routeapi "github.com/openshift/origin/pkg/route/api" |
| 25 | 25 |
templateapi "github.com/openshift/origin/pkg/template/api" |
| 26 |
+ |
|
| 27 |
+ // install all APIs |
|
| 28 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 29 |
+ _ "k8s.io/kubernetes/pkg/api/install" |
|
| 30 |
+ _ "k8s.io/kubernetes/pkg/apis/extensions/install" |
|
| 26 | 31 |
) |
| 27 | 32 |
|
| 28 | 33 |
type mockService struct{}
|
| ... | ... |
@@ -139,7 +143,7 @@ func TestExampleObjectSchemas(t *testing.T) {
|
| 139 | 139 |
t.Logf("%q is skipped", path)
|
| 140 | 140 |
return |
| 141 | 141 |
} |
| 142 |
- if err := latest.Codec.DecodeInto(data, expectedType); err != nil {
|
|
| 142 |
+ if err := runtime.DecodeInto(kapi.Codecs.UniversalDecoder(), data, expectedType); err != nil {
|
|
| 143 | 143 |
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
| 144 | 144 |
return |
| 145 | 145 |
} |
| ... | ... |
@@ -189,7 +193,7 @@ func validateObject(path string, obj runtime.Object, t *testing.T) {
|
| 189 | 189 |
|
| 190 | 190 |
case *kapi.List, *imageapi.ImageStreamList: |
| 191 | 191 |
if list, err := meta.ExtractList(typedObj); err == nil {
|
| 192 |
- runtime.DecodeList(list, kapi.Scheme) |
|
| 192 |
+ runtime.DecodeList(list, kapi.Codecs.UniversalDecoder()) |
|
| 193 | 193 |
for i := range list {
|
| 194 | 194 |
validateObject(path, list[i], t) |
| 195 | 195 |
} |
| ... | ... |
@@ -21,7 +21,7 @@ var OldestVersion = unversioned.GroupVersion{Group: "", Version: "v1beta3"}
|
| 21 | 21 |
// may be assumed to be most preferred to least preferred, and clients may |
| 22 | 22 |
// choose to prefer the earlier items in the list over the latter items when presented |
| 23 | 23 |
// with a set of versions to choose. |
| 24 |
-var Versions = []unversioned.GroupVersion{unversioned.GroupVersion{Group: "", Version: "v1"}, unversioned.GroupVersion{Group: "", Version: "v1beta3"}}
|
|
| 24 |
+var Versions = []unversioned.GroupVersion{{Group: "", Version: "v1"}, {Group: "", Version: "v1beta3"}}
|
|
| 25 | 25 |
|
| 26 | 26 |
// originTypes are the hardcoded types defined by the OpenShift API. |
| 27 | 27 |
var originTypes map[unversioned.GroupVersionKind]bool |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 | 6 |
kapi "k8s.io/kubernetes/pkg/api" |
| 7 |
+ _ "k8s.io/kubernetes/pkg/api/install" |
|
| 7 | 8 |
"k8s.io/kubernetes/pkg/api/meta" |
| 8 | 9 |
"k8s.io/kubernetes/pkg/apimachinery/registered" |
| 9 | 10 |
|
| ... | ... |
@@ -26,7 +27,7 @@ func TestRESTRootScope(t *testing.T) {
|
| 26 | 26 |
func TestResourceToKind(t *testing.T) {
|
| 27 | 27 |
// Ensure we resolve to latest.Version |
| 28 | 28 |
expectedGVK := Version.WithKind("User")
|
| 29 |
- gvk, err := kapi.RESTMapper.KindFor(userapi.SchemeGroupVersion.WithResource("user"))
|
|
| 29 |
+ gvk, err := kapi.RESTMapper.KindFor(userapi.SchemeGroupVersion.WithResource("User"))
|
|
| 30 | 30 |
if err != nil {
|
| 31 | 31 |
t.Fatalf("Unexpected error: %v", err)
|
| 32 | 32 |
} |
| ... | ... |
@@ -27,6 +27,10 @@ import ( |
| 27 | 27 |
) |
| 28 | 28 |
|
| 29 | 29 |
func init() {
|
| 30 |
+ RegisterAll() |
|
| 31 |
+} |
|
| 32 |
+ |
|
| 33 |
+func RegisterAll() {
|
|
| 30 | 34 |
Validator.Register(&authorizationapi.SubjectAccessReview{}, authorizationvalidation.ValidateSubjectAccessReview, nil)
|
| 31 | 35 |
Validator.Register(&authorizationapi.ResourceAccessReview{}, authorizationvalidation.ValidateResourceAccessReview, nil)
|
| 32 | 36 |
Validator.Register(&authorizationapi.LocalSubjectAccessReview{}, authorizationvalidation.ValidateLocalSubjectAccessReview, nil)
|
| ... | ... |
@@ -81,7 +81,7 @@ func TestConflictingNamespace(t *testing.T) {
|
| 81 | 81 |
if err == nil {
|
| 82 | 82 |
t.Fatalf("unexpected non-error: %v", err)
|
| 83 | 83 |
} |
| 84 |
- if e, a := "namespace: invalid value 'foo', Details: namespace must be: bar", err.Error(); e != a {
|
|
| 84 |
+ if e, a := `namespace: Invalid value: "foo": namespace must be: bar`, err.Error(); e != a {
|
|
| 85 | 85 |
t.Fatalf("expected %v, got %v", e, a)
|
| 86 | 86 |
} |
| 87 | 87 |
} |
| ... | ... |
@@ -89,7 +89,7 @@ func TestConflictingNamespace(t *testing.T) {
|
| 89 | 89 |
if err == nil {
|
| 90 | 90 |
t.Fatalf("unexpected non-error: %v", err)
|
| 91 | 91 |
} |
| 92 |
- if e, a := "namespace: invalid value 'foo', Details: namespace must be: bar", err.Error(); e != a {
|
|
| 92 |
+ if e, a := `namespace: Invalid value: "foo": namespace must be: bar`, err.Error(); e != a {
|
|
| 93 | 93 |
t.Fatalf("expected %v, got %v", e, a)
|
| 94 | 94 |
} |
| 95 | 95 |
} |
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"k8s.io/kubernetes/pkg/util/sets" |
| 11 | 11 |
|
| 12 | 12 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
| 13 |
+ _ "github.com/openshift/origin/pkg/authorization/api/install" |
|
| 13 | 14 |
clusterpolicyregistry "github.com/openshift/origin/pkg/authorization/registry/clusterpolicy" |
| 14 | 15 |
roleregistry "github.com/openshift/origin/pkg/authorization/registry/role" |
| 15 | 16 |
"github.com/openshift/origin/pkg/authorization/registry/test" |
| ... | ... |
@@ -13,6 +13,7 @@ import ( |
| 13 | 13 |
"k8s.io/kubernetes/pkg/util/sets" |
| 14 | 14 |
|
| 15 | 15 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
| 16 |
+ _ "github.com/openshift/origin/pkg/authorization/api/install" |
|
| 16 | 17 |
clusterpolicyregistry "github.com/openshift/origin/pkg/authorization/registry/clusterpolicy" |
| 17 | 18 |
clusterpolicybindingregistry "github.com/openshift/origin/pkg/authorization/registry/clusterpolicybinding" |
| 18 | 19 |
rolebindingregistry "github.com/openshift/origin/pkg/authorization/registry/rolebinding" |
| ... | ... |
@@ -165,7 +165,7 @@ func TestBuildAdmission(t *testing.T) {
|
| 165 | 165 |
|
| 166 | 166 |
type fakeObject struct{}
|
| 167 | 167 |
|
| 168 |
-func (*fakeObject) IsAnAPIObject() {}
|
|
| 168 |
+func (*fakeObject) GetObjectKind() unversioned.ObjectKind { return nil }
|
|
| 169 | 169 |
|
| 170 | 170 |
func fakeUser() user.Info {
|
| 171 | 171 |
return &user.DefaultInfo{
|
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"k8s.io/kubernetes/pkg/conversion/queryparams" |
| 9 | 9 |
|
| 10 | 10 |
newer "github.com/openshift/origin/pkg/build/api" |
| 11 |
+ _ "github.com/openshift/origin/pkg/build/api/install" |
|
| 11 | 12 |
older "github.com/openshift/origin/pkg/build/api/v1" |
| 12 | 13 |
testutil "github.com/openshift/origin/test/util/api" |
| 13 | 14 |
) |
| ... | ... |
@@ -8,15 +8,17 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
kapi "k8s.io/kubernetes/pkg/api" |
| 10 | 10 |
"k8s.io/kubernetes/pkg/api/resource" |
| 11 |
+ "k8s.io/kubernetes/pkg/apimachinery/registered" |
|
| 12 |
+ "k8s.io/kubernetes/pkg/runtime" |
|
| 11 | 13 |
|
| 12 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 13 | 14 |
buildapi "github.com/openshift/origin/pkg/build/api" |
| 15 |
+ _ "github.com/openshift/origin/pkg/build/api/install" |
|
| 14 | 16 |
buildutil "github.com/openshift/origin/pkg/build/util" |
| 15 | 17 |
) |
| 16 | 18 |
|
| 17 | 19 |
func TestCustomCreateBuildPod(t *testing.T) {
|
| 18 | 20 |
strategy := CustomBuildStrategy{
|
| 19 |
- Codec: latest.Codec, |
|
| 21 |
+ Codec: kapi.Codecs.LegacyCodec(buildapi.SchemeGroupVersion), |
|
| 20 | 22 |
} |
| 21 | 23 |
|
| 22 | 24 |
expectedBad := mockCustomBuild(false) |
| ... | ... |
@@ -67,7 +69,7 @@ func TestCustomCreateBuildPod(t *testing.T) {
|
| 67 | 67 |
if len(actual.Spec.Volumes) != 3 {
|
| 68 | 68 |
t.Fatalf("Expected 3 volumes in Build pod, got %d", len(actual.Spec.Volumes))
|
| 69 | 69 |
} |
| 70 |
- buildJSON, _ := latest.Codec.Encode(expected) |
|
| 70 |
+ buildJSON, _ := runtime.Encode(kapi.Codecs.LegacyCodec(buildapi.SchemeGroupVersion), expected) |
|
| 71 | 71 |
errorCases := map[int][]string{
|
| 72 | 72 |
0: {"BUILD", string(buildJSON)},
|
| 73 | 73 |
} |
| ... | ... |
@@ -92,7 +94,7 @@ func TestCustomCreateBuildPod(t *testing.T) {
|
| 92 | 92 |
|
| 93 | 93 |
func TestCustomCreateBuildPodExpectedForcePull(t *testing.T) {
|
| 94 | 94 |
strategy := CustomBuildStrategy{
|
| 95 |
- Codec: latest.Codec, |
|
| 95 |
+ Codec: kapi.Codecs.LegacyCodec(buildapi.SchemeGroupVersion), |
|
| 96 | 96 |
} |
| 97 | 97 |
|
| 98 | 98 |
expected := mockCustomBuild(true) |
| ... | ... |
@@ -108,10 +110,10 @@ func TestCustomCreateBuildPodExpectedForcePull(t *testing.T) {
|
| 108 | 108 |
|
| 109 | 109 |
func TestCustomCreateBuildPodWithCustomCodec(t *testing.T) {
|
| 110 | 110 |
strategy := CustomBuildStrategy{
|
| 111 |
- Codec: latest.Codec, |
|
| 111 |
+ Codec: kapi.Codecs.LegacyCodec(buildapi.SchemeGroupVersion), |
|
| 112 | 112 |
} |
| 113 | 113 |
|
| 114 |
- for _, version := range latest.Versions {
|
|
| 114 |
+ for _, version := range registered.GroupOrDie(buildapi.GroupName).GroupVersions {
|
|
| 115 | 115 |
// Create new Build specification and modify Spec API version |
| 116 | 116 |
build := mockCustomBuild(false) |
| 117 | 117 |
build.Spec.Strategy.CustomStrategy.BuildAPIVersion = fmt.Sprintf("%s/%s", version.Group, version.Version)
|
| ... | ... |
@@ -6,16 +6,17 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
kapi "k8s.io/kubernetes/pkg/api" |
| 8 | 8 |
"k8s.io/kubernetes/pkg/api/resource" |
| 9 |
+ "k8s.io/kubernetes/pkg/runtime" |
|
| 9 | 10 |
|
| 10 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 11 | 11 |
buildapi "github.com/openshift/origin/pkg/build/api" |
| 12 |
+ _ "github.com/openshift/origin/pkg/build/api/install" |
|
| 12 | 13 |
buildutil "github.com/openshift/origin/pkg/build/util" |
| 13 | 14 |
) |
| 14 | 15 |
|
| 15 | 16 |
func TestDockerCreateBuildPod(t *testing.T) {
|
| 16 | 17 |
strategy := DockerBuildStrategy{
|
| 17 | 18 |
Image: "docker-test-image", |
| 18 |
- Codec: latest.Codec, |
|
| 19 |
+ Codec: kapi.Codecs.LegacyCodec(buildapi.SchemeGroupVersion), |
|
| 19 | 20 |
} |
| 20 | 21 |
|
| 21 | 22 |
expected := mockDockerBuild() |
| ... | ... |
@@ -80,7 +81,7 @@ func TestDockerCreateBuildPod(t *testing.T) {
|
| 80 | 80 |
t.Fatalf("Found illegal environment variable 'ILLEGAL' defined on container")
|
| 81 | 81 |
} |
| 82 | 82 |
|
| 83 |
- buildJSON, _ := latest.Codec.Encode(expected) |
|
| 83 |
+ buildJSON, _ := runtime.Encode(kapi.Codecs.LegacyCodec(buildapi.SchemeGroupVersion), expected) |
|
| 84 | 84 |
errorCases := map[int][]string{
|
| 85 | 85 |
0: {"BUILD", string(buildJSON)},
|
| 86 | 86 |
} |
| ... | ... |
@@ -8,9 +8,10 @@ import ( |
| 8 | 8 |
"k8s.io/kubernetes/pkg/admission" |
| 9 | 9 |
kapi "k8s.io/kubernetes/pkg/api" |
| 10 | 10 |
"k8s.io/kubernetes/pkg/api/resource" |
| 11 |
+ "k8s.io/kubernetes/pkg/runtime" |
|
| 11 | 12 |
|
| 12 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 13 | 13 |
buildapi "github.com/openshift/origin/pkg/build/api" |
| 14 |
+ _ "github.com/openshift/origin/pkg/build/api/install" |
|
| 14 | 15 |
buildutil "github.com/openshift/origin/pkg/build/util" |
| 15 | 16 |
) |
| 16 | 17 |
|
| ... | ... |
@@ -47,7 +48,7 @@ func testSTICreateBuildPod(t *testing.T, rootAllowed bool) {
|
| 47 | 47 |
strategy := &SourceBuildStrategy{
|
| 48 | 48 |
Image: "sti-test-image", |
| 49 | 49 |
TempDirectoryCreator: &FakeTempDirCreator{},
|
| 50 |
- Codec: latest.Codec, |
|
| 50 |
+ Codec: kapi.Codecs.LegacyCodec(buildapi.SchemeGroupVersion), |
|
| 51 | 51 |
AdmissionControl: &FakeAdmissionControl{admit: rootAllowed},
|
| 52 | 52 |
} |
| 53 | 53 |
|
| ... | ... |
@@ -128,7 +129,7 @@ func testSTICreateBuildPod(t *testing.T, rootAllowed bool) {
|
| 128 | 128 |
if !foundAllowedUIDs && !rootAllowed {
|
| 129 | 129 |
t.Fatalf("Expected ALLLOWED_UIDS when root is not allowed")
|
| 130 | 130 |
} |
| 131 |
- buildJSON, _ := latest.Codec.Encode(expected) |
|
| 131 |
+ buildJSON, _ := runtime.Encode(kapi.Codecs.LegacyCodec(buildapi.SchemeGroupVersion), expected) |
|
| 132 | 132 |
errorCases := map[int][]string{
|
| 133 | 133 |
0: {"BUILD", string(buildJSON)},
|
| 134 | 134 |
} |
| ... | ... |
@@ -13,6 +13,7 @@ import ( |
| 13 | 13 |
"k8s.io/kubernetes/pkg/runtime" |
| 14 | 14 |
|
| 15 | 15 |
buildapi "github.com/openshift/origin/pkg/build/api" |
| 16 |
+ _ "github.com/openshift/origin/pkg/build/api/install" |
|
| 16 | 17 |
buildutil "github.com/openshift/origin/pkg/build/util" |
| 17 | 18 |
"github.com/openshift/origin/pkg/client/testclient" |
| 18 | 19 |
) |
| ... | ... |
@@ -105,7 +106,7 @@ func actionsAreEqual(a, b ktestclient.Action) bool {
|
| 105 | 105 |
|
| 106 | 106 |
func TestStop(t *testing.T) {
|
| 107 | 107 |
notFound := func() runtime.Object {
|
| 108 |
- return &(kerrors.NewNotFound("BuildConfig", "config").(*kerrors.StatusError).ErrStatus)
|
|
| 108 |
+ return &(kerrors.NewNotFound(buildapi.Resource("BuildConfig"), "config").(*kerrors.StatusError).ErrStatus)
|
|
| 109 | 109 |
} |
| 110 | 110 |
|
| 111 | 111 |
tests := map[string]struct {
|
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"k8s.io/kubernetes/pkg/runtime" |
| 9 | 9 |
|
| 10 | 10 |
buildapi "github.com/openshift/origin/pkg/build/api" |
| 11 |
+ _ "github.com/openshift/origin/pkg/build/api/install" |
|
| 11 | 12 |
"github.com/openshift/origin/pkg/build/generator" |
| 12 | 13 |
mocks "github.com/openshift/origin/pkg/build/generator/test" |
| 13 | 14 |
imageapi "github.com/openshift/origin/pkg/image/api" |
| ... | ... |
@@ -11,7 +11,6 @@ import ( |
| 11 | 11 |
|
| 12 | 12 |
kapi "k8s.io/kubernetes/pkg/api" |
| 13 | 13 |
"k8s.io/kubernetes/pkg/api/rest" |
| 14 |
- "k8s.io/kubernetes/pkg/api/unversioned" |
|
| 15 | 14 |
kubeletclient "k8s.io/kubernetes/pkg/kubelet/client" |
| 16 | 15 |
genericrest "k8s.io/kubernetes/pkg/registry/generic/rest" |
| 17 | 16 |
"k8s.io/kubernetes/pkg/runtime" |
| ... | ... |
@@ -6,13 +6,14 @@ import ( |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"testing" |
| 8 | 8 |
|
| 9 |
+ kapi "k8s.io/kubernetes/pkg/api" |
|
| 9 | 10 |
"k8s.io/kubernetes/pkg/api/errors" |
| 10 | 11 |
"k8s.io/kubernetes/pkg/api/unversioned" |
| 11 |
- "k8s.io/kubernetes/pkg/apimachinery/registered" |
|
| 12 | 12 |
kclient "k8s.io/kubernetes/pkg/client/unversioned" |
| 13 | 13 |
"k8s.io/kubernetes/pkg/runtime" |
| 14 | 14 |
|
| 15 | 15 |
"github.com/openshift/origin/pkg/image/api" |
| 16 |
+ _ "github.com/openshift/origin/pkg/image/api/install" |
|
| 16 | 17 |
) |
| 17 | 18 |
|
| 18 | 19 |
type roundTripFunc func(req *http.Request) (*http.Response, error) |
| ... | ... |
@@ -27,26 +28,26 @@ func TestImageStreamImportUnsupported(t *testing.T) {
|
| 27 | 27 |
errFn func(err error) bool |
| 28 | 28 |
}{
|
| 29 | 29 |
{
|
| 30 |
- status: errors.NewNotFound("", "").(errors.APIStatus).Status(),
|
|
| 30 |
+ status: errors.NewNotFound(api.Resource(""), "").(errors.APIStatus).Status(),
|
|
| 31 | 31 |
errFn: func(err error) bool { return err == ErrImageStreamImportUnsupported },
|
| 32 | 32 |
}, |
| 33 | 33 |
{
|
| 34 |
- status: errors.NewNotFound("Other", "").(errors.APIStatus).Status(),
|
|
| 34 |
+ status: errors.NewNotFound(api.Resource("ImageStreamImport"), "").(errors.APIStatus).Status(),
|
|
| 35 | 35 |
errFn: func(err error) bool { return err != ErrImageStreamImportUnsupported && errors.IsNotFound(err) },
|
| 36 | 36 |
}, |
| 37 | 37 |
{
|
| 38 |
- status: errors.NewConflict("Other", "", nil).(errors.APIStatus).Status(),
|
|
| 38 |
+ status: errors.NewConflict(api.Resource("ImageStreamImport"), "", nil).(errors.APIStatus).Status(),
|
|
| 39 | 39 |
errFn: func(err error) bool { return err != ErrImageStreamImportUnsupported && errors.IsConflict(err) },
|
| 40 | 40 |
}, |
| 41 | 41 |
{
|
| 42 |
- status: errors.NewForbidden("Any", "", nil).(errors.APIStatus).Status(),
|
|
| 42 |
+ status: errors.NewForbidden(api.Resource("ImageStreamImport"), "", nil).(errors.APIStatus).Status(),
|
|
| 43 | 43 |
errFn: func(err error) bool { return err == ErrImageStreamImportUnsupported },
|
| 44 | 44 |
}, |
| 45 | 45 |
} |
| 46 | 46 |
for i, test := range testCases {
|
| 47 | 47 |
c, err := New(&kclient.Config{
|
| 48 | 48 |
Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) {
|
| 49 |
- buf := bytes.NewBuffer([]byte(runtime.EncodeOrDie(registered.GroupOrDie(api.GroupName).Codec, &test.status))) |
|
| 49 |
+ buf := bytes.NewBuffer([]byte(runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(api.SchemeGroupVersion), &test.status))) |
|
| 50 | 50 |
return &http.Response{StatusCode: http.StatusNotFound, Body: ioutil.NopCloser(buf)}, nil
|
| 51 | 51 |
}), |
| 52 | 52 |
}) |
| ... | ... |
@@ -9,11 +9,12 @@ import ( |
| 9 | 9 |
"k8s.io/kubernetes/pkg/runtime" |
| 10 | 10 |
|
| 11 | 11 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 12 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 12 | 13 |
) |
| 13 | 14 |
|
| 14 | 15 |
func TestNewClient(t *testing.T) {
|
| 15 |
- o := testclient.NewObjects(kapi.Scheme, kapi.Scheme) |
|
| 16 |
- if err := testclient.AddObjectsFromPath("../../../test/integration/fixtures/test-deployment-config.yaml", o, kapi.Scheme); err != nil {
|
|
| 16 |
+ o := testclient.NewObjects(kapi.Scheme, kapi.Codecs.UniversalDecoder()) |
|
| 17 |
+ if err := testclient.AddObjectsFromPath("../../../test/integration/fixtures/test-deployment-config.yaml", o, kapi.Codecs.UniversalDecoder()); err != nil {
|
|
| 17 | 18 |
t.Fatal(err) |
| 18 | 19 |
} |
| 19 | 20 |
oc, _ := NewFixtureClients(o) |
| ... | ... |
@@ -37,7 +38,7 @@ func TestNewClient(t *testing.T) {
|
| 37 | 37 |
} |
| 38 | 38 |
|
| 39 | 39 |
func TestErrors(t *testing.T) {
|
| 40 |
- o := testclient.NewObjects(kapi.Scheme, kapi.Scheme) |
|
| 40 |
+ o := testclient.NewObjects(kapi.Scheme, kapi.Codecs.UniversalDecoder()) |
|
| 41 | 41 |
o.Add(&kapi.List{
|
| 42 | 42 |
Items: []runtime.Object{
|
| 43 | 43 |
&(errors.NewNotFound(deployapi.Resource("DeploymentConfigList"), "").(*errors.StatusError).ErrStatus),
|
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"github.com/openshift/origin/pkg/auth/ldaputil" |
| 13 | 13 |
"github.com/openshift/origin/pkg/client/testclient" |
| 14 | 14 |
userapi "github.com/openshift/origin/pkg/user/api" |
| 15 |
+ _ "github.com/openshift/origin/pkg/user/api/install" |
|
| 15 | 16 |
) |
| 16 | 17 |
|
| 17 | 18 |
func TestListAllOpenShiftGroups(t *testing.T) {
|
| ... | ... |
@@ -12,15 +12,21 @@ import ( |
| 12 | 12 |
ktc "k8s.io/kubernetes/pkg/client/unversioned/testclient" |
| 13 | 13 |
"k8s.io/kubernetes/pkg/runtime" |
| 14 | 14 |
|
| 15 |
- api "github.com/openshift/origin/pkg/api/latest" |
|
| 16 | 15 |
tc "github.com/openshift/origin/pkg/client/testclient" |
| 17 | 16 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 18 | 17 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 19 | 18 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 19 |
+ |
|
| 20 |
+ // install all APIs |
|
| 21 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 22 |
+ _ "k8s.io/kubernetes/pkg/api/install" |
|
| 20 | 23 |
) |
| 21 | 24 |
|
| 22 | 25 |
func deploymentFor(config *deployapi.DeploymentConfig, status deployapi.DeploymentStatus) *kapi.ReplicationController {
|
| 23 |
- d, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 26 |
+ d, err := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 27 |
+ if err != nil {
|
|
| 28 |
+ panic(err) |
|
| 29 |
+ } |
|
| 24 | 30 |
d.Annotations[deployapi.DeploymentStatusAnnotation] = string(status) |
| 25 | 31 |
return d |
| 26 | 32 |
} |
| ... | ... |
@@ -235,7 +241,7 @@ func TestCmdDeploy_cancelOk(t *testing.T) {
|
| 235 | 235 |
config := deploytest.OkDeploymentConfig(scenario.version) |
| 236 | 236 |
existingDeployments := &kapi.ReplicationControllerList{}
|
| 237 | 237 |
for _, e := range scenario.existing {
|
| 238 |
- d, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(e.version), api.Codec) |
|
| 238 |
+ d, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(e.version), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 239 | 239 |
d.Annotations[deployapi.DeploymentStatusAnnotation] = string(e.status) |
| 240 | 240 |
existingDeployments.Items = append(existingDeployments.Items, *d) |
| 241 | 241 |
} |
| ... | ... |
@@ -77,7 +77,7 @@ func TestRollbackOptions_findTargetDeployment(t *testing.T) {
|
| 77 | 77 |
existingControllers := &kapi.ReplicationControllerList{}
|
| 78 | 78 |
for _, existing := range test.existing {
|
| 79 | 79 |
config := deploytest.OkDeploymentConfig(existing.version) |
| 80 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 80 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 81 | 81 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(existing.status) |
| 82 | 82 |
existingControllers.Items = append(existingControllers.Items, *deployment) |
| 83 | 83 |
} |
| ... | ... |
@@ -164,9 +164,9 @@ func TestChainDescriber(t *testing.T) {
|
| 164 | 164 |
} |
| 165 | 165 |
|
| 166 | 166 |
for _, test := range tests {
|
| 167 |
- o := ktestclient.NewObjects(kapi.Scheme, kapi.Scheme) |
|
| 167 |
+ o := ktestclient.NewObjects(kapi.Scheme, kapi.Codecs.UniversalDecoder()) |
|
| 168 | 168 |
if len(test.path) > 0 {
|
| 169 |
- if err := ktestclient.AddObjectsFromPath(test.path, o, kapi.Scheme); err != nil {
|
|
| 169 |
+ if err := ktestclient.AddObjectsFromPath(test.path, o, kapi.Codecs.UniversalDecoder()); err != nil {
|
|
| 170 | 170 |
t.Fatal(err) |
| 171 | 171 |
} |
| 172 | 172 |
} |
| ... | ... |
@@ -24,6 +24,11 @@ import ( |
| 24 | 24 |
oauthapi "github.com/openshift/origin/pkg/oauth/api" |
| 25 | 25 |
projectapi "github.com/openshift/origin/pkg/project/api" |
| 26 | 26 |
sdnapi "github.com/openshift/origin/pkg/sdn/api" |
| 27 |
+ |
|
| 28 |
+ // install all APIs |
|
| 29 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 30 |
+ _ "k8s.io/kubernetes/pkg/api/install" |
|
| 31 |
+ _ "k8s.io/kubernetes/pkg/apis/extensions/install" |
|
| 27 | 32 |
) |
| 28 | 33 |
|
| 29 | 34 |
type describeClient struct {
|
| ... | ... |
@@ -136,7 +141,7 @@ func TestDescribers(t *testing.T) {
|
| 136 | 136 |
|
| 137 | 137 |
func TestDeploymentConfigDescriber(t *testing.T) {
|
| 138 | 138 |
config := deployapitest.OkDeploymentConfig(1) |
| 139 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 139 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 140 | 140 |
podList := &kapi.PodList{}
|
| 141 | 141 |
eventList := &kapi.EventList{}
|
| 142 | 142 |
deploymentList := &kapi.ReplicationControllerList{}
|
| ... | ... |
@@ -286,9 +286,9 @@ func TestProjectStatus(t *testing.T) {
|
| 286 | 286 |
} |
| 287 | 287 |
return time.Now() |
| 288 | 288 |
} |
| 289 |
- o := ktestclient.NewObjects(kapi.Scheme, kapi.Scheme) |
|
| 289 |
+ o := ktestclient.NewObjects(kapi.Scheme, kapi.Codecs.UniversalDecoder()) |
|
| 290 | 290 |
if len(test.Path) > 0 {
|
| 291 |
- if err := ktestclient.AddObjectsFromPath(test.Path, o, kapi.Scheme); err != nil {
|
|
| 291 |
+ if err := ktestclient.AddObjectsFromPath(test.Path, o, kapi.Codecs.UniversalDecoder()); err != nil {
|
|
| 292 | 292 |
t.Fatal(err) |
| 293 | 293 |
} |
| 294 | 294 |
} |
| ... | ... |
@@ -12,6 +12,10 @@ import ( |
| 12 | 12 |
scalertest "github.com/openshift/origin/pkg/deploy/scaler/test" |
| 13 | 13 |
"github.com/openshift/origin/pkg/deploy/strategy" |
| 14 | 14 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 15 |
+ |
|
| 16 |
+ // install all APIs |
|
| 17 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 18 |
+ _ "k8s.io/kubernetes/pkg/api/install" |
|
| 15 | 19 |
) |
| 16 | 20 |
|
| 17 | 21 |
func TestDeployer_getDeploymentFail(t *testing.T) {
|
| ... | ... |
@@ -190,7 +194,7 @@ func TestDeployer_deployScenarios(t *testing.T) {
|
| 190 | 190 |
} |
| 191 | 191 |
|
| 192 | 192 |
func mkdeployment(version int, status deployapi.DeploymentStatus) *kapi.ReplicationController {
|
| 193 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codec) |
|
| 193 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 194 | 194 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(status) |
| 195 | 195 |
return deployment |
| 196 | 196 |
} |
| ... | ... |
@@ -22,7 +22,7 @@ var OldestVersion = unversioned.GroupVersion{Group: "", Version: "v1"}
|
| 22 | 22 |
// may be assumed to be least feature rich to most feature rich, and clients may |
| 23 | 23 |
// choose to prefer the latter items in the list over the former items when presented |
| 24 | 24 |
// with a set of versions to choose. |
| 25 |
-var Versions = []unversioned.GroupVersion{unversioned.GroupVersion{Group: "", Version: "v1"}}
|
|
| 25 |
+var Versions = []unversioned.GroupVersion{{Group: "", Version: "v1"}}
|
|
| 26 | 26 |
|
| 27 | 27 |
var Codec = serializer.NewCodecFactory(configapi.Scheme).LegacyCodec(unversioned.GroupVersion{Group: "", Version: "v1"})
|
| 28 | 28 |
|
| ... | ... |
@@ -1,14 +1,21 @@ |
| 1 |
-package v1 |
|
| 1 |
+package v1_test |
|
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 | 6 |
"github.com/ghodss/yaml" |
| 7 |
+ |
|
| 7 | 8 |
"k8s.io/kubernetes/pkg/api/unversioned" |
| 8 | 9 |
"k8s.io/kubernetes/pkg/runtime" |
| 10 |
+ "k8s.io/kubernetes/pkg/runtime/serializer" |
|
| 9 | 11 |
"k8s.io/kubernetes/pkg/util" |
| 10 | 12 |
|
| 11 | 13 |
internal "github.com/openshift/origin/pkg/cmd/server/api" |
| 14 |
+ "github.com/openshift/origin/pkg/cmd/server/api/v1" |
|
| 15 |
+ |
|
| 16 |
+ // install all APIs |
|
| 17 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 18 |
+ _ "k8s.io/kubernetes/pkg/api/install" |
|
| 12 | 19 |
) |
| 13 | 20 |
|
| 14 | 21 |
const ( |
| ... | ... |
@@ -367,10 +374,10 @@ type AdmissionPluginTestConfig struct {
|
| 367 | 367 |
Data string `json:"data"` |
| 368 | 368 |
} |
| 369 | 369 |
|
| 370 |
-func (*AdmissionPluginTestConfig) IsAnAPIObject() {}
|
|
| 370 |
+func (obj *AdmissionPluginTestConfig) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
|
| 371 | 371 |
|
| 372 | 372 |
func TestMasterConfig(t *testing.T) {
|
| 373 |
- internal.Scheme.AddKnownTypes(SchemeGroupVersion, &AdmissionPluginTestConfig{})
|
|
| 373 |
+ internal.Scheme.AddKnownTypes(v1.SchemeGroupVersion, &AdmissionPluginTestConfig{})
|
|
| 374 | 374 |
internal.Scheme.AddKnownTypes(internal.SchemeGroupVersion, &AdmissionPluginTestConfig{})
|
| 375 | 375 |
config := &internal.MasterConfig{
|
| 376 | 376 |
ServingInfo: internal.HTTPServingInfo{
|
| ... | ... |
@@ -382,7 +389,7 @@ func TestMasterConfig(t *testing.T) {
|
| 382 | 382 |
AdmissionConfig: internal.AdmissionConfig{
|
| 383 | 383 |
PluginConfig: map[string]internal.AdmissionPluginConfig{ // test config as an embedded object
|
| 384 | 384 |
"plugin": {
|
| 385 |
- Configuration: runtime.EmbeddedObject{Object: &AdmissionPluginTestConfig{}},
|
|
| 385 |
+ Configuration: &AdmissionPluginTestConfig{},
|
|
| 386 | 386 |
}, |
| 387 | 387 |
}, |
| 388 | 388 |
PluginOrderOverride: []string{"plugin"}, // explicitly set this field because it's omitempty
|
| ... | ... |
@@ -391,17 +398,17 @@ func TestMasterConfig(t *testing.T) {
|
| 391 | 391 |
EtcdConfig: &internal.EtcdConfig{},
|
| 392 | 392 |
OAuthConfig: &internal.OAuthConfig{
|
| 393 | 393 |
IdentityProviders: []internal.IdentityProvider{
|
| 394 |
- {Provider: runtime.EmbeddedObject{Object: &internal.BasicAuthPasswordIdentityProvider{}}},
|
|
| 395 |
- {Provider: runtime.EmbeddedObject{Object: &internal.AllowAllPasswordIdentityProvider{}}},
|
|
| 396 |
- {Provider: runtime.EmbeddedObject{Object: &internal.DenyAllPasswordIdentityProvider{}}},
|
|
| 397 |
- {Provider: runtime.EmbeddedObject{Object: &internal.HTPasswdPasswordIdentityProvider{}}},
|
|
| 398 |
- {Provider: runtime.EmbeddedObject{Object: &internal.LDAPPasswordIdentityProvider{}}},
|
|
| 399 |
- {Provider: runtime.EmbeddedObject{Object: &internal.RequestHeaderIdentityProvider{}}},
|
|
| 400 |
- {Provider: runtime.EmbeddedObject{Object: &internal.KeystonePasswordIdentityProvider{}}},
|
|
| 401 |
- {Provider: runtime.EmbeddedObject{Object: &internal.GitHubIdentityProvider{}}},
|
|
| 402 |
- {Provider: runtime.EmbeddedObject{Object: &internal.GitLabIdentityProvider{}}},
|
|
| 403 |
- {Provider: runtime.EmbeddedObject{Object: &internal.GoogleIdentityProvider{}}},
|
|
| 404 |
- {Provider: runtime.EmbeddedObject{Object: &internal.OpenIDIdentityProvider{}}},
|
|
| 394 |
+ {Provider: &internal.BasicAuthPasswordIdentityProvider{}},
|
|
| 395 |
+ {Provider: &internal.AllowAllPasswordIdentityProvider{}},
|
|
| 396 |
+ {Provider: &internal.DenyAllPasswordIdentityProvider{}},
|
|
| 397 |
+ {Provider: &internal.HTPasswdPasswordIdentityProvider{}},
|
|
| 398 |
+ {Provider: &internal.LDAPPasswordIdentityProvider{}},
|
|
| 399 |
+ {Provider: &internal.RequestHeaderIdentityProvider{}},
|
|
| 400 |
+ {Provider: &internal.KeystonePasswordIdentityProvider{}},
|
|
| 401 |
+ {Provider: &internal.GitHubIdentityProvider{}},
|
|
| 402 |
+ {Provider: &internal.GitLabIdentityProvider{}},
|
|
| 403 |
+ {Provider: &internal.GoogleIdentityProvider{}},
|
|
| 404 |
+ {Provider: &internal.OpenIDIdentityProvider{}},
|
|
| 405 | 405 |
}, |
| 406 | 406 |
SessionConfig: &internal.SessionConfig{},
|
| 407 | 407 |
Templates: &internal.OAuthTemplates{},
|
| ... | ... |
@@ -413,7 +420,7 @@ func TestMasterConfig(t *testing.T) {
|
| 413 | 413 |
AdmissionConfig: internal.AdmissionConfig{
|
| 414 | 414 |
PluginConfig: map[string]internal.AdmissionPluginConfig{ // test config as an embedded object
|
| 415 | 415 |
"plugin": {
|
| 416 |
- Configuration: runtime.EmbeddedObject{Object: &AdmissionPluginTestConfig{}},
|
|
| 416 |
+ Configuration: &AdmissionPluginTestConfig{},
|
|
| 417 | 417 |
}, |
| 418 | 418 |
}, |
| 419 | 419 |
PluginOrderOverride: []string{"plugin"}, // explicitly set this field because the it's omitempty
|
| ... | ... |
@@ -430,7 +437,8 @@ func TestMasterConfig(t *testing.T) {
|
| 430 | 430 |
} |
| 431 | 431 |
|
| 432 | 432 |
func writeYAML(obj runtime.Object) ([]byte, error) {
|
| 433 |
- json, err := Codec.Encode(obj) |
|
| 433 |
+ |
|
| 434 |
+ json, err := runtime.Encode(serializer.NewCodecFactory(internal.Scheme).LegacyCodec(v1.SchemeGroupVersion), obj) |
|
| 434 | 435 |
if err != nil {
|
| 435 | 436 |
return nil, err |
| 436 | 437 |
} |
| ... | ... |
@@ -9,8 +9,8 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"time" |
| 11 | 11 |
|
| 12 |
- kapp "k8s.io/kubernetes/cmd/kube-apiserver/app" |
|
| 13 |
- cmapp "k8s.io/kubernetes/cmd/kube-controller-manager/app" |
|
| 12 |
+ apiserveroptions "k8s.io/kubernetes/cmd/kube-apiserver/app/options" |
|
| 13 |
+ controlleroptions "k8s.io/kubernetes/cmd/kube-controller-manager/app/options" |
|
| 14 | 14 |
kvalidation "k8s.io/kubernetes/pkg/api/validation" |
| 15 | 15 |
"k8s.io/kubernetes/pkg/serviceaccount" |
| 16 | 16 |
knet "k8s.io/kubernetes/pkg/util/net" |
| ... | ... |
@@ -547,11 +547,11 @@ func ValidateRoutingConfig(config api.RoutingConfig, fldPath *field.Path) field. |
| 547 | 547 |
} |
| 548 | 548 |
|
| 549 | 549 |
func ValidateAPIServerExtendedArguments(config api.ExtendedArguments, fldPath *field.Path) field.ErrorList {
|
| 550 |
- return ValidateExtendedArguments(config, kapp.NewAPIServer().AddFlags, fldPath) |
|
| 550 |
+ return ValidateExtendedArguments(config, apiserveroptions.NewAPIServer().AddFlags, fldPath) |
|
| 551 | 551 |
} |
| 552 | 552 |
|
| 553 | 553 |
func ValidateControllerExtendedArguments(config api.ExtendedArguments, fldPath *field.Path) field.ErrorList {
|
| 554 |
- return ValidateExtendedArguments(config, cmapp.NewCMServer().AddFlags, fldPath) |
|
| 554 |
+ return ValidateExtendedArguments(config, controlleroptions.NewCMServer().AddFlags, fldPath) |
|
| 555 | 555 |
} |
| 556 | 556 |
|
| 557 | 557 |
func ValidateAdmissionPluginConfig(pluginConfig map[string]api.AdmissionPluginConfig, fieldPath *field.Path) field.ErrorList {
|
| ... | ... |
@@ -4,7 +4,6 @@ import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 | 6 |
kapi "k8s.io/kubernetes/pkg/api" |
| 7 |
- "k8s.io/kubernetes/pkg/runtime" |
|
| 8 | 7 |
"k8s.io/kubernetes/pkg/util" |
| 9 | 8 |
"k8s.io/kubernetes/pkg/util/validation/field" |
| 10 | 9 |
|
| ... | ... |
@@ -205,15 +204,11 @@ func TestValidateAdmissionPluginConfig(t *testing.T) {
|
| 205 | 205 |
Location: "/some/location", |
| 206 | 206 |
} |
| 207 | 207 |
configOnly := configapi.AdmissionPluginConfig{
|
| 208 |
- Configuration: runtime.EmbeddedObject{
|
|
| 209 |
- Object: &configapi.AdmissionPluginConfig{},
|
|
| 210 |
- }, |
|
| 208 |
+ Configuration: &configapi.NodeConfig{},
|
|
| 211 | 209 |
} |
| 212 | 210 |
locationAndConfig := configapi.AdmissionPluginConfig{
|
| 213 |
- Location: "/some/location", |
|
| 214 |
- Configuration: runtime.EmbeddedObject{
|
|
| 215 |
- Object: &configapi.AdmissionPluginConfig{},
|
|
| 216 |
- }, |
|
| 211 |
+ Location: "/some/location", |
|
| 212 |
+ Configuration: &configapi.NodeConfig{},
|
|
| 217 | 213 |
} |
| 218 | 214 |
bothEmpty := configapi.AdmissionPluginConfig{}
|
| 219 | 215 |
|
| ... | ... |
@@ -5,7 +5,7 @@ import ( |
| 5 | 5 |
"strings" |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 |
- kapp "k8s.io/kubernetes/cmd/kubelet/app" |
|
| 8 |
+ kubeletoptions "k8s.io/kubernetes/cmd/kubelet/app/options" |
|
| 9 | 9 |
"k8s.io/kubernetes/pkg/util/validation/field" |
| 10 | 10 |
|
| 11 | 11 |
"github.com/openshift/origin/pkg/cmd/server/api" |
| ... | ... |
@@ -111,5 +111,5 @@ func ValidateDockerConfig(config api.DockerConfig, fldPath *field.Path) field.Er |
| 111 | 111 |
} |
| 112 | 112 |
|
| 113 | 113 |
func ValidateKubeletExtendedArguments(config api.ExtendedArguments, fldPath *field.Path) field.ErrorList {
|
| 114 |
- return ValidateExtendedArguments(config, kapp.NewKubeletServer().AddFlags, fldPath) |
|
| 114 |
+ return ValidateExtendedArguments(config, kubeletoptions.NewKubeletServer().AddFlags, fldPath) |
|
| 115 | 115 |
} |
| ... | ... |
@@ -45,7 +45,7 @@ func TestValidateServingInfo(t *testing.T) {
|
| 45 | 45 |
CertFile: certFileName, |
| 46 | 46 |
}, |
| 47 | 47 |
}, |
| 48 |
- ExpectedErrors: []string{"keyFile: required"},
|
|
| 48 |
+ ExpectedErrors: []string{"keyFile: Required value"},
|
|
| 49 | 49 |
}, |
| 50 | 50 |
|
| 51 | 51 |
"namedCertificates valid": {
|
| ... | ... |
@@ -68,7 +68,7 @@ func TestValidateServingInfo(t *testing.T) {
|
| 68 | 68 |
{Names: []string{"example.com"}, CertInfo: api.CertInfo{CertFile: certFileName, KeyFile: keyFileName}},
|
| 69 | 69 |
}, |
| 70 | 70 |
}, |
| 71 |
- ExpectedErrors: []string{"namedCertificates: invalid"},
|
|
| 71 |
+ ExpectedErrors: []string{"namedCertificates: Invalid value"},
|
|
| 72 | 72 |
}, |
| 73 | 73 |
|
| 74 | 74 |
"namedCertificates with missing names": {
|
| ... | ... |
@@ -80,7 +80,7 @@ func TestValidateServingInfo(t *testing.T) {
|
| 80 | 80 |
{Names: []string{ /*"example.com"*/ }, CertInfo: api.CertInfo{CertFile: certFileName, KeyFile: keyFileName}},
|
| 81 | 81 |
}, |
| 82 | 82 |
}, |
| 83 |
- ExpectedErrors: []string{"namedCertificates[0].names: required"},
|
|
| 83 |
+ ExpectedErrors: []string{"namedCertificates[0].names: Required value"},
|
|
| 84 | 84 |
}, |
| 85 | 85 |
"namedCertificates with missing key": {
|
| 86 | 86 |
ServingInfo: api.ServingInfo{
|
| ... | ... |
@@ -91,7 +91,7 @@ func TestValidateServingInfo(t *testing.T) {
|
| 91 | 91 |
{Names: []string{"example.com"}, CertInfo: api.CertInfo{CertFile: certFileName /*, KeyFile: keyFileName*/}},
|
| 92 | 92 |
}, |
| 93 | 93 |
}, |
| 94 |
- ExpectedErrors: []string{"namedCertificates[0].keyFile: required"},
|
|
| 94 |
+ ExpectedErrors: []string{"namedCertificates[0].keyFile: Required value"},
|
|
| 95 | 95 |
}, |
| 96 | 96 |
"namedCertificates with duplicate names": {
|
| 97 | 97 |
ServingInfo: api.ServingInfo{
|
| ... | ... |
@@ -103,7 +103,7 @@ func TestValidateServingInfo(t *testing.T) {
|
| 103 | 103 |
{Names: []string{"example.com"}, CertInfo: api.CertInfo{CertFile: certFileName, KeyFile: keyFileName}},
|
| 104 | 104 |
}, |
| 105 | 105 |
}, |
| 106 |
- ExpectedErrors: []string{"namedCertificates[1].names[0]: invalid"},
|
|
| 106 |
+ ExpectedErrors: []string{"namedCertificates[1].names[0]: Invalid value"},
|
|
| 107 | 107 |
}, |
| 108 | 108 |
"namedCertificates with empty name": {
|
| 109 | 109 |
ServingInfo: api.ServingInfo{
|
| ... | ... |
@@ -114,7 +114,7 @@ func TestValidateServingInfo(t *testing.T) {
|
| 114 | 114 |
{Names: []string{""}, CertInfo: api.CertInfo{CertFile: certFileName, KeyFile: keyFileName}},
|
| 115 | 115 |
}, |
| 116 | 116 |
}, |
| 117 |
- ExpectedErrors: []string{"namedCertificates[0].names[0]: required"},
|
|
| 117 |
+ ExpectedErrors: []string{"namedCertificates[0].names[0]: Required value"},
|
|
| 118 | 118 |
}, |
| 119 | 119 |
|
| 120 | 120 |
"namedCertificates with unmatched DNS name": {
|
| ... | ... |
@@ -126,7 +126,7 @@ func TestValidateServingInfo(t *testing.T) {
|
| 126 | 126 |
{Names: []string{"badexample.com"}, CertInfo: api.CertInfo{CertFile: certFileName, KeyFile: keyFileName}},
|
| 127 | 127 |
}, |
| 128 | 128 |
}, |
| 129 |
- ExpectedWarnings: []string{"namedCertificates[0].names[0]: invalid"},
|
|
| 129 |
+ ExpectedWarnings: []string{"namedCertificates[0].names[0]: Invalid value"},
|
|
| 130 | 130 |
}, |
| 131 | 131 |
"namedCertificates with non-DNS names": {
|
| 132 | 132 |
ServingInfo: api.ServingInfo{
|
| ... | ... |
@@ -138,7 +138,7 @@ func TestValidateServingInfo(t *testing.T) {
|
| 138 | 138 |
}, |
| 139 | 139 |
}, |
| 140 | 140 |
ExpectedErrors: []string{
|
| 141 |
- "namedCertificates[0].names[0]: invalid value 'foo bar.com', Details: must be a valid DNS name", |
|
| 141 |
+ `namedCertificates[0].names[0]: Invalid value: "foo bar.com": must be a valid DNS name`, |
|
| 142 | 142 |
}, |
| 143 | 143 |
}, |
| 144 | 144 |
} |
| ... | ... |
@@ -4,7 +4,7 @@ import ( |
| 4 | 4 |
"reflect" |
| 5 | 5 |
"testing" |
| 6 | 6 |
|
| 7 |
- "k8s.io/kubernetes/pkg/master" |
|
| 7 |
+ "k8s.io/kubernetes/pkg/genericapiserver" |
|
| 8 | 8 |
|
| 9 | 9 |
configapi "github.com/openshift/origin/pkg/cmd/server/api" |
| 10 | 10 |
) |
| ... | ... |
@@ -12,27 +12,27 @@ import ( |
| 12 | 12 |
func TestGetAPIGroupVersionOverrides(t *testing.T) {
|
| 13 | 13 |
testcases := map[string]struct {
|
| 14 | 14 |
DisabledVersions map[string][]string |
| 15 |
- ExpectedOverrides map[string]master.APIGroupVersionOverride |
|
| 15 |
+ ExpectedOverrides map[string]genericapiserver.APIGroupVersionOverride |
|
| 16 | 16 |
}{
|
| 17 | 17 |
"empty": {
|
| 18 | 18 |
DisabledVersions: nil, |
| 19 |
- ExpectedOverrides: map[string]master.APIGroupVersionOverride{},
|
|
| 19 |
+ ExpectedOverrides: map[string]genericapiserver.APIGroupVersionOverride{},
|
|
| 20 | 20 |
}, |
| 21 | 21 |
"* -> v1": {
|
| 22 | 22 |
DisabledVersions: map[string][]string{"": {"*"}},
|
| 23 |
- ExpectedOverrides: map[string]master.APIGroupVersionOverride{"api/v1": {Disable: true}},
|
|
| 23 |
+ ExpectedOverrides: map[string]genericapiserver.APIGroupVersionOverride{"api/v1": {Disable: true}},
|
|
| 24 | 24 |
}, |
| 25 | 25 |
"v1": {
|
| 26 | 26 |
DisabledVersions: map[string][]string{"": {"v1"}},
|
| 27 |
- ExpectedOverrides: map[string]master.APIGroupVersionOverride{"api/v1": {Disable: true}},
|
|
| 27 |
+ ExpectedOverrides: map[string]genericapiserver.APIGroupVersionOverride{"api/v1": {Disable: true}},
|
|
| 28 | 28 |
}, |
| 29 | 29 |
"* -> v1beta1": {
|
| 30 | 30 |
DisabledVersions: map[string][]string{"extensions": {"*"}},
|
| 31 |
- ExpectedOverrides: map[string]master.APIGroupVersionOverride{"extensions/v1beta1": {Disable: true}},
|
|
| 31 |
+ ExpectedOverrides: map[string]genericapiserver.APIGroupVersionOverride{"extensions/v1beta1": {Disable: true}},
|
|
| 32 | 32 |
}, |
| 33 | 33 |
"extensions/v1beta1": {
|
| 34 | 34 |
DisabledVersions: map[string][]string{"extensions": {"v1beta1"}},
|
| 35 |
- ExpectedOverrides: map[string]master.APIGroupVersionOverride{"extensions/v1beta1": {Disable: true}},
|
|
| 35 |
+ ExpectedOverrides: map[string]genericapiserver.APIGroupVersionOverride{"extensions/v1beta1": {Disable: true}},
|
|
| 36 | 36 |
}, |
| 37 | 37 |
} |
| 38 | 38 |
|
| ... | ... |
@@ -24,6 +24,8 @@ var KnownUpdateValidationExceptions = []reflect.Type{
|
| 24 | 24 |
// TestValidationRegistration makes sure that any RESTStorage that allows create or update has the correct validation register. |
| 25 | 25 |
// It doesn't guarantee that it's actually called, but it does guarantee that it at least exists |
| 26 | 26 |
func TestValidationRegistration(t *testing.T) {
|
| 27 |
+ validation.RegisterAll() |
|
| 28 |
+ |
|
| 27 | 29 |
config := fakeMasterConfig() |
| 28 | 30 |
|
| 29 | 31 |
storageMap := config.GetRestStorage() |
| ... | ... |
@@ -30,6 +30,9 @@ var admissionPluginsNotUsedByKube = sets.NewString( |
| 30 | 30 |
|
| 31 | 31 |
"NamespaceExists", // superceded by NamespaceLifecycle |
| 32 | 32 |
"InitialResources", // do we want this? https://github.com/kubernetes/kubernetes/blob/master/docs/proposals/initial-resources.md |
| 33 |
+ |
|
| 34 |
+ "PersistentVolumeLabel", // do we want this? disable by default |
|
| 35 |
+ "AlwaysPullImages", // do we want this? disable by default |
|
| 33 | 36 |
) |
| 34 | 37 |
|
| 35 | 38 |
func TestKubeAdmissionControllerUsage(t *testing.T) {
|
| ... | ... |
@@ -16,6 +16,10 @@ import ( |
| 16 | 16 |
|
| 17 | 17 |
configapi "github.com/openshift/origin/pkg/cmd/server/api" |
| 18 | 18 |
configapilatest "github.com/openshift/origin/pkg/cmd/server/api/latest" |
| 19 |
+ |
|
| 20 |
+ // install all APIs |
|
| 21 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 22 |
+ _ "k8s.io/kubernetes/pkg/api/install" |
|
| 19 | 23 |
) |
| 20 | 24 |
|
| 21 | 25 |
// this groups of methods force all the unit tests to share the same config directory |
| ... | ... |
@@ -3,15 +3,16 @@ package util_test |
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 |
+ kapi "k8s.io/kubernetes/pkg/api" |
|
| 6 | 7 |
"k8s.io/kubernetes/pkg/kubectl" |
| 7 | 8 |
|
| 8 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 9 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 9 | 10 |
"github.com/openshift/origin/pkg/cmd/util" |
| 10 | 11 |
"github.com/openshift/origin/pkg/cmd/util/clientcmd" |
| 11 | 12 |
) |
| 12 | 13 |
|
| 13 | 14 |
func TestResolveResource(t *testing.T) {
|
| 14 |
- mapper := clientcmd.ShortcutExpander{RESTMapper: kubectl.ShortcutExpander{RESTMapper: latest.RESTMapper}}
|
|
| 15 |
+ mapper := clientcmd.ShortcutExpander{RESTMapper: kubectl.ShortcutExpander{RESTMapper: kapi.RESTMapper}}
|
|
| 15 | 16 |
|
| 16 | 17 |
tests := []struct {
|
| 17 | 18 |
name string |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
|
| 12 | 12 |
v1 "github.com/openshift/origin/pkg/api/v1" |
| 13 | 13 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 14 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 14 | 15 |
deployv1 "github.com/openshift/origin/pkg/deploy/api/v1" |
| 15 | 16 |
) |
| 16 | 17 |
|
| ... | ... |
@@ -188,12 +189,12 @@ func TestDefaults(t *testing.T) {
|
| 188 | 188 |
} |
| 189 | 189 |
|
| 190 | 190 |
func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
|
| 191 |
- data, err := v1.Codec.Encode(obj) |
|
| 191 |
+ data, err := runtime.Encode(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), obj) |
|
| 192 | 192 |
if err != nil {
|
| 193 | 193 |
t.Errorf("%v\n %#v", err, obj)
|
| 194 | 194 |
return nil |
| 195 | 195 |
} |
| 196 |
- obj2, err := kapi.Codec.Decode(data) |
|
| 196 |
+ obj2, err := runtime.Decode(kapi.Codecs.UniversalDecoder(), data) |
|
| 197 | 197 |
if err != nil {
|
| 198 | 198 |
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
|
| 199 | 199 |
return nil |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
|
| 12 | 12 |
v1 "github.com/openshift/origin/pkg/api/v1beta3" |
| 13 | 13 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 14 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 14 | 15 |
deployv1 "github.com/openshift/origin/pkg/deploy/api/v1beta3" |
| 15 | 16 |
) |
| 16 | 17 |
|
| ... | ... |
@@ -186,12 +187,12 @@ func TestDefaults(t *testing.T) {
|
| 186 | 186 |
} |
| 187 | 187 |
|
| 188 | 188 |
func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
|
| 189 |
- data, err := v1.Codec.Encode(obj) |
|
| 189 |
+ data, err := runtime.Encode(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), obj) |
|
| 190 | 190 |
if err != nil {
|
| 191 | 191 |
t.Errorf("%v\n %#v", err, obj)
|
| 192 | 192 |
return nil |
| 193 | 193 |
} |
| 194 |
- obj2, err := kapi.Codec.Decode(data) |
|
| 194 |
+ obj2, err := runtime.Decode(kapi.Codecs.UniversalDecoder(), data) |
|
| 195 | 195 |
if err != nil {
|
| 196 | 196 |
t.Errorf("%v\nData: %s\nSource: %#v", err, string(data), obj)
|
| 197 | 197 |
return nil |
| ... | ... |
@@ -5,8 +5,8 @@ import ( |
| 5 | 5 |
|
| 6 | 6 |
kapi "k8s.io/kubernetes/pkg/api" |
| 7 | 7 |
|
| 8 |
- api "github.com/openshift/origin/pkg/api/latest" |
|
| 9 | 8 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 9 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 10 | 10 |
deployapitest "github.com/openshift/origin/pkg/deploy/api/test" |
| 11 | 11 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 12 | 12 |
) |
| ... | ... |
@@ -16,7 +16,7 @@ import ( |
| 16 | 16 |
func TestHandle_newConfigNoTriggers(t *testing.T) {
|
| 17 | 17 |
controller := &DeploymentConfigChangeController{
|
| 18 | 18 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 19 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 19 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 20 | 20 |
}, |
| 21 | 21 |
changeStrategy: &changeStrategyImpl{
|
| 22 | 22 |
generateDeploymentConfigFunc: func(namespace, name string) (*deployapi.DeploymentConfig, error) {
|
| ... | ... |
@@ -47,7 +47,7 @@ func TestHandle_newConfigTriggers(t *testing.T) {
|
| 47 | 47 |
|
| 48 | 48 |
controller := &DeploymentConfigChangeController{
|
| 49 | 49 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 50 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 50 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 51 | 51 |
}, |
| 52 | 52 |
changeStrategy: &changeStrategyImpl{
|
| 53 | 53 |
generateDeploymentConfigFunc: func(namespace, name string) (*deployapi.DeploymentConfig, error) {
|
| ... | ... |
@@ -120,12 +120,12 @@ func TestHandle_changeWithTemplateDiff(t *testing.T) {
|
| 120 | 120 |
|
| 121 | 121 |
config := deployapitest.OkDeploymentConfig(1) |
| 122 | 122 |
config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{deployapitest.OkConfigChangeTrigger()}
|
| 123 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 123 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 124 | 124 |
var updated *deployapi.DeploymentConfig |
| 125 | 125 |
|
| 126 | 126 |
controller := &DeploymentConfigChangeController{
|
| 127 | 127 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 128 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 128 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 129 | 129 |
}, |
| 130 | 130 |
changeStrategy: &changeStrategyImpl{
|
| 131 | 131 |
generateDeploymentConfigFunc: func(namespace, name string) (*deployapi.DeploymentConfig, error) {
|
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"k8s.io/kubernetes/pkg/util/sets" |
| 9 | 9 |
|
| 10 | 10 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 11 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 11 | 12 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 12 | 13 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 13 | 14 |
) |
| ... | ... |
@@ -25,7 +26,7 @@ func TestHandle_uncorrelatedPod(t *testing.T) {
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 | 27 |
// Verify no-op |
| 28 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 28 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 29 | 29 |
pod := runningPod(deployment) |
| 30 | 30 |
pod.Annotations = make(map[string]string) |
| 31 | 31 |
err := controller.Handle(pod) |
| ... | ... |
@@ -46,12 +47,12 @@ func TestHandle_orphanedPod(t *testing.T) {
|
| 46 | 46 |
return nil, nil |
| 47 | 47 |
}, |
| 48 | 48 |
getDeploymentFunc: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| 49 |
- return nil, kerrors.NewNotFound("ReplicationController", name)
|
|
| 49 |
+ return nil, kerrors.NewNotFound(kapi.Resource("ReplicationController"), name)
|
|
| 50 | 50 |
}, |
| 51 | 51 |
}, |
| 52 | 52 |
deployerPodsFor: func(namespace, name string) (*kapi.PodList, error) {
|
| 53 | 53 |
mkpod := func(suffix string) kapi.Pod {
|
| 54 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 54 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 55 | 55 |
p := okPod(deployment) |
| 56 | 56 |
p.Name = p.Name + suffix |
| 57 | 57 |
return *p |
| ... | ... |
@@ -70,7 +71,7 @@ func TestHandle_orphanedPod(t *testing.T) {
|
| 70 | 70 |
}, |
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 73 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 74 | 74 |
err := controller.Handle(runningPod(deployment)) |
| 75 | 75 |
|
| 76 | 76 |
if err != nil {
|
| ... | ... |
@@ -86,7 +87,7 @@ func TestHandle_orphanedPod(t *testing.T) {
|
| 86 | 86 |
// TestHandle_runningPod ensures that a running deployer pod results in a |
| 87 | 87 |
// transition of the deployment's status to running. |
| 88 | 88 |
func TestHandle_runningPod(t *testing.T) {
|
| 89 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 89 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 90 | 90 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusPending) |
| 91 | 91 |
var updatedDeployment *kapi.ReplicationController |
| 92 | 92 |
|
| ... | ... |
@@ -120,14 +121,14 @@ func TestHandle_runningPod(t *testing.T) {
|
| 120 | 120 |
// TestHandle_podTerminatedOk ensures that a successfully completed deployer |
| 121 | 121 |
// pod results in a transition of the deployment's status to complete. |
| 122 | 122 |
func TestHandle_podTerminatedOk(t *testing.T) {
|
| 123 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 123 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 124 | 124 |
deployment.Spec.Replicas = 1 |
| 125 | 125 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusRunning) |
| 126 | 126 |
var updatedDeployment *kapi.ReplicationController |
| 127 | 127 |
|
| 128 | 128 |
controller := &DeployerPodController{
|
| 129 | 129 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 130 |
- return deployutil.DecodeDeploymentConfig(deployment, kapi.Codec) |
|
| 130 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.UniversalDecoder()) |
|
| 131 | 131 |
}, |
| 132 | 132 |
deploymentClient: &deploymentClientImpl{
|
| 133 | 133 |
getDeploymentFunc: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -161,14 +162,14 @@ func TestHandle_podTerminatedOk(t *testing.T) {
|
| 161 | 161 |
// TestHandle_podTerminatedOk ensures that a successfully completed deployer |
| 162 | 162 |
// pod results in a transition of the deployment's status to complete. |
| 163 | 163 |
func TestHandle_podTerminatedOkTest(t *testing.T) {
|
| 164 |
- deployment, _ := deployutil.MakeDeployment(deploytest.TestDeploymentConfig(deploytest.OkDeploymentConfig(1)), kapi.Codec) |
|
| 164 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.TestDeploymentConfig(deploytest.OkDeploymentConfig(1)), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 165 | 165 |
deployment.Spec.Replicas = 1 |
| 166 | 166 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusRunning) |
| 167 | 167 |
var updatedDeployment *kapi.ReplicationController |
| 168 | 168 |
|
| 169 | 169 |
controller := &DeployerPodController{
|
| 170 | 170 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 171 |
- return deployutil.DecodeDeploymentConfig(deployment, kapi.Codec) |
|
| 171 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.UniversalDecoder()) |
|
| 172 | 172 |
}, |
| 173 | 173 |
deploymentClient: &deploymentClientImpl{
|
| 174 | 174 |
getDeploymentFunc: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -204,7 +205,7 @@ func TestHandle_podTerminatedOkTest(t *testing.T) {
|
| 204 | 204 |
// deployment's status to failed. |
| 205 | 205 |
func TestHandle_podTerminatedFailNoContainerStatus(t *testing.T) {
|
| 206 | 206 |
var updatedDeployment *kapi.ReplicationController |
| 207 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 207 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 208 | 208 |
deployment.Spec.Replicas = 1 |
| 209 | 209 |
// since we do not set the desired replicas annotation, |
| 210 | 210 |
// this also tests that the error is just logged and not result in a failure |
| ... | ... |
@@ -212,7 +213,7 @@ func TestHandle_podTerminatedFailNoContainerStatus(t *testing.T) {
|
| 212 | 212 |
|
| 213 | 213 |
controller := &DeployerPodController{
|
| 214 | 214 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 215 |
- return deployutil.DecodeDeploymentConfig(deployment, kapi.Codec) |
|
| 215 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.UniversalDecoder()) |
|
| 216 | 216 |
}, |
| 217 | 217 |
deploymentClient: &deploymentClientImpl{
|
| 218 | 218 |
getDeploymentFunc: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -251,7 +252,7 @@ func TestHandle_podTerminatedFailNoContainerStatus(t *testing.T) {
|
| 251 | 251 |
// deployment's status to failed. |
| 252 | 252 |
func TestHandle_podTerminatedFailNoContainerStatusTest(t *testing.T) {
|
| 253 | 253 |
var updatedDeployment *kapi.ReplicationController |
| 254 |
- deployment, _ := deployutil.MakeDeployment(deploytest.TestDeploymentConfig(deploytest.OkDeploymentConfig(1)), kapi.Codec) |
|
| 254 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.TestDeploymentConfig(deploytest.OkDeploymentConfig(1)), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 255 | 255 |
deployment.Spec.Replicas = 1 |
| 256 | 256 |
// since we do not set the desired replicas annotation, |
| 257 | 257 |
// this also tests that the error is just logged and not result in a failure |
| ... | ... |
@@ -259,7 +260,7 @@ func TestHandle_podTerminatedFailNoContainerStatusTest(t *testing.T) {
|
| 259 | 259 |
|
| 260 | 260 |
controller := &DeployerPodController{
|
| 261 | 261 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 262 |
- return deployutil.DecodeDeploymentConfig(deployment, kapi.Codec) |
|
| 262 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.UniversalDecoder()) |
|
| 263 | 263 |
}, |
| 264 | 264 |
deploymentClient: &deploymentClientImpl{
|
| 265 | 265 |
getDeploymentFunc: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -296,7 +297,7 @@ func TestHandle_podTerminatedFailNoContainerStatusTest(t *testing.T) {
|
| 296 | 296 |
// TestHandle_cleanupDesiredReplicasAnnotation ensures that the desired replicas annotation |
| 297 | 297 |
// will be cleaned up in a complete deployment and stay around in a failed deployment |
| 298 | 298 |
func TestHandle_cleanupDesiredReplicasAnnotation(t *testing.T) {
|
| 299 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 299 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 300 | 300 |
|
| 301 | 301 |
tests := []struct {
|
| 302 | 302 |
name string |
| ... | ... |
@@ -321,7 +322,7 @@ func TestHandle_cleanupDesiredReplicasAnnotation(t *testing.T) {
|
| 321 | 321 |
|
| 322 | 322 |
controller := &DeployerPodController{
|
| 323 | 323 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 324 |
- return deployutil.DecodeDeploymentConfig(deployment, kapi.Codec) |
|
| 324 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.UniversalDecoder()) |
|
| 325 | 325 |
}, |
| 326 | 326 |
deploymentClient: &deploymentClientImpl{
|
| 327 | 327 |
getDeploymentFunc: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -11,8 +11,8 @@ import ( |
| 11 | 11 |
"k8s.io/kubernetes/pkg/api/resource" |
| 12 | 12 |
"k8s.io/kubernetes/pkg/client/record" |
| 13 | 13 |
|
| 14 |
- api "github.com/openshift/origin/pkg/api/latest" |
|
| 15 | 14 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 15 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 16 | 16 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 17 | 17 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 18 | 18 |
) |
| ... | ... |
@@ -28,7 +28,7 @@ func TestHandle_createPodOk(t *testing.T) {
|
| 28 | 28 |
|
| 29 | 29 |
controller := &DeploymentController{
|
| 30 | 30 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 31 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 31 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 32 | 32 |
}, |
| 33 | 33 |
deploymentClient: &deploymentClientImpl{
|
| 34 | 34 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -50,7 +50,7 @@ func TestHandle_createPodOk(t *testing.T) {
|
| 50 | 50 |
|
| 51 | 51 |
// Verify new -> pending |
| 52 | 52 |
config := deploytest.OkDeploymentConfig(1) |
| 53 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 53 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 54 | 54 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) |
| 55 | 55 |
deployment.Spec.Template.Spec.NodeSelector = map[string]string{"labelKey1": "labelValue1", "labelKey2": "labelValue2"}
|
| 56 | 56 |
err := controller.Handle(deployment) |
| ... | ... |
@@ -129,7 +129,7 @@ func TestHandle_makeContainerFail(t *testing.T) {
|
| 129 | 129 |
|
| 130 | 130 |
controller := &DeploymentController{
|
| 131 | 131 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 132 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 132 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 133 | 133 |
}, |
| 134 | 134 |
deploymentClient: &deploymentClientImpl{
|
| 135 | 135 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -150,7 +150,7 @@ func TestHandle_makeContainerFail(t *testing.T) {
|
| 150 | 150 |
} |
| 151 | 151 |
|
| 152 | 152 |
config := deploytest.OkDeploymentConfig(1) |
| 153 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 153 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 154 | 154 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) |
| 155 | 155 |
err := controller.Handle(deployment) |
| 156 | 156 |
|
| ... | ... |
@@ -170,7 +170,7 @@ func TestHandle_createPodFail(t *testing.T) {
|
| 170 | 170 |
|
| 171 | 171 |
controller := &DeploymentController{
|
| 172 | 172 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 173 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 173 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 174 | 174 |
}, |
| 175 | 175 |
deploymentClient: &deploymentClientImpl{
|
| 176 | 176 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -190,7 +190,7 @@ func TestHandle_createPodFail(t *testing.T) {
|
| 190 | 190 |
} |
| 191 | 191 |
|
| 192 | 192 |
config := deploytest.OkDeploymentConfig(1) |
| 193 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 193 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 194 | 194 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) |
| 195 | 195 |
err := controller.Handle(deployment) |
| 196 | 196 |
|
| ... | ... |
@@ -210,13 +210,13 @@ func TestHandle_deployerPodAlreadyExists(t *testing.T) {
|
| 210 | 210 |
var updatedDeployment *kapi.ReplicationController |
| 211 | 211 |
|
| 212 | 212 |
config := deploytest.OkDeploymentConfig(1) |
| 213 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 213 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 214 | 214 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) |
| 215 | 215 |
deployerPod := relatedPod(deployment) |
| 216 | 216 |
|
| 217 | 217 |
controller := &DeploymentController{
|
| 218 | 218 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 219 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 219 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 220 | 220 |
}, |
| 221 | 221 |
deploymentClient: &deploymentClientImpl{
|
| 222 | 222 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -260,13 +260,13 @@ func TestHandle_unrelatedPodAlreadyExists(t *testing.T) {
|
| 260 | 260 |
var updatedDeployment *kapi.ReplicationController |
| 261 | 261 |
|
| 262 | 262 |
config := deploytest.OkDeploymentConfig(1) |
| 263 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 263 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 264 | 264 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) |
| 265 | 265 |
otherPod := unrelatedPod(deployment) |
| 266 | 266 |
|
| 267 | 267 |
controller := &DeploymentController{
|
| 268 | 268 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 269 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 269 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 270 | 270 |
}, |
| 271 | 271 |
deploymentClient: &deploymentClientImpl{
|
| 272 | 272 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -279,7 +279,7 @@ func TestHandle_unrelatedPodAlreadyExists(t *testing.T) {
|
| 279 | 279 |
return otherPod, nil |
| 280 | 280 |
}, |
| 281 | 281 |
createPodFunc: func(namespace string, pod *kapi.Pod) (*kapi.Pod, error) {
|
| 282 |
- return nil, kerrors.NewAlreadyExists("Pod", pod.Name)
|
|
| 282 |
+ return nil, kerrors.NewAlreadyExists(kapi.Resource("Pod"), pod.Name)
|
|
| 283 | 283 |
}, |
| 284 | 284 |
}, |
| 285 | 285 |
makeContainer: func(strategy *deployapi.DeploymentStrategy) (*kapi.Container, error) {
|
| ... | ... |
@@ -312,7 +312,7 @@ func TestHandle_unrelatedPodAlreadyExists(t *testing.T) {
|
| 312 | 312 |
func TestHandle_noop(t *testing.T) {
|
| 313 | 313 |
controller := &DeploymentController{
|
| 314 | 314 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 315 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 315 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 316 | 316 |
}, |
| 317 | 317 |
deploymentClient: &deploymentClientImpl{
|
| 318 | 318 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -338,7 +338,7 @@ func TestHandle_noop(t *testing.T) {
|
| 338 | 338 |
|
| 339 | 339 |
// Verify no-op |
| 340 | 340 |
config := deploytest.OkDeploymentConfig(1) |
| 341 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 341 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 342 | 342 |
|
| 343 | 343 |
noopStatus := []deployapi.DeploymentStatus{
|
| 344 | 344 |
deployapi.DeploymentStatusPending, |
| ... | ... |
@@ -361,7 +361,7 @@ func TestHandle_failedTest(t *testing.T) {
|
| 361 | 361 |
var updatedDeployment *kapi.ReplicationController |
| 362 | 362 |
controller := &DeploymentController{
|
| 363 | 363 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 364 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 364 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.UniversalDecoder()) |
|
| 365 | 365 |
}, |
| 366 | 366 |
deploymentClient: &deploymentClientImpl{
|
| 367 | 367 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -392,7 +392,7 @@ func TestHandle_failedTest(t *testing.T) {
|
| 392 | 392 |
|
| 393 | 393 |
// Verify successful cleanup |
| 394 | 394 |
config := deploytest.TestDeploymentConfig(deploytest.OkDeploymentConfig(1)) |
| 395 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 395 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 396 | 396 |
deployment.Spec.Replicas = 1 |
| 397 | 397 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusFailed) |
| 398 | 398 |
|
| ... | ... |
@@ -416,7 +416,7 @@ func TestHandle_cleanupPodOk(t *testing.T) {
|
| 416 | 416 |
|
| 417 | 417 |
controller := &DeploymentController{
|
| 418 | 418 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 419 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 419 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 420 | 420 |
}, |
| 421 | 421 |
deploymentClient: &deploymentClientImpl{
|
| 422 | 422 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -452,7 +452,7 @@ func TestHandle_cleanupPodOk(t *testing.T) {
|
| 452 | 452 |
|
| 453 | 453 |
// Verify successful cleanup |
| 454 | 454 |
config := deploytest.OkDeploymentConfig(1) |
| 455 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 455 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 456 | 456 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusComplete) |
| 457 | 457 |
err := controller.Handle(deployment) |
| 458 | 458 |
|
| ... | ... |
@@ -477,7 +477,7 @@ func TestHandle_cleanupPodOkTest(t *testing.T) {
|
| 477 | 477 |
var updatedDeployment *kapi.ReplicationController |
| 478 | 478 |
controller := &DeploymentController{
|
| 479 | 479 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 480 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 480 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.UniversalDecoder()) |
|
| 481 | 481 |
}, |
| 482 | 482 |
deploymentClient: &deploymentClientImpl{
|
| 483 | 483 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -513,7 +513,7 @@ func TestHandle_cleanupPodOkTest(t *testing.T) {
|
| 513 | 513 |
|
| 514 | 514 |
// Verify successful cleanup |
| 515 | 515 |
config := deploytest.TestDeploymentConfig(deploytest.OkDeploymentConfig(1)) |
| 516 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 516 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 517 | 517 |
deployment.Spec.Replicas = 1 |
| 518 | 518 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusComplete) |
| 519 | 519 |
err := controller.Handle(deployment) |
| ... | ... |
@@ -540,7 +540,7 @@ func TestHandle_cleanupPodOkTest(t *testing.T) {
|
| 540 | 540 |
func TestHandle_cleanupPodNoop(t *testing.T) {
|
| 541 | 541 |
controller := &DeploymentController{
|
| 542 | 542 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 543 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 543 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 544 | 544 |
}, |
| 545 | 545 |
deploymentClient: &deploymentClientImpl{
|
| 546 | 546 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -570,7 +570,7 @@ func TestHandle_cleanupPodNoop(t *testing.T) {
|
| 570 | 570 |
|
| 571 | 571 |
// Verify no-op |
| 572 | 572 |
config := deploytest.OkDeploymentConfig(1) |
| 573 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 573 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 574 | 574 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusComplete) |
| 575 | 575 |
err := controller.Handle(deployment) |
| 576 | 576 |
|
| ... | ... |
@@ -584,7 +584,7 @@ func TestHandle_cleanupPodNoop(t *testing.T) {
|
| 584 | 584 |
func TestHandle_cleanupPodFail(t *testing.T) {
|
| 585 | 585 |
controller := &DeploymentController{
|
| 586 | 586 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 587 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 587 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 588 | 588 |
}, |
| 589 | 589 |
deploymentClient: &deploymentClientImpl{
|
| 590 | 590 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -613,7 +613,7 @@ func TestHandle_cleanupPodFail(t *testing.T) {
|
| 613 | 613 |
|
| 614 | 614 |
// Verify error |
| 615 | 615 |
config := deploytest.OkDeploymentConfig(1) |
| 616 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 616 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 617 | 617 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusComplete) |
| 618 | 618 |
err := controller.Handle(deployment) |
| 619 | 619 |
|
| ... | ... |
@@ -627,7 +627,7 @@ func TestHandle_cancelNew(t *testing.T) {
|
| 627 | 627 |
|
| 628 | 628 |
controller := &DeploymentController{
|
| 629 | 629 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 630 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 630 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 631 | 631 |
}, |
| 632 | 632 |
deploymentClient: &deploymentClientImpl{
|
| 633 | 633 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -647,7 +647,7 @@ func TestHandle_cancelNew(t *testing.T) {
|
| 647 | 647 |
recorder: &record.FakeRecorder{},
|
| 648 | 648 |
} |
| 649 | 649 |
|
| 650 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 650 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 651 | 651 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) |
| 652 | 652 |
deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue |
| 653 | 653 |
|
| ... | ... |
@@ -669,7 +669,7 @@ func TestHandle_cancelPendingRunning(t *testing.T) {
|
| 669 | 669 |
|
| 670 | 670 |
controller := &DeploymentController{
|
| 671 | 671 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 672 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 672 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 673 | 673 |
}, |
| 674 | 674 |
deploymentClient: &deploymentClientImpl{
|
| 675 | 675 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -707,7 +707,7 @@ func TestHandle_cancelPendingRunning(t *testing.T) {
|
| 707 | 707 |
|
| 708 | 708 |
for _, status := range cases {
|
| 709 | 709 |
updatedPods = []kapi.Pod{}
|
| 710 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 710 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 711 | 711 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(status) |
| 712 | 712 |
deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue |
| 713 | 713 |
err := controller.Handle(deployment) |
| ... | ... |
@@ -734,7 +734,7 @@ func TestHandle_deployerPodDisappeared(t *testing.T) {
|
| 734 | 734 |
updateCalled := false |
| 735 | 735 |
controller := &DeploymentController{
|
| 736 | 736 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 737 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 737 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 738 | 738 |
}, |
| 739 | 739 |
deploymentClient: &deploymentClientImpl{
|
| 740 | 740 |
updateDeploymentFunc: func(namespace string, deployment *kapi.ReplicationController) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -745,7 +745,7 @@ func TestHandle_deployerPodDisappeared(t *testing.T) {
|
| 745 | 745 |
}, |
| 746 | 746 |
podClient: &podClientImpl{
|
| 747 | 747 |
getPodFunc: func(namespace, name string) (*kapi.Pod, error) {
|
| 748 |
- return nil, kerrors.NewNotFound("Pod", name)
|
|
| 748 |
+ return nil, kerrors.NewNotFound(kapi.Resource("Pod"), name)
|
|
| 749 | 749 |
}, |
| 750 | 750 |
}, |
| 751 | 751 |
makeContainer: func(strategy *deployapi.DeploymentStrategy) (*kapi.Container, error) {
|
| ... | ... |
@@ -754,7 +754,7 @@ func TestHandle_deployerPodDisappeared(t *testing.T) {
|
| 754 | 754 |
recorder: &record.FakeRecorder{},
|
| 755 | 755 |
} |
| 756 | 756 |
|
| 757 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 757 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 758 | 758 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusRunning) |
| 759 | 759 |
|
| 760 | 760 |
err := controller.Handle(deployment) |
| ... | ... |
@@ -788,7 +788,7 @@ func expectMapContains(t *testing.T, exists, expected map[string]string, what st |
| 788 | 788 |
func TestDeployerCustomLabelsAndAnnotations(t *testing.T) {
|
| 789 | 789 |
controller := &DeploymentController{
|
| 790 | 790 |
decodeConfig: func(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, error) {
|
| 791 |
- return deployutil.DecodeDeploymentConfig(deployment, api.Codec) |
|
| 791 |
+ return deployutil.DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 792 | 792 |
}, |
| 793 | 793 |
podClient: &podClientImpl{
|
| 794 | 794 |
createPodFunc: func(namespace string, pod *kapi.Pod) (*kapi.Pod, error) {
|
| ... | ... |
@@ -820,7 +820,7 @@ func TestDeployerCustomLabelsAndAnnotations(t *testing.T) {
|
| 820 | 820 |
config.Spec.Strategy.Labels = test.labels |
| 821 | 821 |
config.Spec.Strategy.Annotations = test.annotations |
| 822 | 822 |
|
| 823 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 823 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 824 | 824 |
podTemplate, err := controller.makeDeployerPod(deployment) |
| 825 | 825 |
if err != nil {
|
| 826 | 826 |
t.Fatal(err) |
| ... | ... |
@@ -14,6 +14,7 @@ import ( |
| 14 | 14 |
|
| 15 | 15 |
"github.com/openshift/origin/pkg/client/testclient" |
| 16 | 16 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 17 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 17 | 18 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 18 | 19 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 19 | 20 |
) |
| ... | ... |
@@ -38,7 +39,7 @@ func TestHandleScenarios(t *testing.T) {
|
| 38 | 38 |
if d.test {
|
| 39 | 39 |
config = deploytest.TestDeploymentConfig(config) |
| 40 | 40 |
} |
| 41 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 41 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 42 | 42 |
deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(d.status) |
| 43 | 43 |
if d.cancelled {
|
| 44 | 44 |
deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue |
| ... | ... |
@@ -650,7 +651,7 @@ func TestHandleScenarios(t *testing.T) {
|
| 650 | 650 |
controller := &DeploymentConfigController{
|
| 651 | 651 |
kubeClient: kc, |
| 652 | 652 |
osClient: oc, |
| 653 |
- codec: kapi.Codec, |
|
| 653 |
+ codec: kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion), |
|
| 654 | 654 |
recorder: recorder, |
| 655 | 655 |
} |
| 656 | 656 |
|
| ... | ... |
@@ -11,12 +11,14 @@ import ( |
| 11 | 11 |
"k8s.io/kubernetes/pkg/runtime" |
| 12 | 12 |
|
| 13 | 13 |
"github.com/openshift/origin/pkg/client/testclient" |
| 14 |
+ deployapi "github.com/openshift/origin/pkg/deploy/api" |
|
| 15 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 14 | 16 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 15 | 17 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 16 | 18 |
) |
| 17 | 19 |
|
| 18 | 20 |
func mkdeployment(version int) kapi.ReplicationController {
|
| 19 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codec) |
|
| 21 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 20 | 22 |
return *deployment |
| 21 | 23 |
} |
| 22 | 24 |
|
| ... | ... |
@@ -30,7 +32,7 @@ func mkdeploymentlist(versions ...int) *kapi.ReplicationControllerList {
|
| 30 | 30 |
|
| 31 | 31 |
func TestStop(t *testing.T) {
|
| 32 | 32 |
notfound := func() runtime.Object {
|
| 33 |
- return &(kerrors.NewNotFound("DeploymentConfig", "config").(*kerrors.StatusError).ErrStatus)
|
|
| 33 |
+ return &(kerrors.NewNotFound(kapi.Resource("DeploymentConfig"), "config").(*kerrors.StatusError).ErrStatus)
|
|
| 34 | 34 |
} |
| 35 | 35 |
|
| 36 | 36 |
tests := []struct {
|
| ... | ... |
@@ -28,7 +28,7 @@ import ( |
| 28 | 28 |
var testSelector = map[string]string{"test": "rest"}
|
| 29 | 29 |
|
| 30 | 30 |
func makeDeployment(version int) kapi.ReplicationController {
|
| 31 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codec) |
|
| 31 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(api.SchemeGroupVersion)) |
|
| 32 | 32 |
deployment.Namespace = kapi.NamespaceDefault |
| 33 | 33 |
deployment.Spec.Selector = testSelector |
| 34 | 34 |
return *deployment |
| ... | ... |
@@ -200,7 +200,7 @@ func TestRESTGet(t *testing.T) {
|
| 200 | 200 |
Transport: nil, |
| 201 | 201 |
ContentType: "text/plain", |
| 202 | 202 |
Flush: true, |
| 203 |
- ResponseChecker: genericrest.NewGenericHttpResponseChecker("Pod", "config-5-application-pod-1"),
|
|
| 203 |
+ ResponseChecker: genericrest.NewGenericHttpResponseChecker(kapi.Resource("pod"), "config-5-application-pod-1"),
|
|
| 204 | 204 |
}, |
| 205 | 205 |
expectedErr: nil, |
| 206 | 206 |
}, |
| ... | ... |
@@ -9,8 +9,8 @@ import ( |
| 9 | 9 |
kapi "k8s.io/kubernetes/pkg/api" |
| 10 | 10 |
kerrors "k8s.io/kubernetes/pkg/api/errors" |
| 11 | 11 |
|
| 12 |
- api "github.com/openshift/origin/pkg/api/latest" |
|
| 13 | 12 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 13 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 14 | 14 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 15 | 15 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 16 | 16 |
) |
| ... | ... |
@@ -48,14 +48,14 @@ func TestCreateOk(t *testing.T) {
|
| 48 | 48 |
return &deployapi.DeploymentConfig{}, nil
|
| 49 | 49 |
}, |
| 50 | 50 |
RCFn: func(ctx kapi.Context, name string) (*kapi.ReplicationController, error) {
|
| 51 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 51 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 52 | 52 |
return deployment, nil |
| 53 | 53 |
}, |
| 54 | 54 |
DCFn: func(ctx kapi.Context, name string) (*deployapi.DeploymentConfig, error) {
|
| 55 | 55 |
return deploytest.OkDeploymentConfig(1), nil |
| 56 | 56 |
}, |
| 57 | 57 |
}, |
| 58 |
- codec: api.Codec, |
|
| 58 |
+ codec: kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion), |
|
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 | 61 |
obj, err := rest.Create(kapi.NewDefaultContext(), &deployapi.DeploymentConfigRollback{
|
| ... | ... |
@@ -87,14 +87,14 @@ func TestCreateGeneratorError(t *testing.T) {
|
| 87 | 87 |
return nil, kerrors.NewInternalError(fmt.Errorf("something terrible happened"))
|
| 88 | 88 |
}, |
| 89 | 89 |
RCFn: func(ctx kapi.Context, name string) (*kapi.ReplicationController, error) {
|
| 90 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 90 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 91 | 91 |
return deployment, nil |
| 92 | 92 |
}, |
| 93 | 93 |
DCFn: func(ctx kapi.Context, name string) (*deployapi.DeploymentConfig, error) {
|
| 94 | 94 |
return deploytest.OkDeploymentConfig(1), nil |
| 95 | 95 |
}, |
| 96 | 96 |
}, |
| 97 |
- codec: api.Codec, |
|
| 97 |
+ codec: kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion), |
|
| 98 | 98 |
} |
| 99 | 99 |
|
| 100 | 100 |
_, err := rest.Create(kapi.NewDefaultContext(), &deployapi.DeploymentConfigRollback{
|
| ... | ... |
@@ -119,15 +119,15 @@ func TestCreateMissingDeployment(t *testing.T) {
|
| 119 | 119 |
return nil, errors.New("something terrible happened")
|
| 120 | 120 |
}, |
| 121 | 121 |
RCFn: func(ctx kapi.Context, name string) (*kapi.ReplicationController, error) {
|
| 122 |
- return nil, kerrors.NewNotFound("replicationController", name)
|
|
| 122 |
+ return nil, kerrors.NewNotFound(kapi.Resource("replicationController"), name)
|
|
| 123 | 123 |
}, |
| 124 | 124 |
DCFn: func(ctx kapi.Context, name string) (*deployapi.DeploymentConfig, error) {
|
| 125 | 125 |
namespace, _ := kapi.NamespaceFrom(ctx) |
| 126 | 126 |
t.Fatalf("unexpected call to GetDeploymentConfig(%s/%s)", namespace, name)
|
| 127 |
- return nil, kerrors.NewNotFound("deploymentConfig", name)
|
|
| 127 |
+ return nil, kerrors.NewNotFound(deployapi.Resource("deploymentConfig"), name)
|
|
| 128 | 128 |
}, |
| 129 | 129 |
}, |
| 130 |
- codec: api.Codec, |
|
| 130 |
+ codec: kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion), |
|
| 131 | 131 |
} |
| 132 | 132 |
|
| 133 | 133 |
obj, err := rest.Create(kapi.NewDefaultContext(), &deployapi.DeploymentConfigRollback{
|
| ... | ... |
@@ -157,17 +157,17 @@ func TestCreateInvalidDeployment(t *testing.T) {
|
| 157 | 157 |
}, |
| 158 | 158 |
RCFn: func(ctx kapi.Context, name string) (*kapi.ReplicationController, error) {
|
| 159 | 159 |
// invalidate the encoded config |
| 160 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 160 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 161 | 161 |
deployment.Annotations[deployapi.DeploymentEncodedConfigAnnotation] = "" |
| 162 | 162 |
return deployment, nil |
| 163 | 163 |
}, |
| 164 | 164 |
DCFn: func(ctx kapi.Context, name string) (*deployapi.DeploymentConfig, error) {
|
| 165 | 165 |
namespace, _ := kapi.NamespaceFrom(ctx) |
| 166 | 166 |
t.Fatalf("unexpected call to GetDeploymentConfig(%s/%s)", namespace, name)
|
| 167 |
- return nil, kerrors.NewNotFound("deploymentConfig", name)
|
|
| 167 |
+ return nil, kerrors.NewNotFound(deployapi.Resource("deploymentConfig"), name)
|
|
| 168 | 168 |
}, |
| 169 | 169 |
}, |
| 170 |
- codec: api.Codec, |
|
| 170 |
+ codec: kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion), |
|
| 171 | 171 |
} |
| 172 | 172 |
|
| 173 | 173 |
obj, err := rest.Create(kapi.NewDefaultContext(), &deployapi.DeploymentConfigRollback{
|
| ... | ... |
@@ -196,14 +196,14 @@ func TestCreateMissingDeploymentConfig(t *testing.T) {
|
| 196 | 196 |
return nil, errors.New("something terrible happened")
|
| 197 | 197 |
}, |
| 198 | 198 |
RCFn: func(ctx kapi.Context, name string) (*kapi.ReplicationController, error) {
|
| 199 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 199 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 200 | 200 |
return deployment, nil |
| 201 | 201 |
}, |
| 202 | 202 |
DCFn: func(ctx kapi.Context, name string) (*deployapi.DeploymentConfig, error) {
|
| 203 |
- return nil, kerrors.NewNotFound("deploymentConfig", name)
|
|
| 203 |
+ return nil, kerrors.NewNotFound(deployapi.Resource("deploymentConfig"), name)
|
|
| 204 | 204 |
}, |
| 205 | 205 |
}, |
| 206 |
- codec: api.Codec, |
|
| 206 |
+ codec: kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion), |
|
| 207 | 207 |
} |
| 208 | 208 |
|
| 209 | 209 |
obj, err := rest.Create(kapi.NewDefaultContext(), &deployapi.DeploymentConfigRollback{
|
| ... | ... |
@@ -226,6 +226,6 @@ func TestCreateMissingDeploymentConfig(t *testing.T) {
|
| 226 | 226 |
|
| 227 | 227 |
func TestNew(t *testing.T) {
|
| 228 | 228 |
// :) |
| 229 |
- rest := NewREST(Client{}, api.Codec)
|
|
| 229 |
+ rest := NewREST(Client{}, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion))
|
|
| 230 | 230 |
rest.New() |
| 231 | 231 |
} |
| ... | ... |
@@ -11,6 +11,8 @@ import ( |
| 11 | 11 |
"k8s.io/kubernetes/pkg/runtime" |
| 12 | 12 |
|
| 13 | 13 |
"github.com/openshift/origin/pkg/client/testclient" |
| 14 |
+ deployapi "github.com/openshift/origin/pkg/deploy/api" |
|
| 15 |
+ _ "github.com/openshift/origin/pkg/deploy/api/install" |
|
| 14 | 16 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 15 | 17 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 16 | 18 |
) |
| ... | ... |
@@ -44,7 +46,7 @@ func TestScale(t *testing.T) {
|
| 44 | 44 |
|
| 45 | 45 |
config := deploytest.OkDeploymentConfig(1) |
| 46 | 46 |
config.Spec.Replicas = 1 |
| 47 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 47 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 48 | 48 |
|
| 49 | 49 |
var wait *kubectl.RetryParams |
| 50 | 50 |
if test.wait {
|
| ... | ... |
@@ -6,13 +6,15 @@ import ( |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 | 8 |
kapi "k8s.io/kubernetes/pkg/api" |
| 9 |
+ "k8s.io/kubernetes/pkg/apimachinery/registered" |
|
| 9 | 10 |
|
| 10 |
- api "github.com/openshift/origin/pkg/api/latest" |
|
| 11 | 11 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 12 | 12 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 13 | 13 |
scalertest "github.com/openshift/origin/pkg/deploy/scaler/test" |
| 14 | 14 |
"github.com/openshift/origin/pkg/deploy/strategy" |
| 15 | 15 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 16 |
+ |
|
| 17 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 16 | 18 |
) |
| 17 | 19 |
|
| 18 | 20 |
func TestRecreate_initialDeployment(t *testing.T) {
|
| ... | ... |
@@ -20,7 +22,7 @@ func TestRecreate_initialDeployment(t *testing.T) {
|
| 20 | 20 |
scaler := &scalertest.FakeScaler{}
|
| 21 | 21 |
|
| 22 | 22 |
strategy := &RecreateDeploymentStrategy{
|
| 23 |
- codec: api.Codec, |
|
| 23 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 24 | 24 |
retryTimeout: 1 * time.Second, |
| 25 | 25 |
retryPeriod: 1 * time.Millisecond, |
| 26 | 26 |
getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -32,7 +34,7 @@ func TestRecreate_initialDeployment(t *testing.T) {
|
| 32 | 32 |
|
| 33 | 33 |
config := deploytest.OkDeploymentConfig(1) |
| 34 | 34 |
config.Spec.Strategy = recreateParams(30, "", "", "") |
| 35 |
- deployment, _ = deployutil.MakeDeployment(config, kapi.Codec) |
|
| 35 |
+ deployment, _ = deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 36 | 36 |
err := strategy.Deploy(nil, deployment, 3) |
| 37 | 37 |
if err != nil {
|
| 38 | 38 |
t.Fatalf("unexpected deploy error: %#v", err)
|
| ... | ... |
@@ -52,12 +54,12 @@ func TestRecreate_initialDeployment(t *testing.T) {
|
| 52 | 52 |
func TestRecreate_deploymentPreHookSuccess(t *testing.T) {
|
| 53 | 53 |
config := deploytest.OkDeploymentConfig(1) |
| 54 | 54 |
config.Spec.Strategy = recreateParams(30, deployapi.LifecycleHookFailurePolicyAbort, "", "") |
| 55 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 55 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 56 | 56 |
scaler := &scalertest.FakeScaler{}
|
| 57 | 57 |
|
| 58 | 58 |
hookExecuted := false |
| 59 | 59 |
strategy := &RecreateDeploymentStrategy{
|
| 60 |
- codec: api.Codec, |
|
| 60 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 61 | 61 |
retryTimeout: 1 * time.Second, |
| 62 | 62 |
retryPeriod: 1 * time.Millisecond, |
| 63 | 63 |
getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -85,11 +87,11 @@ func TestRecreate_deploymentPreHookSuccess(t *testing.T) {
|
| 85 | 85 |
func TestRecreate_deploymentPreHookFail(t *testing.T) {
|
| 86 | 86 |
config := deploytest.OkDeploymentConfig(1) |
| 87 | 87 |
config.Spec.Strategy = recreateParams(30, deployapi.LifecycleHookFailurePolicyAbort, "", "") |
| 88 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 88 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 89 | 89 |
scaler := &scalertest.FakeScaler{}
|
| 90 | 90 |
|
| 91 | 91 |
strategy := &RecreateDeploymentStrategy{
|
| 92 |
- codec: api.Codec, |
|
| 92 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 93 | 93 |
retryTimeout: 1 * time.Second, |
| 94 | 94 |
retryPeriod: 1 * time.Millisecond, |
| 95 | 95 |
getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -116,12 +118,12 @@ func TestRecreate_deploymentPreHookFail(t *testing.T) {
|
| 116 | 116 |
func TestRecreate_deploymentMidHookSuccess(t *testing.T) {
|
| 117 | 117 |
config := deploytest.OkDeploymentConfig(1) |
| 118 | 118 |
config.Spec.Strategy = recreateParams(30, "", deployapi.LifecycleHookFailurePolicyAbort, "") |
| 119 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 119 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 120 | 120 |
scaler := &scalertest.FakeScaler{}
|
| 121 | 121 |
|
| 122 | 122 |
hookExecuted := false |
| 123 | 123 |
strategy := &RecreateDeploymentStrategy{
|
| 124 |
- codec: api.Codec, |
|
| 124 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 125 | 125 |
retryTimeout: 1 * time.Second, |
| 126 | 126 |
retryPeriod: 1 * time.Millisecond, |
| 127 | 127 |
getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -149,11 +151,11 @@ func TestRecreate_deploymentMidHookSuccess(t *testing.T) {
|
| 149 | 149 |
func TestRecreate_deploymentMidHookFail(t *testing.T) {
|
| 150 | 150 |
config := deploytest.OkDeploymentConfig(1) |
| 151 | 151 |
config.Spec.Strategy = recreateParams(30, "", deployapi.LifecycleHookFailurePolicyAbort, "") |
| 152 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 152 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 153 | 153 |
scaler := &scalertest.FakeScaler{}
|
| 154 | 154 |
|
| 155 | 155 |
strategy := &RecreateDeploymentStrategy{
|
| 156 |
- codec: api.Codec, |
|
| 156 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 157 | 157 |
retryTimeout: 1 * time.Second, |
| 158 | 158 |
retryPeriod: 1 * time.Millisecond, |
| 159 | 159 |
getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -179,12 +181,12 @@ func TestRecreate_deploymentMidHookFail(t *testing.T) {
|
| 179 | 179 |
func TestRecreate_deploymentPostHookSuccess(t *testing.T) {
|
| 180 | 180 |
config := deploytest.OkDeploymentConfig(1) |
| 181 | 181 |
config.Spec.Strategy = recreateParams(30, "", "", deployapi.LifecycleHookFailurePolicyAbort) |
| 182 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 182 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 183 | 183 |
scaler := &scalertest.FakeScaler{}
|
| 184 | 184 |
|
| 185 | 185 |
hookExecuted := false |
| 186 | 186 |
strategy := &RecreateDeploymentStrategy{
|
| 187 |
- codec: api.Codec, |
|
| 187 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 188 | 188 |
retryTimeout: 1 * time.Second, |
| 189 | 189 |
retryPeriod: 1 * time.Millisecond, |
| 190 | 190 |
getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -212,12 +214,12 @@ func TestRecreate_deploymentPostHookSuccess(t *testing.T) {
|
| 212 | 212 |
func TestRecreate_deploymentPostHookFail(t *testing.T) {
|
| 213 | 213 |
config := deploytest.OkDeploymentConfig(1) |
| 214 | 214 |
config.Spec.Strategy = recreateParams(30, "", "", deployapi.LifecycleHookFailurePolicyAbort) |
| 215 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 215 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 216 | 216 |
scaler := &scalertest.FakeScaler{}
|
| 217 | 217 |
|
| 218 | 218 |
hookExecuted := false |
| 219 | 219 |
strategy := &RecreateDeploymentStrategy{
|
| 220 |
- codec: api.Codec, |
|
| 220 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 221 | 221 |
retryTimeout: 1 * time.Second, |
| 222 | 222 |
retryPeriod: 1 * time.Millisecond, |
| 223 | 223 |
getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -247,7 +249,7 @@ func TestRecreate_acceptorSuccess(t *testing.T) {
|
| 247 | 247 |
scaler := &scalertest.FakeScaler{}
|
| 248 | 248 |
|
| 249 | 249 |
strategy := &RecreateDeploymentStrategy{
|
| 250 |
- codec: api.Codec, |
|
| 250 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 251 | 251 |
retryTimeout: 1 * time.Second, |
| 252 | 252 |
retryPeriod: 1 * time.Millisecond, |
| 253 | 253 |
getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -264,7 +266,7 @@ func TestRecreate_acceptorSuccess(t *testing.T) {
|
| 264 | 264 |
}, |
| 265 | 265 |
} |
| 266 | 266 |
|
| 267 |
- deployment, _ = deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 267 |
+ deployment, _ = deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 268 | 268 |
err := strategy.DeployWithAcceptor(nil, deployment, 2, acceptor) |
| 269 | 269 |
if err != nil {
|
| 270 | 270 |
t.Fatalf("unexpected deploy error: %#v", err)
|
| ... | ... |
@@ -290,7 +292,7 @@ func TestRecreate_acceptorFail(t *testing.T) {
|
| 290 | 290 |
scaler := &scalertest.FakeScaler{}
|
| 291 | 291 |
|
| 292 | 292 |
strategy := &RecreateDeploymentStrategy{
|
| 293 |
- codec: api.Codec, |
|
| 293 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 294 | 294 |
retryTimeout: 1 * time.Second, |
| 295 | 295 |
retryPeriod: 1 * time.Millisecond, |
| 296 | 296 |
getReplicationController: func(namespace, name string) (*kapi.ReplicationController, error) {
|
| ... | ... |
@@ -305,7 +307,7 @@ func TestRecreate_acceptorFail(t *testing.T) {
|
| 305 | 305 |
}, |
| 306 | 306 |
} |
| 307 | 307 |
|
| 308 |
- deployment, _ = deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 308 |
+ deployment, _ = deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 309 | 309 |
err := strategy.DeployWithAcceptor(nil, deployment, 2, acceptor) |
| 310 | 310 |
if err == nil {
|
| 311 | 311 |
t.Fatalf("expected a deployment failure")
|
| ... | ... |
@@ -6,23 +6,25 @@ import ( |
| 6 | 6 |
"time" |
| 7 | 7 |
|
| 8 | 8 |
kapi "k8s.io/kubernetes/pkg/api" |
| 9 |
+ "k8s.io/kubernetes/pkg/apimachinery/registered" |
|
| 9 | 10 |
ktestclient "k8s.io/kubernetes/pkg/client/unversioned/testclient" |
| 10 | 11 |
"k8s.io/kubernetes/pkg/kubectl" |
| 11 | 12 |
"k8s.io/kubernetes/pkg/runtime" |
| 12 | 13 |
|
| 13 |
- api "github.com/openshift/origin/pkg/api/latest" |
|
| 14 | 14 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 15 | 15 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 16 | 16 |
strat "github.com/openshift/origin/pkg/deploy/strategy" |
| 17 | 17 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 18 |
+ |
|
| 19 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 18 | 20 |
) |
| 19 | 21 |
|
| 20 | 22 |
func TestRolling_deployInitial(t *testing.T) {
|
| 21 | 23 |
initialStrategyInvoked := false |
| 22 | 24 |
|
| 23 | 25 |
strategy := &RollingDeploymentStrategy{
|
| 24 |
- codec: api.Codec, |
|
| 25 |
- client: ktestclient.NewSimpleFake(), |
|
| 26 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 27 |
+ client: ktestclient.NewSimpleFake(), |
|
| 26 | 28 |
initialStrategy: &testStrategy{
|
| 27 | 29 |
deployFn: func(from *kapi.ReplicationController, to *kapi.ReplicationController, desiredReplicas int, updateAcceptor strat.UpdateAcceptor) error {
|
| 28 | 30 |
initialStrategyInvoked = true |
| ... | ... |
@@ -40,7 +42,7 @@ func TestRolling_deployInitial(t *testing.T) {
|
| 40 | 40 |
|
| 41 | 41 |
config := deploytest.OkDeploymentConfig(1) |
| 42 | 42 |
config.Spec.Strategy = deploytest.OkRollingStrategy() |
| 43 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 43 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 44 | 44 |
err := strategy.Deploy(nil, deployment, 2) |
| 45 | 45 |
if err != nil {
|
| 46 | 46 |
t.Fatalf("unexpected error: %v", err)
|
| ... | ... |
@@ -53,10 +55,10 @@ func TestRolling_deployInitial(t *testing.T) {
|
| 53 | 53 |
func TestRolling_deployRolling(t *testing.T) {
|
| 54 | 54 |
latestConfig := deploytest.OkDeploymentConfig(1) |
| 55 | 55 |
latestConfig.Spec.Strategy = deploytest.OkRollingStrategy() |
| 56 |
- latest, _ := deployutil.MakeDeployment(latestConfig, kapi.Codec) |
|
| 56 |
+ latest, _ := deployutil.MakeDeployment(latestConfig, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 57 | 57 |
config := deploytest.OkDeploymentConfig(2) |
| 58 | 58 |
config.Spec.Strategy = deploytest.OkRollingStrategy() |
| 59 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 59 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 60 | 60 |
|
| 61 | 61 |
deployments := map[string]*kapi.ReplicationController{
|
| 62 | 62 |
latest.Name: latest, |
| ... | ... |
@@ -77,8 +79,8 @@ func TestRolling_deployRolling(t *testing.T) {
|
| 77 | 77 |
|
| 78 | 78 |
var rollingConfig *kubectl.RollingUpdaterConfig |
| 79 | 79 |
strategy := &RollingDeploymentStrategy{
|
| 80 |
- codec: api.Codec, |
|
| 81 |
- client: fake, |
|
| 80 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 81 |
+ client: fake, |
|
| 82 | 82 |
initialStrategy: &testStrategy{
|
| 83 | 83 |
deployFn: func(from *kapi.ReplicationController, to *kapi.ReplicationController, desiredReplicas int, updateAcceptor strat.UpdateAcceptor) error {
|
| 84 | 84 |
t.Fatalf("unexpected call to initial strategy")
|
| ... | ... |
@@ -140,7 +142,7 @@ func TestRolling_deployRolling(t *testing.T) {
|
| 140 | 140 |
func TestRolling_deployRollingHooks(t *testing.T) {
|
| 141 | 141 |
config := deploytest.OkDeploymentConfig(1) |
| 142 | 142 |
config.Spec.Strategy = deploytest.OkRollingStrategy() |
| 143 |
- latest, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 143 |
+ latest, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 144 | 144 |
|
| 145 | 145 |
var hookError error |
| 146 | 146 |
|
| ... | ... |
@@ -157,8 +159,8 @@ func TestRolling_deployRollingHooks(t *testing.T) {
|
| 157 | 157 |
}) |
| 158 | 158 |
|
| 159 | 159 |
strategy := &RollingDeploymentStrategy{
|
| 160 |
- codec: api.Codec, |
|
| 161 |
- client: fake, |
|
| 160 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 161 |
+ client: fake, |
|
| 162 | 162 |
initialStrategy: &testStrategy{
|
| 163 | 163 |
deployFn: func(from *kapi.ReplicationController, to *kapi.ReplicationController, desiredReplicas int, updateAcceptor strat.UpdateAcceptor) error {
|
| 164 | 164 |
t.Fatalf("unexpected call to initial strategy")
|
| ... | ... |
@@ -192,7 +194,7 @@ func TestRolling_deployRollingHooks(t *testing.T) {
|
| 192 | 192 |
for _, tc := range cases {
|
| 193 | 193 |
config := deploytest.OkDeploymentConfig(2) |
| 194 | 194 |
config.Spec.Strategy.RollingParams = tc.params |
| 195 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 195 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 196 | 196 |
deployments[deployment.Name] = deployment |
| 197 | 197 |
hookError = nil |
| 198 | 198 |
if tc.hookShouldFail {
|
| ... | ... |
@@ -217,8 +219,8 @@ func TestRolling_deployInitialHooks(t *testing.T) {
|
| 217 | 217 |
var hookError error |
| 218 | 218 |
|
| 219 | 219 |
strategy := &RollingDeploymentStrategy{
|
| 220 |
- codec: api.Codec, |
|
| 221 |
- client: ktestclient.NewSimpleFake(), |
|
| 220 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 221 |
+ client: ktestclient.NewSimpleFake(), |
|
| 222 | 222 |
initialStrategy: &testStrategy{
|
| 223 | 223 |
deployFn: func(from *kapi.ReplicationController, to *kapi.ReplicationController, desiredReplicas int, updateAcceptor strat.UpdateAcceptor) error {
|
| 224 | 224 |
return nil |
| ... | ... |
@@ -251,7 +253,7 @@ func TestRolling_deployInitialHooks(t *testing.T) {
|
| 251 | 251 |
for _, tc := range cases {
|
| 252 | 252 |
config := deploytest.OkDeploymentConfig(2) |
| 253 | 253 |
config.Spec.Strategy.RollingParams = tc.params |
| 254 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 254 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0])) |
|
| 255 | 255 |
hookError = nil |
| 256 | 256 |
if tc.hookShouldFail {
|
| 257 | 257 |
hookError = fmt.Errorf("hook failure")
|
| ... | ... |
@@ -21,6 +21,8 @@ import ( |
| 21 | 21 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 22 | 22 |
deployutil "github.com/openshift/origin/pkg/deploy/util" |
| 23 | 23 |
namer "github.com/openshift/origin/pkg/util/namer" |
| 24 |
+ |
|
| 25 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 24 | 26 |
) |
| 25 | 27 |
|
| 26 | 28 |
func TestHookExecutor_executeExecNewCreatePodFailure(t *testing.T) {
|
| ... | ... |
@@ -31,7 +33,7 @@ func TestHookExecutor_executeExecNewCreatePodFailure(t *testing.T) {
|
| 31 | 31 |
}, |
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 34 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 35 | 35 |
|
| 36 | 36 |
executor := &HookExecutor{
|
| 37 | 37 |
podClient: &HookExecutorPodClientImpl{
|
| ... | ... |
@@ -42,7 +44,7 @@ func TestHookExecutor_executeExecNewCreatePodFailure(t *testing.T) {
|
| 42 | 42 |
return func() *kapi.Pod { return nil }
|
| 43 | 43 |
}, |
| 44 | 44 |
}, |
| 45 |
- codec: kapi.Codec, |
|
| 45 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 | 48 |
err := executor.executeExecNewPod(hook, deployment, "hook") |
| ... | ... |
@@ -62,7 +64,7 @@ func TestHookExecutor_executeExecNewPodSucceeded(t *testing.T) {
|
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 | 64 |
config := deploytest.OkDeploymentConfig(1) |
| 65 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 65 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 66 | 66 |
deployment.Spec.Template.Spec.NodeSelector = map[string]string{"labelKey1": "labelValue1", "labelKey2": "labelValue2"}
|
| 67 | 67 |
|
| 68 | 68 |
podLogs := &bytes.Buffer{}
|
| ... | ... |
@@ -82,7 +84,7 @@ func TestHookExecutor_executeExecNewPodSucceeded(t *testing.T) {
|
| 82 | 82 |
podLogStream: func(namespace, name string, opts *kapi.PodLogOptions) (io.ReadCloser, error) {
|
| 83 | 83 |
return ioutil.NopCloser(strings.NewReader("test")), nil
|
| 84 | 84 |
}, |
| 85 |
- codec: kapi.Codec, |
|
| 85 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 86 | 86 |
} |
| 87 | 87 |
|
| 88 | 88 |
err := executor.executeExecNewPod(hook, deployment, "hook") |
| ... | ... |
@@ -116,7 +118,7 @@ func TestHookExecutor_executeExecNewPodFailed(t *testing.T) {
|
| 116 | 116 |
}, |
| 117 | 117 |
} |
| 118 | 118 |
|
| 119 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 119 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 120 | 120 |
|
| 121 | 121 |
var createdPod *kapi.Pod |
| 122 | 122 |
executor := &HookExecutor{
|
| ... | ... |
@@ -134,7 +136,7 @@ func TestHookExecutor_executeExecNewPodFailed(t *testing.T) {
|
| 134 | 134 |
podLogStream: func(namespace, name string, opts *kapi.PodLogOptions) (io.ReadCloser, error) {
|
| 135 | 135 |
return nil, fmt.Errorf("can't access logs")
|
| 136 | 136 |
}, |
| 137 |
- codec: kapi.Codec, |
|
| 137 |
+ decoder: kapi.Codecs.UniversalDecoder(), |
|
| 138 | 138 |
} |
| 139 | 139 |
|
| 140 | 140 |
err := executor.executeExecNewPod(hook, deployment, "hook") |
| ... | ... |
@@ -154,7 +156,7 @@ func TestHookExecutor_makeHookPodInvalidContainerRef(t *testing.T) {
|
| 154 | 154 |
} |
| 155 | 155 |
|
| 156 | 156 |
config := deploytest.OkDeploymentConfig(1) |
| 157 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 157 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 158 | 158 |
|
| 159 | 159 |
_, err := makeHookPod(hook, deployment, &config.Spec.Strategy, "hook") |
| 160 | 160 |
|
| ... | ... |
@@ -407,7 +409,7 @@ func TestHookExecutor_makeHookPodRestart(t *testing.T) {
|
| 407 | 407 |
} |
| 408 | 408 |
|
| 409 | 409 |
config := deploytest.OkDeploymentConfig(1) |
| 410 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 410 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 411 | 411 |
|
| 412 | 412 |
pod, err := makeHookPod(hook, deployment, &config.Spec.Strategy, "hook") |
| 413 | 413 |
if err != nil {
|
| ... | ... |
@@ -508,7 +510,7 @@ func TestAcceptNewlyObservedReadyPods_scenarios(t *testing.T) {
|
| 508 | 508 |
acceptedPods: acceptedPods, |
| 509 | 509 |
} |
| 510 | 510 |
|
| 511 |
- deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codec) |
|
| 511 |
+ deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 512 | 512 |
deployment.Spec.Replicas = 1 |
| 513 | 513 |
|
| 514 | 514 |
err := acceptor.Accept(deployment) |
| ... | ... |
@@ -604,7 +606,7 @@ func deployment(name, namespace string, strategyLabels, strategyAnnotations map[ |
| 604 | 604 |
}, |
| 605 | 605 |
}, |
| 606 | 606 |
} |
| 607 |
- deployment, _ := deployutil.MakeDeployment(config, kapi.Codec) |
|
| 607 |
+ deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 608 | 608 |
deployment.Namespace = namespace |
| 609 | 609 |
return config, deployment |
| 610 | 610 |
} |
| ... | ... |
@@ -11,6 +11,8 @@ import ( |
| 11 | 11 |
|
| 12 | 12 |
deployapi "github.com/openshift/origin/pkg/deploy/api" |
| 13 | 13 |
deploytest "github.com/openshift/origin/pkg/deploy/api/test" |
| 14 |
+ |
|
| 15 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 14 | 16 |
) |
| 15 | 17 |
|
| 16 | 18 |
func podTemplateA() *kapi.PodTemplateSpec {
|
| ... | ... |
@@ -63,7 +65,7 @@ func TestPodName(t *testing.T) {
|
| 63 | 63 |
|
| 64 | 64 |
func TestMakeDeploymentOk(t *testing.T) {
|
| 65 | 65 |
config := deploytest.OkDeploymentConfig(1) |
| 66 |
- deployment, err := MakeDeployment(config, kapi.Codec) |
|
| 66 |
+ deployment, err := MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 67 | 67 |
|
| 68 | 68 |
if err != nil {
|
| 69 | 69 |
t.Fatalf("unexpected error: %#v", err)
|
| ... | ... |
@@ -97,7 +99,7 @@ func TestMakeDeploymentOk(t *testing.T) {
|
| 97 | 97 |
t.Fatalf("expected deployment with DeploymentEncodedConfigAnnotation annotation")
|
| 98 | 98 |
} |
| 99 | 99 |
|
| 100 |
- if decodedConfig, err := DecodeDeploymentConfig(deployment, kapi.Codec); err != nil {
|
|
| 100 |
+ if decodedConfig, err := DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)); err != nil {
|
|
| 101 | 101 |
t.Fatalf("invalid encoded config on deployment: %v", err)
|
| 102 | 102 |
} else {
|
| 103 | 103 |
if e, a := config.Name, decodedConfig.Name; e != a {
|
| ... | ... |
@@ -133,7 +135,7 @@ func TestMakeDeploymentOk(t *testing.T) {
|
| 133 | 133 |
|
| 134 | 134 |
func TestDeploymentsByLatestVersion_sorting(t *testing.T) {
|
| 135 | 135 |
mkdeployment := func(version int) kapi.ReplicationController {
|
| 136 |
- deployment, _ := MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codec) |
|
| 136 |
+ deployment, _ := MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) |
|
| 137 | 137 |
return *deployment |
| 138 | 138 |
} |
| 139 | 139 |
deployments := []kapi.ReplicationController{
|
| ... | ... |
@@ -12,12 +12,16 @@ import ( |
| 12 | 12 |
"github.com/docker/distribution/registry/auth" |
| 13 | 13 |
|
| 14 | 14 |
kapi "k8s.io/kubernetes/pkg/api" |
| 15 |
+ "k8s.io/kubernetes/pkg/apimachinery/registered" |
|
| 15 | 16 |
"k8s.io/kubernetes/pkg/runtime" |
| 16 | 17 |
|
| 17 | 18 |
"github.com/docker/distribution/context" |
| 18 | 19 |
"github.com/openshift/origin/pkg/api/latest" |
| 19 | 20 |
"github.com/openshift/origin/pkg/authorization/api" |
| 20 | 21 |
userapi "github.com/openshift/origin/pkg/user/api" |
| 22 |
+ |
|
| 23 |
+ // install all APIs |
|
| 24 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 21 | 25 |
) |
| 22 | 26 |
|
| 23 | 27 |
// TestVerifyImageStreamAccess mocks openshift http request/response and |
| ... | ... |
@@ -36,7 +40,7 @@ func TestVerifyImageStreamAccess(t *testing.T) {
|
| 36 | 36 |
// Test valid openshift bearer token but token *not* scoped for create operation |
| 37 | 37 |
openshiftResponse: response{
|
| 38 | 38 |
200, |
| 39 |
- runtime.EncodeOrDie(latest.Codec, &api.SubjectAccessReviewResponse{
|
|
| 39 |
+ runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &api.SubjectAccessReviewResponse{
|
|
| 40 | 40 |
Namespace: "foo", |
| 41 | 41 |
Allowed: false, |
| 42 | 42 |
Reason: "not authorized!", |
| ... | ... |
@@ -48,7 +52,7 @@ func TestVerifyImageStreamAccess(t *testing.T) {
|
| 48 | 48 |
// Test valid openshift bearer token and token scoped for create operation |
| 49 | 49 |
openshiftResponse: response{
|
| 50 | 50 |
200, |
| 51 |
- runtime.EncodeOrDie(latest.Codec, &api.SubjectAccessReviewResponse{
|
|
| 51 |
+ runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &api.SubjectAccessReviewResponse{
|
|
| 52 | 52 |
Namespace: "foo", |
| 53 | 53 |
Allowed: true, |
| 54 | 54 |
Reason: "authorized!", |
| ... | ... |
@@ -157,7 +161,7 @@ func TestAccessController(t *testing.T) {
|
| 157 | 157 |
"docker login with valid openshift creds": {
|
| 158 | 158 |
basicToken: "dXNyMTphd2Vzb21l", |
| 159 | 159 |
openshiftResponses: []response{
|
| 160 |
- {200, runtime.EncodeOrDie(latest.Codec, &userapi.User{ObjectMeta: kapi.ObjectMeta{Name: "usr1"}})},
|
|
| 160 |
+ {200, runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &userapi.User{ObjectMeta: kapi.ObjectMeta{Name: "usr1"}})},
|
|
| 161 | 161 |
}, |
| 162 | 162 |
expectedError: nil, |
| 163 | 163 |
expectedChallenge: false, |
| ... | ... |
@@ -189,7 +193,7 @@ func TestAccessController(t *testing.T) {
|
| 189 | 189 |
}}, |
| 190 | 190 |
basicToken: "b3BlbnNoaWZ0OmF3ZXNvbWU=", |
| 191 | 191 |
openshiftResponses: []response{
|
| 192 |
- {200, runtime.EncodeOrDie(latest.Codec, &api.SubjectAccessReviewResponse{Namespace: "foo", Allowed: false, Reason: "unauthorized!"})},
|
|
| 192 |
+ {200, runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &api.SubjectAccessReviewResponse{Namespace: "foo", Allowed: false, Reason: "unauthorized!"})},
|
|
| 193 | 193 |
}, |
| 194 | 194 |
expectedError: ErrOpenShiftAccessDenied, |
| 195 | 195 |
expectedChallenge: true, |
| ... | ... |
@@ -205,10 +209,10 @@ func TestAccessController(t *testing.T) {
|
| 205 | 205 |
}, |
| 206 | 206 |
basicToken: "b3BlbnNoaWZ0OmF3ZXNvbWU=", |
| 207 | 207 |
openshiftResponses: []response{
|
| 208 |
- {200, runtime.EncodeOrDie(latest.Codec, &api.SubjectAccessReviewResponse{Namespace: "foo", Allowed: true, Reason: "authorized!"})},
|
|
| 209 |
- {200, runtime.EncodeOrDie(latest.Codec, &api.SubjectAccessReviewResponse{Namespace: "bar", Allowed: true, Reason: "authorized!"})},
|
|
| 210 |
- {200, runtime.EncodeOrDie(latest.Codec, &api.SubjectAccessReviewResponse{Namespace: "", Allowed: true, Reason: "authorized!"})},
|
|
| 211 |
- {200, runtime.EncodeOrDie(latest.Codec, &api.SubjectAccessReviewResponse{Namespace: "baz", Allowed: false, Reason: "no!"})},
|
|
| 208 |
+ {200, runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &api.SubjectAccessReviewResponse{Namespace: "foo", Allowed: true, Reason: "authorized!"})},
|
|
| 209 |
+ {200, runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &api.SubjectAccessReviewResponse{Namespace: "bar", Allowed: true, Reason: "authorized!"})},
|
|
| 210 |
+ {200, runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &api.SubjectAccessReviewResponse{Namespace: "", Allowed: true, Reason: "authorized!"})},
|
|
| 211 |
+ {200, runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &api.SubjectAccessReviewResponse{Namespace: "baz", Allowed: false, Reason: "no!"})},
|
|
| 212 | 212 |
}, |
| 213 | 213 |
expectedError: ErrOpenShiftAccessDenied, |
| 214 | 214 |
expectedChallenge: true, |
| ... | ... |
@@ -229,7 +233,7 @@ func TestAccessController(t *testing.T) {
|
| 229 | 229 |
}}, |
| 230 | 230 |
basicToken: "b3BlbnNoaWZ0OmF3ZXNvbWU=", |
| 231 | 231 |
openshiftResponses: []response{
|
| 232 |
- {200, runtime.EncodeOrDie(latest.Codec, &api.SubjectAccessReviewResponse{Namespace: "foo", Allowed: true, Reason: "authorized!"})},
|
|
| 232 |
+ {200, runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &api.SubjectAccessReviewResponse{Namespace: "foo", Allowed: true, Reason: "authorized!"})},
|
|
| 233 | 233 |
}, |
| 234 | 234 |
expectedError: nil, |
| 235 | 235 |
expectedChallenge: false, |
| ... | ... |
@@ -253,7 +257,7 @@ func TestAccessController(t *testing.T) {
|
| 253 | 253 |
}, |
| 254 | 254 |
basicToken: "b3BlbnNoaWZ0OmF3ZXNvbWU=", |
| 255 | 255 |
openshiftResponses: []response{
|
| 256 |
- {200, runtime.EncodeOrDie(latest.Codec, &api.SubjectAccessReviewResponse{Allowed: true, Reason: "authorized!"})},
|
|
| 256 |
+ {200, runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), &api.SubjectAccessReviewResponse{Allowed: true, Reason: "authorized!"})},
|
|
| 257 | 257 |
}, |
| 258 | 258 |
expectedError: nil, |
| 259 | 259 |
expectedChallenge: false, |
| ... | ... |
@@ -7,11 +7,13 @@ import ( |
| 7 | 7 |
"testing" |
| 8 | 8 |
|
| 9 | 9 |
kapi "k8s.io/kubernetes/pkg/api" |
| 10 |
+ "k8s.io/kubernetes/pkg/apimachinery/registered" |
|
| 10 | 11 |
"k8s.io/kubernetes/pkg/runtime" |
| 11 | 12 |
|
| 12 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 13 | 13 |
buildapi "github.com/openshift/origin/pkg/build/api" |
| 14 | 14 |
imageapi "github.com/openshift/origin/pkg/image/api" |
| 15 |
+ |
|
| 16 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 15 | 17 |
) |
| 16 | 18 |
|
| 17 | 19 |
func testImageInfo() *imageapi.DockerImage {
|
| ... | ... |
@@ -159,7 +161,7 @@ func TestGenerateSimpleDockerApp(t *testing.T) {
|
| 159 | 159 |
Items: items, |
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 |
- data, err := latest.Codec.Encode(out) |
|
| 162 |
+ data, err := runtime.Encode(kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]), out) |
|
| 163 | 163 |
if err != nil {
|
| 164 | 164 |
log.Fatalf("Unable to generate output: %v", err)
|
| 165 | 165 |
} |
| ... | ... |
@@ -34,6 +34,8 @@ import ( |
| 34 | 34 |
"github.com/openshift/origin/pkg/generate/source" |
| 35 | 35 |
imageapi "github.com/openshift/origin/pkg/image/api" |
| 36 | 36 |
templateapi "github.com/openshift/origin/pkg/template/api" |
| 37 |
+ |
|
| 38 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 37 | 39 |
) |
| 38 | 40 |
|
| 39 | 41 |
func skipExternalGit(t *testing.T) {
|
| ... | ... |
@@ -5,11 +5,14 @@ import ( |
| 5 | 5 |
"testing" |
| 6 | 6 |
|
| 7 | 7 |
kapi "k8s.io/kubernetes/pkg/api" |
| 8 |
+ "k8s.io/kubernetes/pkg/runtime" |
|
| 8 | 9 |
"k8s.io/kubernetes/pkg/util" |
| 9 | 10 |
|
| 10 |
- _ "github.com/openshift/origin/pkg/api/latest" |
|
| 11 | 11 |
newer "github.com/openshift/origin/pkg/image/api" |
| 12 |
+ "github.com/openshift/origin/pkg/image/api/v1" |
|
| 12 | 13 |
testutil "github.com/openshift/origin/test/util/api" |
| 14 |
+ |
|
| 15 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 13 | 16 |
) |
| 14 | 17 |
|
| 15 | 18 |
func TestRoundTripVersionedObject(t *testing.T) {
|
| ... | ... |
@@ -26,12 +29,12 @@ func TestRoundTripVersionedObject(t *testing.T) {
|
| 26 | 26 |
DockerImageReference: "foo/bar/baz", |
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
- data, err := kapi.Scheme.EncodeToVersion(i, "v1") |
|
| 29 |
+ data, err := runtime.Encode(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), i) |
|
| 30 | 30 |
if err != nil {
|
| 31 | 31 |
t.Fatalf("unexpected error: %v", err)
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 |
- obj, err := kapi.Scheme.Decode(data) |
|
| 34 |
+ obj, err := runtime.Decode(kapi.Codecs.UniversalDecoder(), data) |
|
| 35 | 35 |
if err != nil {
|
| 36 | 36 |
t.Fatalf("unexpected error: %v", err)
|
| 37 | 37 |
} |
| ... | ... |
@@ -5,10 +5,13 @@ import ( |
| 5 | 5 |
"testing" |
| 6 | 6 |
|
| 7 | 7 |
kapi "k8s.io/kubernetes/pkg/api" |
| 8 |
+ "k8s.io/kubernetes/pkg/runtime" |
|
| 8 | 9 |
"k8s.io/kubernetes/pkg/util" |
| 9 | 10 |
|
| 10 |
- _ "github.com/openshift/origin/pkg/api/latest" |
|
| 11 | 11 |
newer "github.com/openshift/origin/pkg/image/api" |
| 12 |
+ "github.com/openshift/origin/pkg/image/api/v1beta3" |
|
| 13 |
+ |
|
| 14 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 12 | 15 |
) |
| 13 | 16 |
|
| 14 | 17 |
var Convert = kapi.Scheme.Convert |
| ... | ... |
@@ -26,12 +29,12 @@ func TestRoundTripVersionedObject(t *testing.T) {
|
| 26 | 26 |
DockerImageReference: "foo/bar/baz", |
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
- data, err := kapi.Scheme.EncodeToVersion(i, "v1beta3") |
|
| 29 |
+ data, err := runtime.Encode(kapi.Codecs.LegacyCodec(v1beta3.SchemeGroupVersion), i) |
|
| 30 | 30 |
if err != nil {
|
| 31 | 31 |
t.Fatalf("unexpected error: %v", err)
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 |
- obj, err := kapi.Scheme.Decode(data) |
|
| 34 |
+ obj, err := runtime.Decode(kapi.Codecs.UniversalDecoder(), data) |
|
| 35 | 35 |
if err != nil {
|
| 36 | 36 |
t.Fatalf("unexpected error: %v", err)
|
| 37 | 37 |
} |
| ... | ... |
@@ -184,7 +184,7 @@ func TestValidateImageStream(t *testing.T) {
|
| 184 | 184 |
name191Char := strings.Repeat("b", 191)
|
| 185 | 185 |
name192Char := "x" + name191Char |
| 186 | 186 |
|
| 187 |
- missingNameErr := field.Required(field.NewPath("metadata", "name"))
|
|
| 187 |
+ missingNameErr := field.Required(field.NewPath("metadata", "name"), "")
|
|
| 188 | 188 |
missingNameErr.Detail = "name or generateName is required" |
| 189 | 189 |
|
| 190 | 190 |
tests := map[string]struct {
|
| ... | ... |
@@ -225,7 +225,7 @@ func TestValidateImageStream(t *testing.T) {
|
| 225 | 225 |
namespace: "", |
| 226 | 226 |
name: "foo", |
| 227 | 227 |
expected: field.ErrorList{
|
| 228 |
- field.Required(field.NewPath("metadata", "namespace")),
|
|
| 228 |
+ field.Required(field.NewPath("metadata", "namespace"), ""),
|
|
| 229 | 229 |
}, |
| 230 | 230 |
}, |
| 231 | 231 |
"invalid namespace": {
|
| ... | ... |
@@ -272,8 +272,8 @@ func TestValidateImageStream(t *testing.T) {
|
| 272 | 272 |
}, |
| 273 | 273 |
}, |
| 274 | 274 |
expected: field.ErrorList{
|
| 275 |
- field.Required(field.NewPath("status", "tags").Key("tag").Child("items").Index(0).Child("dockerImageReference")),
|
|
| 276 |
- field.Required(field.NewPath("status", "tags").Key("tag").Child("items").Index(2).Child("dockerImageReference")),
|
|
| 275 |
+ field.Required(field.NewPath("status", "tags").Key("tag").Child("items").Index(0).Child("dockerImageReference"), ""),
|
|
| 276 |
+ field.Required(field.NewPath("status", "tags").Key("tag").Child("items").Index(2).Child("dockerImageReference"), ""),
|
|
| 277 | 277 |
}, |
| 278 | 278 |
}, |
| 279 | 279 |
"ImageStreamTags can't be scheduled": {
|
| ... | ... |
@@ -453,7 +453,7 @@ func TestValidateImageStreamImport(t *testing.T) {
|
| 453 | 453 |
name191Char := strings.Repeat("b", 191)
|
| 454 | 454 |
name192Char := "x" + name191Char |
| 455 | 455 |
|
| 456 |
- missingNameErr := field.Required(field.NewPath("metadata", "name"))
|
|
| 456 |
+ missingNameErr := field.Required(field.NewPath("metadata", "name"), "")
|
|
| 457 | 457 |
missingNameErr.Detail = "name or generateName is required" |
| 458 | 458 |
|
| 459 | 459 |
validMeta := kapi.ObjectMeta{Namespace: "foo", Name: "foo"}
|
| ... | ... |
@@ -497,7 +497,7 @@ func TestValidateImageStreamImport(t *testing.T) {
|
| 497 | 497 |
"missing namespace": {
|
| 498 | 498 |
isi: &api.ImageStreamImport{ObjectMeta: kapi.ObjectMeta{Name: "foo"}, Spec: validSpec},
|
| 499 | 499 |
expected: field.ErrorList{
|
| 500 |
- field.Required(field.NewPath("metadata", "namespace")),
|
|
| 500 |
+ field.Required(field.NewPath("metadata", "namespace"), ""),
|
|
| 501 | 501 |
}, |
| 502 | 502 |
}, |
| 503 | 503 |
"invalid namespace": {
|
| ... | ... |
@@ -13,6 +13,8 @@ import ( |
| 13 | 13 |
client "github.com/openshift/origin/pkg/client/testclient" |
| 14 | 14 |
"github.com/openshift/origin/pkg/dockerregistry" |
| 15 | 15 |
"github.com/openshift/origin/pkg/image/api" |
| 16 |
+ |
|
| 17 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 16 | 18 |
) |
| 17 | 19 |
|
| 18 | 20 |
type expectedImage struct {
|
| ... | ... |
@@ -394,7 +396,7 @@ func TestScheduledImport(t *testing.T) {
|
| 394 | 394 |
} |
| 395 | 395 |
|
| 396 | 396 |
// encountering a not found error for image streams should drop the controller |
| 397 |
- status := apierrs.NewNotFound("imageStreams", "test").(*apierrs.StatusError).ErrStatus
|
|
| 397 |
+ status := apierrs.NewNotFound(api.Resource("imagestream"), "test").(*apierrs.StatusError).ErrStatus
|
|
| 398 | 398 |
fake = client.NewSimpleFake(&status) |
| 399 | 399 |
b.controller.streams = fake |
| 400 | 400 |
b.scheduler.RunOnce() |
| ... | ... |
@@ -9,7 +9,9 @@ import ( |
| 9 | 9 |
docker "github.com/fsouza/go-dockerclient" |
| 10 | 10 |
|
| 11 | 11 |
kapi "k8s.io/kubernetes/pkg/api" |
| 12 |
- _ "k8s.io/kubernetes/pkg/api/v1" |
|
| 12 |
+ "k8s.io/kubernetes/pkg/runtime" |
|
| 13 |
+ |
|
| 14 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 13 | 15 |
) |
| 14 | 16 |
|
| 15 | 17 |
func TestCredentialsForSecrets(t *testing.T) {
|
| ... | ... |
@@ -17,7 +19,7 @@ func TestCredentialsForSecrets(t *testing.T) {
|
| 17 | 17 |
if err != nil {
|
| 18 | 18 |
t.Fatal(err) |
| 19 | 19 |
} |
| 20 |
- obj, err := kapi.Codec.Decode(data) |
|
| 20 |
+ obj, err := runtime.Decode(kapi.Codecs.UniversalDecoder(), data) |
|
| 21 | 21 |
if err != nil {
|
| 22 | 22 |
t.Fatal(err) |
| 23 | 23 |
} |
| ... | ... |
@@ -142,7 +142,7 @@ func TestImport(t *testing.T) {
|
| 142 | 142 |
if !expectStatusError(isi.Status.Images[1].Status, "Internal error occurred: no such digest") {
|
| 143 | 143 |
t.Errorf("unexpected status: %#v", isi.Status.Images[1].Status)
|
| 144 | 144 |
} |
| 145 |
- if !expectStatusError(isi.Status.Images[2].Status, " \"\" is invalid: from.name: invalid value 'test/un/parse/able/image', Details: invalid name: the docker pull spec \"test/un/parse/able/image\" must be two or three segments separated by slashes") {
|
|
| 145 |
+ if !expectStatusError(isi.Status.Images[2].Status, " \"\" is invalid: from.name: Invalid value: \"test/un/parse/able/image\": invalid name: the docker pull spec \"test/un/parse/able/image\" must be two or three segments separated by slashes") {
|
|
| 146 | 146 |
t.Errorf("unexpected status: %#v", isi.Status.Images[2].Status)
|
| 147 | 147 |
} |
| 148 | 148 |
// non DockerImage refs are no-ops |
| ... | ... |
@@ -12,6 +12,9 @@ import ( |
| 12 | 12 |
"github.com/openshift/origin/pkg/api/latest" |
| 13 | 13 |
"github.com/openshift/origin/pkg/image/api" |
| 14 | 14 |
"github.com/openshift/origin/pkg/image/registry/image" |
| 15 |
+ |
|
| 16 |
+ // install all APIs |
|
| 17 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 15 | 18 |
) |
| 16 | 19 |
|
| 17 | 20 |
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) {
|
| ... | ... |
@@ -14,6 +14,9 @@ import ( |
| 14 | 14 |
"github.com/openshift/origin/pkg/authorization/registry/subjectaccessreview" |
| 15 | 15 |
"github.com/openshift/origin/pkg/image/api" |
| 16 | 16 |
"github.com/openshift/origin/pkg/image/registry/imagestream" |
| 17 |
+ |
|
| 18 |
+ // install all APIs |
|
| 19 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 17 | 20 |
) |
| 18 | 21 |
|
| 19 | 22 |
const ( |
| ... | ... |
@@ -6,12 +6,12 @@ import ( |
| 6 | 6 |
goetcd "github.com/coreos/go-etcd/etcd" |
| 7 | 7 |
|
| 8 | 8 |
kapi "k8s.io/kubernetes/pkg/api" |
| 9 |
+ "k8s.io/kubernetes/pkg/api/v1" |
|
| 9 | 10 |
"k8s.io/kubernetes/pkg/registry/registrytest" |
| 10 | 11 |
"k8s.io/kubernetes/pkg/runtime" |
| 11 | 12 |
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest" |
| 12 | 13 |
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" |
| 13 | 14 |
|
| 14 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 15 | 15 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
| 16 | 16 |
"github.com/openshift/origin/pkg/authorization/registry/subjectaccessreview" |
| 17 | 17 |
"github.com/openshift/origin/pkg/image/api" |
| ... | ... |
@@ -19,6 +19,8 @@ import ( |
| 19 | 19 |
imageetcd "github.com/openshift/origin/pkg/image/registry/image/etcd" |
| 20 | 20 |
"github.com/openshift/origin/pkg/image/registry/imagestream" |
| 21 | 21 |
imagestreametcd "github.com/openshift/origin/pkg/image/registry/imagestream/etcd" |
| 22 |
+ |
|
| 23 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 22 | 24 |
) |
| 23 | 25 |
|
| 24 | 26 |
var testDefaultRegistry = imagestream.DefaultRegistryFunc(func() (string, bool) { return "defaultregistry:5000", true })
|
| ... | ... |
@@ -35,6 +37,7 @@ func (f *fakeSubjectAccessReviewRegistry) CreateSubjectAccessReview(ctx kapi.Con |
| 35 | 35 |
func setup(t *testing.T) (*goetcd.Client, *etcdtesting.EtcdTestServer, *REST) {
|
| 36 | 36 |
|
| 37 | 37 |
etcdStorage, server := registrytest.NewEtcdStorage(t, "") |
| 38 |
+ etcdClient := goetcd.NewClient(server.ClientURLs.StringSlice()) |
|
| 38 | 39 |
|
| 39 | 40 |
imageStorage := imageetcd.NewREST(etcdStorage) |
| 40 | 41 |
imageStreamStorage, imageStreamStatus, internalStorage := imagestreametcd.NewREST(etcdStorage, testDefaultRegistry, &fakeSubjectAccessReviewRegistry{})
|
| ... | ... |
@@ -44,7 +47,7 @@ func setup(t *testing.T) (*goetcd.Client, *etcdtesting.EtcdTestServer, *REST) {
|
| 44 | 44 |
|
| 45 | 45 |
storage := NewREST(imageRegistry, imageStreamRegistry) |
| 46 | 46 |
|
| 47 |
- return server.Client, server, storage |
|
| 47 |
+ return etcdClient, server, storage |
|
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 | 50 |
func TestNameAndID(t *testing.T) {
|
| ... | ... |
@@ -245,14 +248,14 @@ func TestGet(t *testing.T) {
|
| 245 | 245 |
ctx := kapi.NewDefaultContext() |
| 246 | 246 |
if test.repo != nil {
|
| 247 | 247 |
ctx = kapi.WithNamespace(kapi.NewContext(), test.repo.Namespace) |
| 248 |
- _, err := client.Create(etcdtest.AddPrefix("/imagestreams/"+test.repo.Namespace+"/"+test.repo.Name), runtime.EncodeOrDie(latest.Codec, test.repo), 0)
|
|
| 248 |
+ _, err := client.Create(etcdtest.AddPrefix("/imagestreams/"+test.repo.Namespace+"/"+test.repo.Name), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), test.repo), 0)
|
|
| 249 | 249 |
if err != nil {
|
| 250 | 250 |
t.Errorf("Unexpected error: %v", err)
|
| 251 | 251 |
continue |
| 252 | 252 |
} |
| 253 | 253 |
} |
| 254 | 254 |
if test.image != nil {
|
| 255 |
- _, err := client.Create(etcdtest.AddPrefix("/images/"+test.image.Name), runtime.EncodeOrDie(latest.Codec, test.image), 0)
|
|
| 255 |
+ _, err := client.Create(etcdtest.AddPrefix("/images/"+test.image.Name), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), test.image), 0)
|
|
| 256 | 256 |
if err != nil {
|
| 257 | 257 |
t.Errorf("Unexpected error: %v", err)
|
| 258 | 258 |
continue |
| ... | ... |
@@ -12,13 +12,13 @@ import ( |
| 12 | 12 |
kapi "k8s.io/kubernetes/pkg/api" |
| 13 | 13 |
"k8s.io/kubernetes/pkg/api/errors" |
| 14 | 14 |
"k8s.io/kubernetes/pkg/api/unversioned" |
| 15 |
+ "k8s.io/kubernetes/pkg/api/v1" |
|
| 15 | 16 |
"k8s.io/kubernetes/pkg/registry/registrytest" |
| 16 | 17 |
"k8s.io/kubernetes/pkg/runtime" |
| 17 | 18 |
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest" |
| 18 | 19 |
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" |
| 19 | 20 |
"k8s.io/kubernetes/pkg/watch" |
| 20 | 21 |
|
| 21 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 22 | 22 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
| 23 | 23 |
"github.com/openshift/origin/pkg/authorization/registry/subjectaccessreview" |
| 24 | 24 |
"github.com/openshift/origin/pkg/image/api" |
| ... | ... |
@@ -26,6 +26,8 @@ import ( |
| 26 | 26 |
imageetcd "github.com/openshift/origin/pkg/image/registry/image/etcd" |
| 27 | 27 |
"github.com/openshift/origin/pkg/image/registry/imagestream" |
| 28 | 28 |
imagestreametcd "github.com/openshift/origin/pkg/image/registry/imagestream/etcd" |
| 29 |
+ |
|
| 30 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 29 | 31 |
) |
| 30 | 32 |
|
| 31 | 33 |
var testDefaultRegistry = imagestream.DefaultRegistryFunc(func() (string, bool) { return "defaultregistry:5000", true })
|
| ... | ... |
@@ -42,6 +44,7 @@ func (f *fakeSubjectAccessReviewRegistry) CreateSubjectAccessReview(ctx kapi.Con |
| 42 | 42 |
func setup(t *testing.T) (*etcd.Client, *etcdtesting.EtcdTestServer, *REST) {
|
| 43 | 43 |
|
| 44 | 44 |
etcdStorage, server := registrytest.NewEtcdStorage(t, "") |
| 45 |
+ etcdClient := etcd.NewClient(server.ClientURLs.StringSlice()) |
|
| 45 | 46 |
|
| 46 | 47 |
imageStorage := imageetcd.NewREST(etcdStorage) |
| 47 | 48 |
imageStreamStorage, imageStreamStatus, internalStorage := imagestreametcd.NewREST(etcdStorage, testDefaultRegistry, &fakeSubjectAccessReviewRegistry{})
|
| ... | ... |
@@ -51,7 +54,7 @@ func setup(t *testing.T) (*etcd.Client, *etcdtesting.EtcdTestServer, *REST) {
|
| 51 | 51 |
|
| 52 | 52 |
storage := NewREST(imageRegistry, imageStreamRegistry) |
| 53 | 53 |
|
| 54 |
- return server.Client, server, storage |
|
| 54 |
+ return etcdClient, server, storage |
|
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 | 57 |
func validImageStream() *api.ImageStream {
|
| ... | ... |
@@ -126,7 +129,7 @@ func TestCreateImageStreamNotFoundWithName(t *testing.T) {
|
| 126 | 126 |
if e, a := http.StatusNotFound, e.ErrStatus.Code; int32(e) != a {
|
| 127 | 127 |
t.Errorf("error status code: expected %d, got %d", e, a)
|
| 128 | 128 |
} |
| 129 |
- if e, a := "imageStream", e.ErrStatus.Details.Kind; e != a {
|
|
| 129 |
+ if e, a := "imagestreams", e.ErrStatus.Details.Kind; e != a {
|
|
| 130 | 130 |
t.Errorf("error status details kind: expected %s, got %s", e, a)
|
| 131 | 131 |
} |
| 132 | 132 |
if e, a := "somerepo", e.ErrStatus.Details.Name; e != a {
|
| ... | ... |
@@ -142,7 +145,7 @@ func TestCreateSuccessWithName(t *testing.T) {
|
| 142 | 142 |
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "somerepo"},
|
| 143 | 143 |
} |
| 144 | 144 |
|
| 145 |
- _, err := client.Create(etcdtest.AddPrefix("/imagestreams/default/somerepo"), runtime.EncodeOrDie(latest.Codec, initialRepo), 0)
|
|
| 145 |
+ _, err := client.Create(etcdtest.AddPrefix("/imagestreams/default/somerepo"), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), initialRepo), 0)
|
|
| 146 | 146 |
if err != nil {
|
| 147 | 147 |
t.Fatalf("Unexpected error: %v", err)
|
| 148 | 148 |
} |
| ... | ... |
@@ -220,12 +223,12 @@ func TestAddExistingImageWithNewTag(t *testing.T) {
|
| 220 | 220 |
client, server, storage := setup(t) |
| 221 | 221 |
defer server.Terminate(t) |
| 222 | 222 |
|
| 223 |
- _, err := client.Create(etcdtest.AddPrefix("/imagestreams/default/somerepo"), runtime.EncodeOrDie(latest.Codec, existingRepo), 0)
|
|
| 223 |
+ _, err := client.Create(etcdtest.AddPrefix("/imagestreams/default/somerepo"), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), existingRepo), 0)
|
|
| 224 | 224 |
if err != nil {
|
| 225 | 225 |
t.Fatalf("Unexpected error: %v", err)
|
| 226 | 226 |
} |
| 227 | 227 |
|
| 228 |
- _, err = client.Create(etcdtest.AddPrefix("/images/default/"+imageID), runtime.EncodeOrDie(latest.Codec, existingImage), 0)
|
|
| 228 |
+ _, err = client.Create(etcdtest.AddPrefix("/images/default/"+imageID), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), existingImage), 0)
|
|
| 229 | 229 |
if err != nil {
|
| 230 | 230 |
t.Fatalf("Unexpected error: %v", err)
|
| 231 | 231 |
} |
| ... | ... |
@@ -282,12 +285,12 @@ func TestAddExistingImageAndTag(t *testing.T) {
|
| 282 | 282 |
client, server, storage := setup(t) |
| 283 | 283 |
defer server.Terminate(t) |
| 284 | 284 |
|
| 285 |
- _, err := client.Create(etcdtest.AddPrefix("/imagestreams/default/somerepo"), runtime.EncodeOrDie(latest.Codec, existingRepo), 0)
|
|
| 285 |
+ _, err := client.Create(etcdtest.AddPrefix("/imagestreams/default/somerepo"), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), existingRepo), 0)
|
|
| 286 | 286 |
if err != nil {
|
| 287 | 287 |
t.Fatalf("Unexpected error: %v", err)
|
| 288 | 288 |
} |
| 289 | 289 |
|
| 290 |
- _, err = client.Create(etcdtest.AddPrefix("/images/default/existingImage"), runtime.EncodeOrDie(latest.Codec, existingImage), 0)
|
|
| 290 |
+ _, err = client.Create(etcdtest.AddPrefix("/images/default/existingImage"), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), existingImage), 0)
|
|
| 291 | 291 |
if err != nil {
|
| 292 | 292 |
t.Fatalf("Unexpected error: %v", err)
|
| 293 | 293 |
} |
| ... | ... |
@@ -357,7 +360,7 @@ func TestTrackingTags(t *testing.T) {
|
| 357 | 357 |
}, |
| 358 | 358 |
} |
| 359 | 359 |
|
| 360 |
- _, err := client.Create(etcdtest.AddPrefix("/imagestreams/default/stream"), runtime.EncodeOrDie(latest.Codec, stream), 0)
|
|
| 360 |
+ _, err := client.Create(etcdtest.AddPrefix("/imagestreams/default/stream"), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), stream), 0)
|
|
| 361 | 361 |
if err != nil {
|
| 362 | 362 |
t.Fatalf("Unexpected error: %v", err)
|
| 363 | 363 |
} |
| ... | ... |
@@ -472,7 +475,7 @@ func TestCreateRetryConflictNoTagDiff(t *testing.T) {
|
| 472 | 472 |
// image stream whose tags haven't changed. |
| 473 | 473 |
if firstUpdate {
|
| 474 | 474 |
firstUpdate = false |
| 475 |
- return nil, errors.NewConflict("ImageStream", repo.Name, fmt.Errorf("resource modified"))
|
|
| 475 |
+ return nil, errors.NewConflict(api.Resource("imagestreams"), repo.Name, fmt.Errorf("resource modified"))
|
|
| 476 | 476 |
} |
| 477 | 477 |
return repo, nil |
| 478 | 478 |
}, |
| ... | ... |
@@ -526,7 +529,7 @@ func TestCreateRetryConflictTagDiff(t *testing.T) {
|
| 526 | 526 |
// get/compare is retried. |
| 527 | 527 |
if firstUpdate {
|
| 528 | 528 |
firstUpdate = false |
| 529 |
- return nil, errors.NewConflict("ImageStream", repo.Name, fmt.Errorf("resource modified"))
|
|
| 529 |
+ return nil, errors.NewConflict(api.Resource("imagestreams"), repo.Name, fmt.Errorf("resource modified"))
|
|
| 530 | 530 |
} |
| 531 | 531 |
return repo, nil |
| 532 | 532 |
}, |
| ... | ... |
@@ -9,13 +9,13 @@ import ( |
| 9 | 9 |
kapi "k8s.io/kubernetes/pkg/api" |
| 10 | 10 |
"k8s.io/kubernetes/pkg/api/errors" |
| 11 | 11 |
"k8s.io/kubernetes/pkg/api/unversioned" |
| 12 |
+ "k8s.io/kubernetes/pkg/api/v1" |
|
| 12 | 13 |
"k8s.io/kubernetes/pkg/auth/user" |
| 13 | 14 |
"k8s.io/kubernetes/pkg/registry/registrytest" |
| 14 | 15 |
"k8s.io/kubernetes/pkg/runtime" |
| 15 | 16 |
"k8s.io/kubernetes/pkg/storage/etcd/etcdtest" |
| 16 | 17 |
etcdtesting "k8s.io/kubernetes/pkg/storage/etcd/testing" |
| 17 | 18 |
|
| 18 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 19 | 19 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
| 20 | 20 |
"github.com/openshift/origin/pkg/authorization/registry/subjectaccessreview" |
| 21 | 21 |
"github.com/openshift/origin/pkg/image/api" |
| ... | ... |
@@ -23,6 +23,8 @@ import ( |
| 23 | 23 |
imageetcd "github.com/openshift/origin/pkg/image/registry/image/etcd" |
| 24 | 24 |
"github.com/openshift/origin/pkg/image/registry/imagestream" |
| 25 | 25 |
imagestreametcd "github.com/openshift/origin/pkg/image/registry/imagestream/etcd" |
| 26 |
+ |
|
| 27 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 26 | 28 |
) |
| 27 | 29 |
|
| 28 | 30 |
var testDefaultRegistry = imagestream.DefaultRegistryFunc(func() (string, bool) { return "defaultregistry:5000", true })
|
| ... | ... |
@@ -56,6 +58,7 @@ func (u *fakeUser) GetGroups() []string {
|
| 56 | 56 |
func setup(t *testing.T) (*etcd.Client, *etcdtesting.EtcdTestServer, *REST) {
|
| 57 | 57 |
|
| 58 | 58 |
etcdStorage, server := registrytest.NewEtcdStorage(t, "") |
| 59 |
+ etcdClient := etcd.NewClient(server.ClientURLs.StringSlice()) |
|
| 59 | 60 |
|
| 60 | 61 |
imageStorage := imageetcd.NewREST(etcdStorage) |
| 61 | 62 |
imageStreamStorage, imageStreamStatus, internalStorage := imagestreametcd.NewREST(etcdStorage, testDefaultRegistry, &fakeSubjectAccessReviewRegistry{})
|
| ... | ... |
@@ -65,7 +68,7 @@ func setup(t *testing.T) (*etcd.Client, *etcdtesting.EtcdTestServer, *REST) {
|
| 65 | 65 |
|
| 66 | 66 |
storage := NewREST(imageRegistry, imageStreamRegistry) |
| 67 | 67 |
|
| 68 |
- return server.Client, server, storage |
|
| 68 |
+ return etcdClient, server, storage |
|
| 69 | 69 |
} |
| 70 | 70 |
|
| 71 | 71 |
type statusError interface {
|
| ... | ... |
@@ -174,7 +177,7 @@ func TestGetImageStreamTag(t *testing.T) {
|
| 174 | 174 |
}, |
| 175 | 175 |
}}, |
| 176 | 176 |
expectError: true, |
| 177 |
- errorTargetKind: "imageStreamTag", |
|
| 177 |
+ errorTargetKind: "imagestreamtag", |
|
| 178 | 178 |
errorTargetID: "test:latest", |
| 179 | 179 |
}, |
| 180 | 180 |
"missing image": {
|
| ... | ... |
@@ -189,7 +192,7 @@ func TestGetImageStreamTag(t *testing.T) {
|
| 189 | 189 |
}, |
| 190 | 190 |
"missing repo": {
|
| 191 | 191 |
expectError: true, |
| 192 |
- errorTargetKind: "imageStream", |
|
| 192 |
+ errorTargetKind: "imagestreams", |
|
| 193 | 193 |
errorTargetID: "test", |
| 194 | 194 |
}, |
| 195 | 195 |
"missing tag": {
|
| ... | ... |
@@ -202,7 +205,7 @@ func TestGetImageStreamTag(t *testing.T) {
|
| 202 | 202 |
}, |
| 203 | 203 |
}}, |
| 204 | 204 |
expectError: true, |
| 205 |
- errorTargetKind: "imageStreamTag", |
|
| 205 |
+ errorTargetKind: "imagestreamtag", |
|
| 206 | 206 |
errorTargetID: "test:latest", |
| 207 | 207 |
}, |
| 208 | 208 |
} |
| ... | ... |
@@ -212,10 +215,10 @@ func TestGetImageStreamTag(t *testing.T) {
|
| 212 | 212 |
defer server.Terminate(t) |
| 213 | 213 |
|
| 214 | 214 |
if testCase.image != nil {
|
| 215 |
- client.Create(etcdtest.AddPrefix("/images/"+testCase.image.Name), runtime.EncodeOrDie(latest.Codec, testCase.image), 0)
|
|
| 215 |
+ client.Create(etcdtest.AddPrefix("/images/"+testCase.image.Name), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), testCase.image), 0)
|
|
| 216 | 216 |
} |
| 217 | 217 |
if testCase.repo != nil {
|
| 218 |
- client.Create(etcdtest.AddPrefix("/imagestreams/default/test"), runtime.EncodeOrDie(latest.Codec, testCase.repo), 0)
|
|
| 218 |
+ client.Create(etcdtest.AddPrefix("/imagestreams/default/test"), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), testCase.repo), 0)
|
|
| 219 | 219 |
} |
| 220 | 220 |
|
| 221 | 221 |
obj, err := storage.Get(kapi.NewDefaultContext(), "test:latest") |
| ... | ... |
@@ -277,8 +280,8 @@ func TestGetImageStreamTagDIR(t *testing.T) {
|
| 277 | 277 |
|
| 278 | 278 |
client, server, storage := setup(t) |
| 279 | 279 |
defer server.Terminate(t) |
| 280 |
- client.Create(etcdtest.AddPrefix("/images/"+image.Name), runtime.EncodeOrDie(latest.Codec, image), 0)
|
|
| 281 |
- client.Create(etcdtest.AddPrefix("/imagestreams/default/test"), runtime.EncodeOrDie(latest.Codec, repo), 0)
|
|
| 280 |
+ client.Create(etcdtest.AddPrefix("/images/"+image.Name), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), image), 0)
|
|
| 281 |
+ client.Create(etcdtest.AddPrefix("/imagestreams/default/test"), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), repo), 0)
|
|
| 282 | 282 |
obj, err := storage.Get(kapi.NewDefaultContext(), "test:latest") |
| 283 | 283 |
if err != nil {
|
| 284 | 284 |
t.Fatalf("Unexpected error: %v", err)
|
| ... | ... |
@@ -398,7 +401,7 @@ func TestDeleteImageStreamTag(t *testing.T) {
|
| 398 | 398 |
defer server.Terminate(t) |
| 399 | 399 |
|
| 400 | 400 |
if testCase.repo != nil {
|
| 401 |
- client.Create(etcdtest.AddPrefix("/imagestreams/default/test"), runtime.EncodeOrDie(latest.Codec, testCase.repo), 0)
|
|
| 401 |
+ client.Create(etcdtest.AddPrefix("/imagestreams/default/test"), runtime.EncodeOrDie(kapi.Codecs.LegacyCodec(v1.SchemeGroupVersion), testCase.repo), 0)
|
|
| 402 | 402 |
} |
| 403 | 403 |
|
| 404 | 404 |
ctx := kapi.WithUser(kapi.NewDefaultContext(), &fakeUser{})
|
| ... | ... |
@@ -1,10 +1,13 @@ |
| 1 |
-package v1 |
|
| 1 |
+package v1_test |
|
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 | 6 |
"github.com/openshift/origin/pkg/oauth/api" |
| 7 | 7 |
testutil "github.com/openshift/origin/test/util/api" |
| 8 |
+ |
|
| 9 |
+ // install all APIs |
|
| 10 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 8 | 11 |
) |
| 9 | 12 |
|
| 10 | 13 |
func TestFieldSelectorConversions(t *testing.T) {
|
| ... | ... |
@@ -128,7 +128,7 @@ func TestValidateClientAuthorization(t *testing.T) {
|
| 128 | 128 |
UserName: "myusername", |
| 129 | 129 |
UserUID: "myuseruid", |
| 130 | 130 |
}, |
| 131 |
- T: field.ErrorTypeInvalid, |
|
| 131 |
+ T: field.ErrorTypeForbidden, |
|
| 132 | 132 |
F: "metadata.namespace", |
| 133 | 133 |
}, |
| 134 | 134 |
} |
| ... | ... |
@@ -140,10 +140,10 @@ func TestValidateClientAuthorization(t *testing.T) {
|
| 140 | 140 |
} |
| 141 | 141 |
for i := range errs {
|
| 142 | 142 |
if errs[i].Type != v.T {
|
| 143 |
- t.Errorf("%s: expected errors to have type %s: %v", k, v.T, errs[i])
|
|
| 143 |
+ t.Errorf("%s: expected errors to have type %s GOT: %v", k, v.T, errs[i])
|
|
| 144 | 144 |
} |
| 145 | 145 |
if errs[i].Field != v.F {
|
| 146 |
- t.Errorf("%s: expected errors to have field %s: %v", k, v.F, errs[i])
|
|
| 146 |
+ t.Errorf("%s: expected errors to have field %s GOT: %v", k, v.F, errs[i])
|
|
| 147 | 147 |
} |
| 148 | 148 |
} |
| 149 | 149 |
} |
| ... | ... |
@@ -169,7 +169,7 @@ func TestValidateClient(t *testing.T) {
|
| 169 | 169 |
}, |
| 170 | 170 |
"disallowed namespace": {
|
| 171 | 171 |
Client: oapi.OAuthClient{ObjectMeta: api.ObjectMeta{Name: "name", Namespace: "foo"}},
|
| 172 |
- T: field.ErrorTypeInvalid, |
|
| 172 |
+ T: field.ErrorTypeForbidden, |
|
| 173 | 173 |
F: "metadata.namespace", |
| 174 | 174 |
}, |
| 175 | 175 |
} |
| ... | ... |
@@ -222,7 +222,7 @@ func TestValidateAccessTokens(t *testing.T) {
|
| 222 | 222 |
UserName: "myusername", |
| 223 | 223 |
UserUID: "myuseruid", |
| 224 | 224 |
}, |
| 225 |
- T: field.ErrorTypeInvalid, |
|
| 225 |
+ T: field.ErrorTypeForbidden, |
|
| 226 | 226 |
F: "metadata.namespace", |
| 227 | 227 |
}, |
| 228 | 228 |
} |
| ... | ... |
@@ -302,7 +302,7 @@ func TestValidateAuthorizeTokens(t *testing.T) {
|
| 302 | 302 |
UserName: "myusername", |
| 303 | 303 |
UserUID: "myuseruid", |
| 304 | 304 |
}, |
| 305 |
- T: field.ErrorTypeInvalid, |
|
| 305 |
+ T: field.ErrorTypeForbidden, |
|
| 306 | 306 |
F: "metadata.namespace", |
| 307 | 307 |
}, |
| 308 | 308 |
} |
| ... | ... |
@@ -7,6 +7,7 @@ import ( |
| 7 | 7 |
|
| 8 | 8 |
"k8s.io/kubernetes/pkg/admission" |
| 9 | 9 |
kapi "k8s.io/kubernetes/pkg/api" |
| 10 |
+ "k8s.io/kubernetes/pkg/api/unversioned" |
|
| 10 | 11 |
"k8s.io/kubernetes/pkg/client/cache" |
| 11 | 12 |
"k8s.io/kubernetes/pkg/client/unversioned/testclient" |
| 12 | 13 |
kubeletclient "k8s.io/kubernetes/pkg/kubelet/client" |
| ... | ... |
@@ -17,11 +18,16 @@ import ( |
| 17 | 17 |
buildapi "github.com/openshift/origin/pkg/build/api" |
| 18 | 18 |
"github.com/openshift/origin/pkg/cmd/server/origin" |
| 19 | 19 |
projectcache "github.com/openshift/origin/pkg/project/cache" |
| 20 |
+ |
|
| 21 |
+ // install all APIs |
|
| 22 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 20 | 23 |
) |
| 21 | 24 |
|
| 22 |
-type UnknownObject struct{}
|
|
| 25 |
+type UnknownObject struct {
|
|
| 26 |
+ unversioned.TypeMeta |
|
| 27 |
+} |
|
| 23 | 28 |
|
| 24 |
-func (*UnknownObject) IsAnAPIObject() {}
|
|
| 29 |
+func (obj *UnknownObject) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
|
| 25 | 30 |
|
| 26 | 31 |
// TestIgnoreThatWhichCannotBeKnown verifies that the plug-in does not reject objects that are unknown to RESTMapper |
| 27 | 32 |
func TestIgnoreThatWhichCannotBeKnown(t *testing.T) {
|
| ... | ... |
@@ -14,17 +14,21 @@ import ( |
| 14 | 14 |
|
| 15 | 15 |
"github.com/openshift/origin/pkg/client/testclient" |
| 16 | 16 |
oadmission "github.com/openshift/origin/pkg/cmd/server/admission" |
| 17 |
+ requestlimitapi "github.com/openshift/origin/pkg/project/admission/requestlimit/api" |
|
| 17 | 18 |
projectapi "github.com/openshift/origin/pkg/project/api" |
| 18 | 19 |
projectcache "github.com/openshift/origin/pkg/project/cache" |
| 19 | 20 |
userapi "github.com/openshift/origin/pkg/user/api" |
| 20 | 21 |
apierrors "k8s.io/kubernetes/pkg/api/errors" |
| 22 |
+ |
|
| 23 |
+ // install all APIs |
|
| 24 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 21 | 25 |
) |
| 22 | 26 |
|
| 23 | 27 |
func TestReadConfig(t *testing.T) {
|
| 24 | 28 |
|
| 25 | 29 |
tests := []struct {
|
| 26 | 30 |
config string |
| 27 |
- expected ProjectRequestLimitConfig |
|
| 31 |
+ expected requestlimitapi.ProjectRequestLimitConfig |
|
| 28 | 32 |
errExpected bool |
| 29 | 33 |
}{
|
| 30 | 34 |
{
|
| ... | ... |
@@ -50,8 +54,8 @@ limits: |
| 50 | 50 |
- selector: {}
|
| 51 | 51 |
maxProjects: 1 |
| 52 | 52 |
`, |
| 53 |
- expected: ProjectRequestLimitConfig{
|
|
| 54 |
- Limits: []ProjectLimitBySelector{
|
|
| 53 |
+ expected: requestlimitapi.ProjectRequestLimitConfig{
|
|
| 54 |
+ Limits: []requestlimitapi.ProjectLimitBySelector{
|
|
| 55 | 55 |
{
|
| 56 | 56 |
Selector: map[string]string{"level": "platinum"},
|
| 57 | 57 |
MaxProjects: nil, |
| ... | ... |
@@ -82,8 +86,8 @@ kind: ProjectRequestLimitConfig |
| 82 | 82 |
limits: |
| 83 | 83 |
- maxProjects: 1 |
| 84 | 84 |
`, |
| 85 |
- expected: ProjectRequestLimitConfig{
|
|
| 86 |
- Limits: []ProjectLimitBySelector{
|
|
| 85 |
+ expected: requestlimitapi.ProjectRequestLimitConfig{
|
|
| 86 |
+ Limits: []requestlimitapi.ProjectLimitBySelector{
|
|
| 87 | 87 |
{
|
| 88 | 88 |
Selector: nil, |
| 89 | 89 |
MaxProjects: intp(1), |
| ... | ... |
@@ -96,7 +100,7 @@ limits: |
| 96 | 96 |
config: `apiVersion: v1 |
| 97 | 97 |
kind: ProjectRequestLimitConfig |
| 98 | 98 |
`, |
| 99 |
- expected: ProjectRequestLimitConfig{},
|
|
| 99 |
+ expected: requestlimitapi.ProjectRequestLimitConfig{},
|
|
| 100 | 100 |
}, |
| 101 | 101 |
} |
| 102 | 102 |
|
| ... | ... |
@@ -173,7 +177,7 @@ func TestMaxProjectByRequester(t *testing.T) {
|
| 173 | 173 |
|
| 174 | 174 |
func TestAdmit(t *testing.T) {
|
| 175 | 175 |
tests := []struct {
|
| 176 |
- config *ProjectRequestLimitConfig |
|
| 176 |
+ config *requestlimitapi.ProjectRequestLimitConfig |
|
| 177 | 177 |
user string |
| 178 | 178 |
expectForbidden bool |
| 179 | 179 |
}{
|
| ... | ... |
@@ -266,7 +270,7 @@ func selectorEquals(a, b map[string]string) bool {
|
| 266 | 266 |
return true |
| 267 | 267 |
} |
| 268 | 268 |
|
| 269 |
-func configEquals(a, b *ProjectRequestLimitConfig) bool {
|
|
| 269 |
+func configEquals(a, b *requestlimitapi.ProjectRequestLimitConfig) bool {
|
|
| 270 | 270 |
if len(a.Limits) != len(b.Limits) {
|
| 271 | 271 |
return false |
| 272 | 272 |
} |
| ... | ... |
@@ -322,9 +326,9 @@ func userFn(usersAndLabels map[string]labels.Set) ktestclient.ReactionFunc {
|
| 322 | 322 |
} |
| 323 | 323 |
} |
| 324 | 324 |
|
| 325 |
-func multiLevelConfig() *ProjectRequestLimitConfig {
|
|
| 326 |
- return &ProjectRequestLimitConfig{
|
|
| 327 |
- Limits: []ProjectLimitBySelector{
|
|
| 325 |
+func multiLevelConfig() *requestlimitapi.ProjectRequestLimitConfig {
|
|
| 326 |
+ return &requestlimitapi.ProjectRequestLimitConfig{
|
|
| 327 |
+ Limits: []requestlimitapi.ProjectLimitBySelector{
|
|
| 328 | 328 |
{
|
| 329 | 329 |
Selector: map[string]string{"platinum": "yes"},
|
| 330 | 330 |
MaxProjects: nil, |
| ... | ... |
@@ -349,13 +353,13 @@ func multiLevelConfig() *ProjectRequestLimitConfig {
|
| 349 | 349 |
} |
| 350 | 350 |
} |
| 351 | 351 |
|
| 352 |
-func emptyConfig() *ProjectRequestLimitConfig {
|
|
| 353 |
- return &ProjectRequestLimitConfig{}
|
|
| 352 |
+func emptyConfig() *requestlimitapi.ProjectRequestLimitConfig {
|
|
| 353 |
+ return &requestlimitapi.ProjectRequestLimitConfig{}
|
|
| 354 | 354 |
} |
| 355 | 355 |
|
| 356 |
-func singleDefaultConfig() *ProjectRequestLimitConfig {
|
|
| 357 |
- return &ProjectRequestLimitConfig{
|
|
| 358 |
- Limits: []ProjectLimitBySelector{
|
|
| 356 |
+func singleDefaultConfig() *requestlimitapi.ProjectRequestLimitConfig {
|
|
| 357 |
+ return &requestlimitapi.ProjectRequestLimitConfig{
|
|
| 358 |
+ Limits: []requestlimitapi.ProjectLimitBySelector{
|
|
| 359 | 359 |
{
|
| 360 | 360 |
Selector: nil, |
| 361 | 361 |
MaxProjects: intp(1), |
| ... | ... |
@@ -22,7 +22,7 @@ func TestValidateProjectRequestLimitConfig(t *testing.T) {
|
| 22 | 22 |
// 1: single default |
| 23 | 23 |
{
|
| 24 | 24 |
config: api.ProjectRequestLimitConfig{
|
| 25 |
- Limits: []ProjectLimitBySelector{
|
|
| 25 |
+ Limits: []api.ProjectLimitBySelector{
|
|
| 26 | 26 |
{
|
| 27 | 27 |
Selector: nil, |
| 28 | 28 |
MaxProjects: intp(1), |
| ... | ... |
@@ -33,7 +33,7 @@ func TestValidateProjectRequestLimitConfig(t *testing.T) {
|
| 33 | 33 |
// 2: multiple limits |
| 34 | 34 |
{
|
| 35 | 35 |
config: api.ProjectRequestLimitConfig{
|
| 36 |
- Limits: []ProjectLimitBySelector{
|
|
| 36 |
+ Limits: []api.ProjectLimitBySelector{
|
|
| 37 | 37 |
{
|
| 38 | 38 |
Selector: map[string]string{"foo": "bar", "foo2": "baz"},
|
| 39 | 39 |
MaxProjects: intp(10), |
| ... | ... |
@@ -48,7 +48,7 @@ func TestValidateProjectRequestLimitConfig(t *testing.T) {
|
| 48 | 48 |
// 3: negative limit (error) |
| 49 | 49 |
{
|
| 50 | 50 |
config: api.ProjectRequestLimitConfig{
|
| 51 |
- Limits: []ProjectLimitBySelector{
|
|
| 51 |
+ Limits: []api.ProjectLimitBySelector{
|
|
| 52 | 52 |
{
|
| 53 | 53 |
Selector: map[string]string{"foo": "bar", "foo2": "baz"},
|
| 54 | 54 |
MaxProjects: intp(10), |
| ... | ... |
@@ -66,7 +66,7 @@ func TestValidateProjectRequestLimitConfig(t *testing.T) {
|
| 66 | 66 |
// 4: invalid selector label (error) |
| 67 | 67 |
{
|
| 68 | 68 |
config: api.ProjectRequestLimitConfig{
|
| 69 |
- Limits: []ProjectLimitBySelector{
|
|
| 69 |
+ Limits: []api.ProjectLimitBySelector{
|
|
| 70 | 70 |
{
|
| 71 | 71 |
Selector: map[string]string{"foo": "bar", "foo2": "baz"},
|
| 72 | 72 |
MaxProjects: intp(10), |
| ... | ... |
@@ -109,3 +109,7 @@ func TestValidateProjectRequestLimitConfig(t *testing.T) {
|
| 109 | 109 |
} |
| 110 | 110 |
} |
| 111 | 111 |
} |
| 112 |
+ |
|
| 113 |
+func intp(n int) *int {
|
|
| 114 |
+ return &n |
|
| 115 |
+} |
| ... | ... |
@@ -1,4 +1,4 @@ |
| 1 |
-package v1 |
|
| 1 |
+package v1_test |
|
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| ... | ... |
@@ -7,6 +7,9 @@ import ( |
| 7 | 7 |
"k8s.io/kubernetes/pkg/registry/namespace" |
| 8 | 8 |
|
| 9 | 9 |
testutil "github.com/openshift/origin/test/util/api" |
| 10 |
+ |
|
| 11 |
+ // install all APIs |
|
| 12 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 10 | 13 |
) |
| 11 | 14 |
|
| 12 | 15 |
func TestFieldSelectorConversions(t *testing.T) {
|
| ... | ... |
@@ -1,4 +1,4 @@ |
| 1 |
-package v1 |
|
| 1 |
+package v1_test |
|
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| ... | ... |
@@ -6,7 +6,11 @@ import ( |
| 6 | 6 |
kapi "k8s.io/kubernetes/pkg/api" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/openshift/origin/pkg/route/api" |
| 9 |
+ "github.com/openshift/origin/pkg/route/api/v1" |
|
| 9 | 10 |
testutil "github.com/openshift/origin/test/util/api" |
| 11 |
+ |
|
| 12 |
+ // install all APIs |
|
| 13 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 10 | 14 |
) |
| 11 | 15 |
|
| 12 | 16 |
func TestFieldSelectorConversions(t *testing.T) {
|
| ... | ... |
@@ -19,12 +23,12 @@ func TestFieldSelectorConversions(t *testing.T) {
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 | 21 |
func TestSupportingCamelConstants(t *testing.T) {
|
| 22 |
- for k, v := range map[TLSTerminationType]api.TLSTerminationType{
|
|
| 22 |
+ for k, v := range map[v1.TLSTerminationType]api.TLSTerminationType{
|
|
| 23 | 23 |
"Reencrypt": api.TLSTerminationReencrypt, |
| 24 | 24 |
"Edge": api.TLSTerminationEdge, |
| 25 | 25 |
"Passthrough": api.TLSTerminationPassthrough, |
| 26 | 26 |
} {
|
| 27 |
- obj := &TLSConfig{Termination: k}
|
|
| 27 |
+ obj := &v1.TLSConfig{Termination: k}
|
|
| 28 | 28 |
out := &api.TLSConfig{}
|
| 29 | 29 |
if err := kapi.Scheme.Convert(obj, out); err != nil {
|
| 30 | 30 |
t.Errorf("%s: did not convert: %v", k, err)
|
| ... | ... |
@@ -1,10 +1,13 @@ |
| 1 |
-package v1 |
|
| 1 |
+package v1_test |
|
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 | 6 |
"github.com/openshift/origin/pkg/sdn/api" |
| 7 | 7 |
testutil "github.com/openshift/origin/test/util/api" |
| 8 |
+ |
|
| 9 |
+ // install all APIs |
|
| 10 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 8 | 11 |
) |
| 9 | 12 |
|
| 10 | 13 |
func TestFieldSelectorConversions(t *testing.T) {
|
| ... | ... |
@@ -45,7 +45,7 @@ func (r fakeRetriever) Get(name string) (*api.Service, error) {
|
| 45 | 45 |
|
| 46 | 46 |
func TestServiceResolverCache(t *testing.T) {
|
| 47 | 47 |
c := fakeRetriever{
|
| 48 |
- err: errors.NewNotFound(kapi.Resource("Service"), "bar"),
|
|
| 48 |
+ err: errors.NewNotFound(api.Resource("Service"), "bar"),
|
|
| 49 | 49 |
} |
| 50 | 50 |
cache := NewServiceResolverCache(c.Get) |
| 51 | 51 |
if v, ok := cache.resolve("FOO_SERVICE_HOST"); v != "" || ok {
|
| ... | ... |
@@ -1,10 +1,13 @@ |
| 1 |
-package v1 |
|
| 1 |
+package v1_test |
|
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 | 6 |
"github.com/openshift/origin/pkg/template/api" |
| 7 | 7 |
testutil "github.com/openshift/origin/test/util/api" |
| 8 |
+ |
|
| 9 |
+ // install all APIs |
|
| 10 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 8 | 11 |
) |
| 9 | 12 |
|
| 10 | 13 |
func TestFieldSelectorConversions(t *testing.T) {
|
| ... | ... |
@@ -9,12 +9,15 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"testing" |
| 11 | 11 |
|
| 12 |
+ kapi "k8s.io/kubernetes/pkg/api" |
|
| 13 |
+ "k8s.io/kubernetes/pkg/runtime" |
|
| 12 | 14 |
"k8s.io/kubernetes/pkg/util" |
| 13 | 15 |
|
| 14 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 15 | 16 |
"github.com/openshift/origin/pkg/api/v1beta3" |
| 16 | 17 |
"github.com/openshift/origin/pkg/template/api" |
| 17 | 18 |
"github.com/openshift/origin/pkg/template/generator" |
| 19 |
+ |
|
| 20 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 18 | 21 |
) |
| 19 | 22 |
|
| 20 | 23 |
func makeParameter(name, value, generate string, required bool) api.Parameter {
|
| ... | ... |
@@ -129,7 +132,7 @@ func TestParameterGenerators(t *testing.T) {
|
| 129 | 129 |
|
| 130 | 130 |
func TestProcessValueEscape(t *testing.T) {
|
| 131 | 131 |
var template api.Template |
| 132 |
- if err := latest.Codec.DecodeInto([]byte(`{
|
|
| 132 |
+ if err := runtime.DecodeInto(kapi.Codecs.UniversalDecoder(), []byte(`{
|
|
| 133 | 133 |
"kind":"Template", "apiVersion":"v1", |
| 134 | 134 |
"objects": [ |
| 135 | 135 |
{
|
| ... | ... |
@@ -159,7 +162,7 @@ func TestProcessValueEscape(t *testing.T) {
|
| 159 | 159 |
if len(errs) > 0 {
|
| 160 | 160 |
t.Fatalf("unexpected error: %v", errs)
|
| 161 | 161 |
} |
| 162 |
- result, err := v1beta3.Codec.Encode(&template) |
|
| 162 |
+ result, err := runtime.Encode(kapi.Codecs.LegacyCodec(v1beta3.SchemeGroupVersion), &template) |
|
| 163 | 163 |
if err != nil {
|
| 164 | 164 |
t.Fatalf("unexpected error during encoding Config: %#v", err)
|
| 165 | 165 |
} |
| ... | ... |
@@ -298,7 +301,7 @@ func TestEvaluateLabels(t *testing.T) {
|
| 298 | 298 |
|
| 299 | 299 |
for k, testCase := range testCases {
|
| 300 | 300 |
var template api.Template |
| 301 |
- if err := latest.Codec.DecodeInto([]byte(testCase.Input), &template); err != nil {
|
|
| 301 |
+ if err := runtime.DecodeInto(kapi.Codecs.UniversalDecoder(), []byte(testCase.Input), &template); err != nil {
|
|
| 302 | 302 |
t.Errorf("%s: unexpected error: %v", k, err)
|
| 303 | 303 |
continue |
| 304 | 304 |
} |
| ... | ... |
@@ -316,7 +319,7 @@ func TestEvaluateLabels(t *testing.T) {
|
| 316 | 316 |
t.Errorf("%s: unexpected error: %v", k, errs)
|
| 317 | 317 |
continue |
| 318 | 318 |
} |
| 319 |
- result, err := v1beta3.Codec.Encode(&template) |
|
| 319 |
+ result, err := runtime.Encode(kapi.Codecs.LegacyCodec(v1beta3.SchemeGroupVersion), &template) |
|
| 320 | 320 |
if err != nil {
|
| 321 | 321 |
t.Errorf("%s: unexpected error: %v", k, err)
|
| 322 | 322 |
continue |
| ... | ... |
@@ -334,12 +337,12 @@ func TestEvaluateLabels(t *testing.T) {
|
| 334 | 334 |
func TestProcessTemplateParameters(t *testing.T) {
|
| 335 | 335 |
var template, expectedTemplate api.Template |
| 336 | 336 |
jsonData, _ := ioutil.ReadFile("../../test/templates/fixtures/guestbook.json")
|
| 337 |
- if err := latest.Codec.DecodeInto(jsonData, &template); err != nil {
|
|
| 337 |
+ if err := runtime.DecodeInto(kapi.Codecs.UniversalDecoder(), jsonData, &template); err != nil {
|
|
| 338 | 338 |
t.Fatalf("unexpected error: %v", err)
|
| 339 | 339 |
} |
| 340 | 340 |
|
| 341 | 341 |
expectedData, _ := ioutil.ReadFile("../../test/templates/fixtures/guestbook_list.json")
|
| 342 |
- if err := latest.Codec.DecodeInto(expectedData, &expectedTemplate); err != nil {
|
|
| 342 |
+ if err := runtime.DecodeInto(kapi.Codecs.UniversalDecoder(), expectedData, &expectedTemplate); err != nil {
|
|
| 343 | 343 |
t.Fatalf("unexpected error: %v", err)
|
| 344 | 344 |
} |
| 345 | 345 |
|
| ... | ... |
@@ -356,11 +359,11 @@ func TestProcessTemplateParameters(t *testing.T) {
|
| 356 | 356 |
if len(errs) > 0 {
|
| 357 | 357 |
t.Fatalf("unexpected error: %v", errs)
|
| 358 | 358 |
} |
| 359 |
- result, err := v1beta3.Codec.Encode(&template) |
|
| 359 |
+ result, err := runtime.Encode(kapi.Codecs.LegacyCodec(v1beta3.SchemeGroupVersion), &template) |
|
| 360 | 360 |
if err != nil {
|
| 361 | 361 |
t.Fatalf("unexpected error during encoding Config: %#v", err)
|
| 362 | 362 |
} |
| 363 |
- exp, _ := v1beta3.Codec.Encode(&expectedTemplate) |
|
| 363 |
+ exp, _ := runtime.Encode(kapi.Codecs.LegacyCodec(v1beta3.SchemeGroupVersion), &expectedTemplate) |
|
| 364 | 364 |
|
| 365 | 365 |
if string(result) != string(exp) {
|
| 366 | 366 |
t.Errorf("unexpected output: %s", util.StringDiff(string(exp), string(result)))
|
| ... | ... |
@@ -1,10 +1,13 @@ |
| 1 |
-package v1 |
|
| 1 |
+package v1_test |
|
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"testing" |
| 5 | 5 |
|
| 6 | 6 |
"github.com/openshift/origin/pkg/user/api" |
| 7 | 7 |
testutil "github.com/openshift/origin/test/util/api" |
| 8 |
+ |
|
| 9 |
+ // install all APIs |
|
| 10 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 8 | 11 |
) |
| 9 | 12 |
|
| 10 | 13 |
func TestFieldSelectorConversions(t *testing.T) {
|
| ... | ... |
@@ -11,6 +11,9 @@ import ( |
| 11 | 11 |
"github.com/davecgh/go-spew/spew" |
| 12 | 12 |
authorizationapi "github.com/openshift/origin/pkg/authorization/api" |
| 13 | 13 |
"github.com/openshift/origin/pkg/client/testclient" |
| 14 |
+ |
|
| 15 |
+ // install all APIs |
|
| 16 |
+ _ "github.com/openshift/origin/pkg/api/install" |
|
| 14 | 17 |
) |
| 15 | 18 |
|
| 16 | 19 |
func TestGroupReaper(t *testing.T) {
|
| ... | ... |
@@ -17,7 +17,7 @@ type FakeLabelsResource struct {
|
| 17 | 17 |
kapi.ObjectMeta `json:"metadata,omitempty"` |
| 18 | 18 |
} |
| 19 | 19 |
|
| 20 |
-func (*FakeLabelsResource) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
|
| 20 |
+func (obj *FakeLabelsResource) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
|
| 21 | 21 |
|
| 22 | 22 |
func TestAddConfigLabels(t *testing.T) {
|
| 23 | 23 |
var nilLabels map[string]string |
| ... | ... |
@@ -142,7 +142,7 @@ func TestAddConfigLabels(t *testing.T) {
|
| 142 | 142 |
if err != nil {
|
| 143 | 143 |
t.Error(err) |
| 144 | 144 |
} |
| 145 |
- metaLabels := accessor.Labels() |
|
| 145 |
+ metaLabels := accessor.GetLabels() |
|
| 146 | 146 |
if e, a := test.expectedLabels, metaLabels; !reflect.DeepEqual(e, a) {
|
| 147 | 147 |
t.Errorf("Unexpected labels on testCase[%v]. Expected: %#v, got: %#v.", i, e, a)
|
| 148 | 148 |
} |
| ... | ... |
@@ -160,8 +160,8 @@ func checkAdmissionObjectLabelValues(labels, expected map[string]string) error {
|
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 | 162 |
func registerAdmissionPluginTestConfigType() {
|
| 163 |
- kapi.Scheme.AddKnownTypes(configapi.SchemeGroupVersion, &TestPluginConfig{})
|
|
| 164 |
- kapi.Scheme.AddKnownTypes(configapiv1.SchemeGroupVersion, &TestPluginConfig{})
|
|
| 163 |
+ configapi.Scheme.AddKnownTypes(configapi.SchemeGroupVersion, &TestPluginConfig{})
|
|
| 164 |
+ configapi.Scheme.AddKnownTypes(configapiv1.SchemeGroupVersion, &TestPluginConfig{})
|
|
| 165 | 165 |
} |
| 166 | 166 |
|
| 167 | 167 |
func setupAdmissionPluginTestConfig(t *testing.T, value string) string {
|
| ... | ... |
@@ -3,8 +3,12 @@ |
| 3 | 3 |
package integration |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 |
+ "io/ioutil" |
|
| 7 |
+ "os" |
|
| 8 |
+ "path/filepath" |
|
| 6 | 9 |
"testing" |
| 7 | 10 |
|
| 11 |
+ kapi "k8s.io/kubernetes/pkg/api" |
|
| 8 | 12 |
"k8s.io/kubernetes/pkg/api/unversioned" |
| 9 | 13 |
"k8s.io/kubernetes/pkg/api/v1" |
| 10 | 14 |
"k8s.io/kubernetes/pkg/runtime" |
| ... | ... |
@@ -88,3 +92,59 @@ func TestTemplate(t *testing.T) {
|
| 88 | 88 |
} |
| 89 | 89 |
} |
| 90 | 90 |
} |
| 91 |
+ |
|
| 92 |
+func walkJSONFiles(inDir string, fn func(name, path string, data []byte)) error {
|
|
| 93 |
+ err := filepath.Walk(inDir, func(path string, info os.FileInfo, err error) error {
|
|
| 94 |
+ if err != nil {
|
|
| 95 |
+ return err |
|
| 96 |
+ } |
|
| 97 |
+ if info.IsDir() && path != inDir {
|
|
| 98 |
+ return filepath.SkipDir |
|
| 99 |
+ } |
|
| 100 |
+ name := filepath.Base(path) |
|
| 101 |
+ ext := filepath.Ext(name) |
|
| 102 |
+ if ext != "" {
|
|
| 103 |
+ name = name[:len(name)-len(ext)] |
|
| 104 |
+ } |
|
| 105 |
+ if !(ext == ".json" || ext == ".yaml") {
|
|
| 106 |
+ return nil |
|
| 107 |
+ } |
|
| 108 |
+ data, err := ioutil.ReadFile(path) |
|
| 109 |
+ if err != nil {
|
|
| 110 |
+ return err |
|
| 111 |
+ } |
|
| 112 |
+ fn(name, path, data) |
|
| 113 |
+ return nil |
|
| 114 |
+ }) |
|
| 115 |
+ return err |
|
| 116 |
+} |
|
| 117 |
+ |
|
| 118 |
+func TestTemplateTransformationFromConfig(t *testing.T) {
|
|
| 119 |
+ _, clusterAdminKubeConfig, err := testserver.StartTestMaster() |
|
| 120 |
+ if err != nil {
|
|
| 121 |
+ t.Fatalf("unexpected error: %v", err)
|
|
| 122 |
+ } |
|
| 123 |
+ |
|
| 124 |
+ clusterAdminClient, err := testutil.GetClusterAdminClient(clusterAdminKubeConfig) |
|
| 125 |
+ if err != nil {
|
|
| 126 |
+ t.Fatalf("unexpected error: %v", err)
|
|
| 127 |
+ } |
|
| 128 |
+ |
|
| 129 |
+ walkJSONFiles("../templates/fixtures", func(name, path string, data []byte) {
|
|
| 130 |
+ template, err := runtime.Decode(kapi.Codecs.UniversalDecoder(), data) |
|
| 131 |
+ if err != nil {
|
|
| 132 |
+ t.Errorf("%q: unexpected error: %v", path, err)
|
|
| 133 |
+ return |
|
| 134 |
+ } |
|
| 135 |
+ config, err := clusterAdminClient.TemplateConfigs("default").Create(template.(*templateapi.Template))
|
|
| 136 |
+ if err != nil {
|
|
| 137 |
+ t.Errorf("%q: unexpected error: %v", path, err)
|
|
| 138 |
+ return |
|
| 139 |
+ } |
|
| 140 |
+ if len(config.Objects) == 0 {
|
|
| 141 |
+ t.Errorf("%q: no items in config object", path)
|
|
| 142 |
+ return |
|
| 143 |
+ } |
|
| 144 |
+ t.Logf("tested %q", path)
|
|
| 145 |
+ }) |
|
| 146 |
+} |
| 91 | 147 |
deleted file mode 100644 |
| ... | ... |
@@ -1,106 +0,0 @@ |
| 1 |
-package templates |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "io/ioutil" |
|
| 5 |
- "net/http" |
|
| 6 |
- "net/http/httptest" |
|
| 7 |
- "os" |
|
| 8 |
- "path/filepath" |
|
| 9 |
- "strings" |
|
| 10 |
- "testing" |
|
| 11 |
- |
|
| 12 |
- kapi "k8s.io/kubernetes/pkg/api" |
|
| 13 |
- "k8s.io/kubernetes/pkg/api/rest" |
|
| 14 |
- "k8s.io/kubernetes/pkg/apiserver" |
|
| 15 |
- kclient "k8s.io/kubernetes/pkg/client/unversioned" |
|
| 16 |
- "k8s.io/kubernetes/pkg/master" |
|
| 17 |
- "k8s.io/kubernetes/plugin/pkg/admission/admit" |
|
| 18 |
- |
|
| 19 |
- "github.com/openshift/origin/pkg/api/latest" |
|
| 20 |
- osclient "github.com/openshift/origin/pkg/client" |
|
| 21 |
- templateapi "github.com/openshift/origin/pkg/template/api" |
|
| 22 |
- templateregistry "github.com/openshift/origin/pkg/template/registry" |
|
| 23 |
-) |
|
| 24 |
- |
|
| 25 |
-func walkJSONFiles(inDir string, fn func(name, path string, data []byte)) error {
|
|
| 26 |
- err := filepath.Walk(inDir, func(path string, info os.FileInfo, err error) error {
|
|
| 27 |
- if err != nil {
|
|
| 28 |
- return err |
|
| 29 |
- } |
|
| 30 |
- if info.IsDir() && path != inDir {
|
|
| 31 |
- return filepath.SkipDir |
|
| 32 |
- } |
|
| 33 |
- name := filepath.Base(path) |
|
| 34 |
- ext := filepath.Ext(name) |
|
| 35 |
- if ext != "" {
|
|
| 36 |
- name = name[:len(name)-len(ext)] |
|
| 37 |
- } |
|
| 38 |
- if !(ext == ".json" || ext == ".yaml") {
|
|
| 39 |
- return nil |
|
| 40 |
- } |
|
| 41 |
- data, err := ioutil.ReadFile(path) |
|
| 42 |
- if err != nil {
|
|
| 43 |
- return err |
|
| 44 |
- } |
|
| 45 |
- fn(name, path, data) |
|
| 46 |
- return nil |
|
| 47 |
- }) |
|
| 48 |
- return err |
|
| 49 |
-} |
|
| 50 |
- |
|
| 51 |
-func TestTemplateTransformationFromConfig(t *testing.T) {
|
|
| 52 |
- osMux := http.NewServeMux() |
|
| 53 |
- server := httptest.NewServer(osMux) |
|
| 54 |
- defer server.Close() |
|
| 55 |
- |
|
| 56 |
- osClient := osclient.NewOrDie(&kclient.Config{Host: server.URL, GroupVersion: &latest.Version})
|
|
| 57 |
- |
|
| 58 |
- storage := map[string]rest.Storage{
|
|
| 59 |
- "processedTemplates": templateregistry.NewREST(), |
|
| 60 |
- } |
|
| 61 |
- for k, v := range storage {
|
|
| 62 |
- delete(storage, k) |
|
| 63 |
- storage[strings.ToLower(k)] = v |
|
| 64 |
- } |
|
| 65 |
- |
|
| 66 |
- interfaces, _ := latest.InterfacesFor(latest.Version) |
|
| 67 |
- handlerContainer := master.NewHandlerContainer(osMux) |
|
| 68 |
- version := apiserver.APIGroupVersion{
|
|
| 69 |
- Root: "/oapi", |
|
| 70 |
- GroupVersion: latest.Version, |
|
| 71 |
- |
|
| 72 |
- Mapper: latest.RESTMapper, |
|
| 73 |
- |
|
| 74 |
- Storage: storage, |
|
| 75 |
- Codec: interfaces.Codec, |
|
| 76 |
- |
|
| 77 |
- Creater: kapi.Scheme, |
|
| 78 |
- Typer: kapi.Scheme, |
|
| 79 |
- Convertor: kapi.Scheme, |
|
| 80 |
- Linker: interfaces.MetadataAccessor, |
|
| 81 |
- |
|
| 82 |
- Admit: admit.NewAlwaysAdmit(), |
|
| 83 |
- Context: kapi.NewRequestContextMapper(), |
|
| 84 |
- } |
|
| 85 |
- if err := version.InstallREST(handlerContainer); err != nil {
|
|
| 86 |
- t.Fatalf("unexpected error: %v", err)
|
|
| 87 |
- } |
|
| 88 |
- |
|
| 89 |
- walkJSONFiles("fixtures", func(name, path string, data []byte) {
|
|
| 90 |
- template, err := interfaces.Codec.Decode(data) |
|
| 91 |
- if err != nil {
|
|
| 92 |
- t.Errorf("%q: unexpected error: %v", path, err)
|
|
| 93 |
- return |
|
| 94 |
- } |
|
| 95 |
- config, err := osClient.TemplateConfigs("default").Create(template.(*templateapi.Template))
|
|
| 96 |
- if err != nil {
|
|
| 97 |
- t.Errorf("%q: unexpected error: %v", path, err)
|
|
| 98 |
- return |
|
| 99 |
- } |
|
| 100 |
- if len(config.Objects) == 0 {
|
|
| 101 |
- t.Errorf("%q: no items in config object", path)
|
|
| 102 |
- return |
|
| 103 |
- } |
|
| 104 |
- t.Logf("tested %q", path)
|
|
| 105 |
- }) |
|
| 106 |
-} |