make generic proxy can be marked as deprecated
Signed-off-by: zhu733756 <zhu733756@kubesphere.io>
This commit is contained in:
@@ -41,6 +41,9 @@ type genericProxy struct {
|
||||
|
||||
// api version
|
||||
Version string
|
||||
|
||||
// mark as desprecated
|
||||
desprecated bool
|
||||
}
|
||||
|
||||
func NewGenericProxy(endpoint string, groupName string, version string) (*genericProxy, error) {
|
||||
@@ -59,6 +62,10 @@ func NewGenericProxy(endpoint string, groupName string, version string) (*generi
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (g *genericProxy) SetProxyDesprecated() {
|
||||
g.desprecated = true
|
||||
}
|
||||
|
||||
// currently, we only support proxy GET/PUT/POST/DELETE/PATCH.
|
||||
// Maybe we can try another way to implement proxy.
|
||||
func (g *genericProxy) AddToContainer(container *restful.Container) error {
|
||||
@@ -93,6 +100,10 @@ func (g *genericProxy) AddToContainer(container *restful.Container) error {
|
||||
}
|
||||
|
||||
func (g *genericProxy) handler(request *restful.Request, response *restful.Response) {
|
||||
if g.desprecated {
|
||||
klog.Warning(fmt.Sprintf("This proxy group %s has deprecated", g.GroupName))
|
||||
}
|
||||
|
||||
u := g.makeURL(request)
|
||||
|
||||
httpProxy := proxy.NewUpgradeAwareHandler(u, http.DefaultTransport, false, false, &errorResponder{})
|
||||
|
||||
@@ -33,5 +33,7 @@ func AddToContainer(container *restful.Container, endpoint string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
proxy.SetProxyDesprecated()
|
||||
|
||||
return proxy.AddToContainer(container)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user