Skip to content

Commit

Permalink
Chore: remove acr image (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
chivalryq committed Jun 21, 2023
1 parent c50db15 commit 7a81518
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to Aliyun Container Registry (ACR)
uses: docker/login-action@v1
with:
registry: acr.kubevela.net
username: "${{ secrets.ACR_USERNAME }}"
password: "${{ secrets.ACR_PASSWORD }}"
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
with:
Expand All @@ -53,5 +47,4 @@ jobs:
VERSION=${{ steps.get_version.outputs.VERSION }}
GOPROXY=https://proxy.golang.org
tags: |-
acr.kubevela.net/oamdev/velaux:${{ steps.get_version.outputs.VERSION }}
oamdev/velaux:${{ steps.get_version.outputs.VERSION }}
14 changes: 10 additions & 4 deletions pkg/plugin/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,26 @@ func newDefaultRouter(h Handle, plugin *types.Plugin) *defaultRouter {
return &defaultRouter{h: h, plugin: plugin}
}

// GenerateHTTPRouter create and return the plugin backend router
func GenerateHTTPRouter(plugin *types.Plugin, pathPrefix string, h Handle) http.Handler {
// GetPluginHandler get the plugin backend router, if not exist, will create and cache it
func GetPluginHandler(plugin *types.Plugin, h Handle) http.Handler {
if r, e := cachePluginRouter[plugin.PluginID()]; e {
return r
}
router := GeneratePluginHandler(plugin, h)
cachePluginRouter[plugin.PluginID()] = router
return router
}

// GeneratePluginHandler create and return the plugin backend router
func GeneratePluginHandler(plugin *types.Plugin, h Handle) http.Handler {
var router http.Handler
if len(plugin.Routes) == 0 {
klog.Warningf("plugin %s don't define the routes, will proxy all path requests and not check the permission.", plugin.PluginID())
router = newDefaultRouter(h, plugin)
} else {
r := httprouter.New()
for _, route := range plugin.Routes {
routePath := path.Join(pathPrefix+"/:"+DefaultPluginResourceKey, route.Path)
routePath := path.Join(types.PluginProxyRoutePath+"/:"+DefaultPluginResourceKey, route.Path)
method := route.Method
if method == "" {
method = "GET"
Expand All @@ -72,6 +79,5 @@ func GenerateHTTPRouter(plugin *types.Plugin, pathPrefix string, h Handle) http.
}
router = r
}
cachePluginRouter[plugin.PluginID()] = router
return router
}
8 changes: 4 additions & 4 deletions pkg/plugin/router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
func TestDefaultGenerateHTTPRouter(t *testing.T) {
var res = &httptest.ResponseRecorder{}
var req = &http.Request{Method: "GET", URL: &url.URL{Scheme: "http", Path: "/proxy/plugins/default-router/test", Host: "127.0.0.1"}}
defaultRouter := GenerateHTTPRouter(&types.Plugin{
defaultRouter := GetPluginHandler(&types.Plugin{
JSONData: types.JSONData{
ID: "default-router",
},
}, "/proxy/plugins", func(w http.ResponseWriter, r1 *http.Request, p1 httprouter.Params, p2 *types.Plugin, r2 *types.Route) {
}, func(w http.ResponseWriter, r1 *http.Request, p1 httprouter.Params, p2 *types.Plugin, r2 *types.Route) {
if r1.URL.Path == "/proxy/plugins/default-router/test" {
w.WriteHeader(403)
return
Expand All @@ -50,7 +50,7 @@ func TestRouteGenerateHTTPRouter(t *testing.T) {
var req = &http.Request{Method: "GET", URL: &url.URL{Scheme: "http", Path: "/proxy/plugins/route-router/nodes/t", Host: "127.0.0.1"}}
var reqMethodNotAllow = &http.Request{Method: "PUT", URL: &url.URL{Scheme: "http", Path: "/proxy/plugins/route-router/nodes/t", Host: "127.0.0.1"}}
var req404 = &http.Request{Method: "GET", URL: &url.URL{Scheme: "http", Path: "/proxy/plugins/route-router/nodes", Host: "127.0.0.1"}}
router := GenerateHTTPRouter(&types.Plugin{
router := GetPluginHandler(&types.Plugin{
JSONData: types.JSONData{
ID: "route-router",
Routes: []*types.Route{
Expand All @@ -64,7 +64,7 @@ func TestRouteGenerateHTTPRouter(t *testing.T) {
},
},
},
}, "/proxy/plugins", func(w http.ResponseWriter, r1 *http.Request, p1 httprouter.Params, p2 *types.Plugin, r2 *types.Route) {
}, func(w http.ResponseWriter, r1 *http.Request, p1 httprouter.Params, p2 *types.Plugin, r2 *types.Route) {
assert.Equal(t, p1.ByName("node"), "t")
assert.Equal(t, len(r2.ProxyHeaders), 1)
assert.Equal(t, r2.ProxyHeaders[0].Name, "Authorization")
Expand Down
3 changes: 3 additions & 0 deletions pkg/plugin/types/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
)

// PluginProxyRoutePath the route prefix to request the plugin backend server.
const PluginProxyRoutePath = "/proxy/plugins/"

// Plugin VelaUX plugin model
type Plugin struct {
JSONData
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const (
PluginPublicRoutePath = "/public/plugins/"

// PluginProxyRoutePath the route prefix to request the plugin backend server.
PluginProxyRoutePath = "/proxy/plugins/"
PluginProxyRoutePath = plugintypes.PluginProxyRoutePath

// DexRoutePath the route prefix to request the dex service
DexRoutePath = "/dex"
Expand Down Expand Up @@ -454,7 +454,7 @@ func (s *restServer) proxyPluginBackend(req *http.Request, res http.ResponseWrit
return
}
// Register the plugin route
router.GenerateHTTPRouter(plugin, PluginProxyRoutePath, s.pluginBackendProxyHandler).ServeHTTP(res, req)
router.GetPluginHandler(plugin, s.pluginBackendProxyHandler).ServeHTTP(res, req)
}

func (s *restServer) pluginBackendProxyHandler(w http.ResponseWriter, r *http.Request, p httprouter.Params, plugin *plugintypes.Plugin, route *plugintypes.Route) {
Expand Down

0 comments on commit 7a81518

Please sign in to comment.