Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove oapi #21782

Merged
merged 4 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pkg/api/legacy/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
)

var (
RESTPrefix = "/oapi"
GroupName = ""
GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"}
InternalGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
Expand Down
3 changes: 0 additions & 3 deletions pkg/build/apiserver/registry/buildconfig/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/openshift/api/build"
buildv1 "github.com/openshift/api/build/v1"
buildclienttyped "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1"
"github.com/openshift/origin/pkg/api/legacy"
buildapi "github.com/openshift/origin/pkg/build/apis/build"
buildv1helpers "github.com/openshift/origin/pkg/build/apis/build/v1"
"github.com/openshift/origin/pkg/build/client"
Expand All @@ -35,8 +34,6 @@ var (
)

func init() {
// webhooks need to return legacy build serialization when hit via oapi
legacy.InstallInternalLegacyBuild(webhookEncodingScheme)
// TODO eventually we shouldn't deal in internal versions, but for now decode into one.
utilruntime.Must(buildv1helpers.Install(webhookEncodingScheme))
webhookEncodingCodecFactory = serializer.NewCodecFactory(webhookEncodingScheme)
Expand Down
52 changes: 0 additions & 52 deletions pkg/cmd/openshift-apiserver/openshiftapiserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/http"
"time"

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

"k8s.io/apiserver/pkg/admission"
Expand All @@ -25,7 +24,6 @@ import (
openshiftcontrolplanev1 "github.com/openshift/api/openshiftcontrolplane/v1"
"github.com/openshift/library-go/pkg/config/helpers"
"github.com/openshift/origin/pkg/admission/namespaceconditions"
"github.com/openshift/origin/pkg/api/legacy"
originadmission "github.com/openshift/origin/pkg/apiserver/admission"
"github.com/openshift/origin/pkg/cmd/openshift-apiserver/openshiftapiserver/configprocessing"
configlatest "github.com/openshift/origin/pkg/cmd/server/apis/config/latest"
Expand Down Expand Up @@ -101,10 +99,8 @@ func NewOpenshiftAPIConfig(config *openshiftcontrolplanev1.OpenShiftAPIServerCon
genericConfig.AuditPolicyChecker = policyChecker
genericConfig.ExternalAddress = "apiserver.openshift-apiserver.svc"
genericConfig.BuildHandlerChainFunc = OpenshiftHandlerChain
genericConfig.LegacyAPIGroupPrefixes = configprocessing.LegacyAPIGroupPrefixes
genericConfig.RequestInfoResolver = configprocessing.OpenshiftRequestInfoResolver()
genericConfig.OpenAPIConfig = configprocessing.DefaultOpenAPIConfig(nil)
genericConfig.SwaggerConfig = defaultSwaggerConfig()
genericConfig.RESTOptionsGetter = restOptsGetter
// previously overwritten. I don't know why
genericConfig.RequestTimeout = time.Duration(60) * time.Second
Expand Down Expand Up @@ -259,54 +255,6 @@ func NewOpenshiftAPIConfig(config *openshiftcontrolplanev1.OpenShiftAPIServerCon
return ret, ret.ExtraConfig.Validate()
}

var apiInfo = map[string]swagger.Info{
legacy.RESTPrefix + "/" + legacy.GroupVersion.Version: {
Title: "OpenShift v1 REST API",
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.`,
},
}

// customizeSwaggerDefinition applies selective patches to the swagger API docs
// TODO: move most of these upstream or to go-restful
func customizeSwaggerDefinition(apiList *swagger.ApiDeclarationList) {
for path, info := range apiInfo {
if dec, ok := apiList.At(path); ok {
if len(info.Title) > 0 {
dec.Info.Title = info.Title
}
if len(info.Description) > 0 {
dec.Info.Description = info.Description
}
apiList.Put(path, dec)
} else {
glog.Warningf("No API exists for predefined swagger description %s", path)
}
}
for _, version := range []string{legacy.RESTPrefix + "/" + legacy.GroupVersion.Version} {
apiDeclaration, _ := apiList.At(version)
models := &apiDeclaration.Models

model, _ := models.At("runtime.RawExtension")
model.Required = []string{}
model.Properties = swagger.ModelPropertyList{}
model.Description = "this may be any JSON object with a 'kind' and 'apiVersion' field; and is preserved unmodified by processing"
models.Put("runtime.RawExtension", model)

model, _ = models.At("patch.Object")
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"
models.Put("patch.Object", model)

apiDeclaration.Models = *models
apiList.Put(version, apiDeclaration)
}
}

func defaultSwaggerConfig() *swagger.Config {
ret := genericapiserver.DefaultSwaggerConfig()
ret.PostBuildHandler = customizeSwaggerDefinition
return ret
}

func OpenshiftHandlerChain(apiHandler http.Handler, genericConfig *genericapiserver.Config) http.Handler {
// this is the normal kube handler chain
handler := genericapiserver.DefaultBuildHandlerChain(apiHandler, genericConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,8 @@ func DefaultOpenAPIConfig(oauthMetadata *oauthutil.OauthAuthorizationServerMetad
op := r.Operation
path := r.Path
// DEPRECATED: These endpoints are going to be removed in 1.8 or 1.9 release.
if strings.HasPrefix(path, "/oapi/v1/namespaces/{namespace}/processedtemplates") {
op = "createNamespacedProcessedTemplate"
} else if strings.HasPrefix(path, "/apis/template.openshift.io/v1/namespaces/{namespace}/processedtemplates") {
if strings.HasPrefix(path, "/apis/template.openshift.io/v1/namespaces/{namespace}/processedtemplates") {
op = "createNamespacedProcessedTemplateV1"
} else if strings.HasPrefix(path, "/oapi/v1/processedtemplates") {
op = "createProcessedTemplateForAllNamespacesV1"
} else if strings.HasPrefix(path, "/apis/template.openshift.io/v1/processedtemplates") {
op = "createProcessedTemplateForAllNamespaces"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package configprocessing

import (
"github.com/openshift/origin/pkg/api/legacy"
oauthorizer "github.com/openshift/origin/pkg/authorization/authorizer"
"k8s.io/apimachinery/pkg/util/sets"
apirequest "k8s.io/apiserver/pkg/endpoints/request"
genericapiserver "k8s.io/apiserver/pkg/server"
)

var LegacyAPIGroupPrefixes = sets.NewString(genericapiserver.DefaultLegacyAPIPrefix, legacy.RESTPrefix)

func OpenshiftRequestInfoResolver() apirequest.RequestInfoResolver {
// Default API request info factory
requestInfoFactory := &apirequest.RequestInfoFactory{
APIPrefixes: sets.NewString("api", "osapi", "oapi", "apis"),
GrouplessAPIPrefixes: sets.NewString("api", "osapi", "oapi"),
APIPrefixes: sets.NewString("api", "apis"),
GrouplessAPIPrefixes: sets.NewString("api"),
}
personalSARRequestInfoResolver := oauthorizer.NewPersonalSARRequestInfoResolver(requestInfoFactory)
projectRequestInfoResolver := oauthorizer.NewProjectRequestInfoResolver(personalSARRequestInfoResolver)
Expand Down
136 changes: 0 additions & 136 deletions pkg/cmd/openshift-apiserver/openshiftapiserver/legacy.go

This file was deleted.

Loading