Skip to content

Commit 53288d4

Browse files
committed
update tests for oapi removal
1 parent fd57997 commit 53288d4

File tree

19 files changed

+94
-1005
lines changed

19 files changed

+94
-1005
lines changed

pkg/api/legacy/install.go

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
)
77

88
var (
9-
RESTPrefix = "/oapi"
109
GroupName = ""
1110
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
1211
InternalGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}

pkg/build/apiserver/registry/buildconfig/webhook.go

-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/openshift/api/build"
2323
buildv1 "github.com/openshift/api/build/v1"
2424
buildclienttyped "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1"
25-
"github.com/openshift/origin/pkg/api/legacy"
2625
buildapi "github.com/openshift/origin/pkg/build/apis/build"
2726
buildv1helpers "github.com/openshift/origin/pkg/build/apis/build/v1"
2827
"github.com/openshift/origin/pkg/build/client"
@@ -35,8 +34,6 @@ var (
3534
)
3635

3736
func init() {
38-
// webhooks need to return legacy build serialization when hit via oapi
39-
legacy.InstallInternalLegacyBuild(webhookEncodingScheme)
4037
// TODO eventually we shouldn't deal in internal versions, but for now decode into one.
4138
utilruntime.Must(buildv1helpers.Install(webhookEncodingScheme))
4239
webhookEncodingCodecFactory = serializer.NewCodecFactory(webhookEncodingScheme)

pkg/cmd/openshift-apiserver/openshiftapiserver/config.go

-52
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"net/http"
88
"time"
99

10-
"github.com/emicklei/go-restful-swagger12"
1110
"github.com/golang/glog"
1211

1312
"k8s.io/apiserver/pkg/admission"
@@ -25,7 +24,6 @@ import (
2524
openshiftcontrolplanev1 "github.com/openshift/api/openshiftcontrolplane/v1"
2625
"github.com/openshift/library-go/pkg/config/helpers"
2726
"github.com/openshift/origin/pkg/admission/namespaceconditions"
28-
"github.com/openshift/origin/pkg/api/legacy"
2927
originadmission "github.com/openshift/origin/pkg/apiserver/admission"
3028
"github.com/openshift/origin/pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing"
3129
configlatest "github.com/openshift/origin/pkg/cmd/server/apis/config/latest"
@@ -101,10 +99,8 @@ func NewOpenshiftAPIConfig(config *openshiftcontrolplanev1.OpenShiftAPIServerCon
10199
genericConfig.AuditPolicyChecker = policyChecker
102100
genericConfig.ExternalAddress = "apiserver.openshift-apiserver.svc"
103101
genericConfig.BuildHandlerChainFunc = OpenshiftHandlerChain
104-
genericConfig.LegacyAPIGroupPrefixes = configprocessing.LegacyAPIGroupPrefixes
105102
genericConfig.RequestInfoResolver = configprocessing.OpenshiftRequestInfoResolver()
106103
genericConfig.OpenAPIConfig = configprocessing.DefaultOpenAPIConfig(nil)
107-
genericConfig.SwaggerConfig = defaultSwaggerConfig()
108104
genericConfig.RESTOptionsGetter = restOptsGetter
109105
// previously overwritten. I don't know why
110106
genericConfig.RequestTimeout = time.Duration(60) * time.Second
@@ -259,54 +255,6 @@ func NewOpenshiftAPIConfig(config *openshiftcontrolplanev1.OpenShiftAPIServerCon
259255
return ret, ret.ExtraConfig.Validate()
260256
}
261257

262-
var apiInfo = map[string]swagger.Info{
263-
legacy.RESTPrefix + "/" + legacy.GroupVersion.Version: {
264-
Title: "OpenShift v1 REST API",
265-
Description: `The OpenShift API exposes operations for managing an enterprise Kubernetes cluster, including security and user management, application deployments, image and source builds, HTTP(s) routing, and project management.`,
266-
},
267-
}
268-
269-
// customizeSwaggerDefinition applies selective patches to the swagger API docs
270-
// TODO: move most of these upstream or to go-restful
271-
func customizeSwaggerDefinition(apiList *swagger.ApiDeclarationList) {
272-
for path, info := range apiInfo {
273-
if dec, ok := apiList.At(path); ok {
274-
if len(info.Title) > 0 {
275-
dec.Info.Title = info.Title
276-
}
277-
if len(info.Description) > 0 {
278-
dec.Info.Description = info.Description
279-
}
280-
apiList.Put(path, dec)
281-
} else {
282-
glog.Warningf("No API exists for predefined swagger description %s", path)
283-
}
284-
}
285-
for _, version := range []string{legacy.RESTPrefix + "/" + legacy.GroupVersion.Version} {
286-
apiDeclaration, _ := apiList.At(version)
287-
models := &apiDeclaration.Models
288-
289-
model, _ := models.At("runtime.RawExtension")
290-
model.Required = []string{}
291-
model.Properties = swagger.ModelPropertyList{}
292-
model.Description = "this may be any JSON object with a 'kind' and 'apiVersion' field; and is preserved unmodified by processing"
293-
models.Put("runtime.RawExtension", model)
294-
295-
model, _ = models.At("patch.Object")
296-
model.Description = "represents an object patch, which may be any of: JSON patch (RFC 6902), JSON merge patch (RFC 7396), or the Kubernetes strategic merge patch"
297-
models.Put("patch.Object", model)
298-
299-
apiDeclaration.Models = *models
300-
apiList.Put(version, apiDeclaration)
301-
}
302-
}
303-
304-
func defaultSwaggerConfig() *swagger.Config {
305-
ret := genericapiserver.DefaultSwaggerConfig()
306-
ret.PostBuildHandler = customizeSwaggerDefinition
307-
return ret
308-
}
309-
310258
func OpenshiftHandlerChain(apiHandler http.Handler, genericConfig *genericapiserver.Config) http.Handler {
311259
// this is the normal kube handler chain
312260
handler := genericapiserver.DefaultBuildHandlerChain(apiHandler, genericConfig)

pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing/openapi.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,8 @@ func DefaultOpenAPIConfig(oauthMetadata *oauthutil.OauthAuthorizationServerMetad
5858
op := r.Operation
5959
path := r.Path
6060
// DEPRECATED: These endpoints are going to be removed in 1.8 or 1.9 release.
61-
if strings.HasPrefix(path, "/oapi/v1/namespaces/{namespace}/processedtemplates") {
62-
op = "createNamespacedProcessedTemplate"
63-
} else if strings.HasPrefix(path, "/apis/template.openshift.io/v1/namespaces/{namespace}/processedtemplates") {
61+
if strings.HasPrefix(path, "/apis/template.openshift.io/v1/namespaces/{namespace}/processedtemplates") {
6462
op = "createNamespacedProcessedTemplateV1"
65-
} else if strings.HasPrefix(path, "/oapi/v1/processedtemplates") {
66-
op = "createProcessedTemplateForAllNamespacesV1"
6763
} else if strings.HasPrefix(path, "/apis/template.openshift.io/v1/processedtemplates") {
6864
op = "createProcessedTemplateForAllNamespaces"
6965
}

pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing/requestinforesolver.go

-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
package configprocessing
22

33
import (
4-
"github.com/openshift/origin/pkg/api/legacy"
54
oauthorizer "github.com/openshift/origin/pkg/authorization/authorizer"
65
"k8s.io/apimachinery/pkg/util/sets"
76
apirequest "k8s.io/apiserver/pkg/endpoints/request"
8-
genericapiserver "k8s.io/apiserver/pkg/server"
97
)
108

11-
var LegacyAPIGroupPrefixes = sets.NewString(genericapiserver.DefaultLegacyAPIPrefix, legacy.RESTPrefix)
12-
139
func OpenshiftRequestInfoResolver() apirequest.RequestInfoResolver {
1410
// Default API request info factory
1511
requestInfoFactory := &apirequest.RequestInfoFactory{

pkg/cmd/openshift-kube-apiserver/openshiftkubeapiserver/handlers_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"k8s.io/kubernetes/pkg/api/legacyscheme"
1414

1515
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
16-
"github.com/openshift/origin/pkg/api/legacy"
1716
)
1817

1918
var (
@@ -262,7 +261,7 @@ func TestVersionSkewFilterSkippedOnNonAPIRequest(t *testing.T) {
262261

263262
func testHandlerChain(handler http.Handler) http.Handler {
264263
kgenericconfig := apiserver.NewConfig(legacyscheme.Codecs)
265-
kgenericconfig.LegacyAPIGroupPrefixes = sets.NewString(apiserver.DefaultLegacyAPIPrefix, legacy.RESTPrefix)
264+
kgenericconfig.LegacyAPIGroupPrefixes = sets.NewString(apiserver.DefaultLegacyAPIPrefix)
266265

267266
handler = apifilters.WithRequestInfo(handler, apiserver.NewRequestInfoResolver(kgenericconfig))
268267
return handler

0 commit comments

Comments
 (0)