build: move e2e dependencies into e2e/go.mod

Several packages are only used while running the e2e suite. These
packages are less important to update, as the they can not influence the
final executable that is part of the Ceph-CSI container-image.

By moving these dependencies out of the main Ceph-CSI go.mod, it is
easier to identify if a reported CVE affects Ceph-CSI, or only the
testing (like most of the Kubernetes CVEs).

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2025-03-04 08:57:28 +01:00
committed by mergify[bot]
parent 15da101b1b
commit bec6090996
8047 changed files with 1407827 additions and 3453 deletions

View File

@ -0,0 +1,15 @@
package restfuladapter
import (
"github.com/emicklei/go-restful/v3"
"k8s.io/kube-openapi/pkg/common"
)
// AdaptWebServices adapts a slice of restful.WebService into the common interfaces.
func AdaptWebServices(webServices []*restful.WebService) []common.RouteContainer {
var containers []common.RouteContainer
for _, ws := range webServices {
containers = append(containers, &WebServiceAdapter{ws})
}
return containers
}

View File

@ -0,0 +1,54 @@
package restfuladapter
import (
"encoding/json"
"github.com/emicklei/go-restful/v3"
"k8s.io/kube-openapi/pkg/common"
)
var _ common.Parameter = &ParamAdapter{}
type ParamAdapter struct {
Param *restful.Parameter
}
func (r *ParamAdapter) MarshalJSON() ([]byte, error) {
return json.Marshal(r.Param)
}
func (r *ParamAdapter) Name() string {
return r.Param.Data().Name
}
func (r *ParamAdapter) Description() string {
return r.Param.Data().Description
}
func (r *ParamAdapter) Required() bool {
return r.Param.Data().Required
}
func (r *ParamAdapter) Kind() common.ParameterKind {
switch r.Param.Kind() {
case restful.PathParameterKind:
return common.PathParameterKind
case restful.QueryParameterKind:
return common.QueryParameterKind
case restful.BodyParameterKind:
return common.BodyParameterKind
case restful.HeaderParameterKind:
return common.HeaderParameterKind
case restful.FormParameterKind:
return common.FormParameterKind
default:
return common.UnknownParameterKind
}
}
func (r *ParamAdapter) DataType() string {
return r.Param.Data().DataType
}
func (r *ParamAdapter) AllowMultiple() bool {
return r.Param.Data().AllowMultiple
}

View File

@ -0,0 +1,25 @@
package restfuladapter
import (
"github.com/emicklei/go-restful/v3"
"k8s.io/kube-openapi/pkg/common"
)
var _ common.StatusCodeResponse = &ResponseErrorAdapter{}
// ResponseErrorAdapter adapts a restful.ResponseError to common.StatusCodeResponse.
type ResponseErrorAdapter struct {
Err *restful.ResponseError
}
func (r *ResponseErrorAdapter) Message() string {
return r.Err.Message
}
func (r *ResponseErrorAdapter) Model() interface{} {
return r.Err.Model
}
func (r *ResponseErrorAdapter) Code() int {
return r.Err.Code
}

View File

@ -0,0 +1,68 @@
package restfuladapter
import (
"github.com/emicklei/go-restful/v3"
"k8s.io/kube-openapi/pkg/common"
)
var _ common.Route = &RouteAdapter{}
// RouteAdapter adapts a restful.Route to common.Route.
type RouteAdapter struct {
Route *restful.Route
}
func (r *RouteAdapter) StatusCodeResponses() []common.StatusCodeResponse {
// go-restful uses the ResponseErrors field to contain both error and regular responses.
var responses []common.StatusCodeResponse
for _, res := range r.Route.ResponseErrors {
localRes := res
responses = append(responses, &ResponseErrorAdapter{&localRes})
}
return responses
}
func (r *RouteAdapter) OperationName() string {
return r.Route.Operation
}
func (r *RouteAdapter) Method() string {
return r.Route.Method
}
func (r *RouteAdapter) Path() string {
return r.Route.Path
}
func (r *RouteAdapter) Parameters() []common.Parameter {
var params []common.Parameter
for _, rParam := range r.Route.ParameterDocs {
params = append(params, &ParamAdapter{rParam})
}
return params
}
func (r *RouteAdapter) Description() string {
return r.Route.Doc
}
func (r *RouteAdapter) Consumes() []string {
return r.Route.Consumes
}
func (r *RouteAdapter) Produces() []string {
return r.Route.Produces
}
func (r *RouteAdapter) Metadata() map[string]interface{} {
return r.Route.Metadata
}
func (r *RouteAdapter) RequestPayloadSample() interface{} {
return r.Route.ReadSample
}
func (r *RouteAdapter) ResponsePayloadSample() interface{} {
return r.Route.WriteSample
}

View File

@ -0,0 +1,34 @@
package restfuladapter
import (
"github.com/emicklei/go-restful/v3"
"k8s.io/kube-openapi/pkg/common"
)
var _ common.RouteContainer = &WebServiceAdapter{}
// WebServiceAdapter adapts a restful.WebService to common.RouteContainer.
type WebServiceAdapter struct {
WebService *restful.WebService
}
func (r *WebServiceAdapter) RootPath() string {
return r.WebService.RootPath()
}
func (r *WebServiceAdapter) PathParameters() []common.Parameter {
var params []common.Parameter
for _, rParam := range r.WebService.PathParameters() {
params = append(params, &ParamAdapter{rParam})
}
return params
}
func (r *WebServiceAdapter) Routes() []common.Route {
var routes []common.Route
for _, rRoute := range r.WebService.Routes() {
localRoute := rRoute
routes = append(routes, &RouteAdapter{&localRoute})
}
return routes
}