apiserver: fix the issue that the /kapis/version API cannot be matched by routing (#5696)

This commit is contained in:
Xinzhao Xu
2023-05-19 11:26:55 +08:00
committed by GitHub
parent c128200192
commit 7575235d64

View File

@@ -17,6 +17,8 @@ limitations under the License.
package runtime
import (
"strings"
"github.com/emicklei/go-restful/v3"
"k8s.io/apimachinery/pkg/runtime/schema"
)
@@ -41,7 +43,8 @@ func init() {
func NewWebService(gv schema.GroupVersion) *restful.WebService {
webservice := restful.WebService{}
webservice.Path(ApiRootPath + "/" + gv.String()).
// the GroupVersion might be empty, we need to remove the final /
webservice.Path(strings.TrimRight(ApiRootPath+"/"+gv.String(), "/")).
Produces(restful.MIME_JSON)
return &webservice