mirror of
https://github.com/cnrancher/kube-explorer.git
synced 2025-08-17 14:06:39 +00:00
feat: Support for nginx ingress path prefix
And validate should failed if git tree is dirty
This commit is contained in:
parent
8f069c3b38
commit
a5e53f2b17
@ -6,6 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rancher/apiserver/pkg/types"
|
"github.com/rancher/apiserver/pkg/types"
|
||||||
|
"github.com/rancher/apiserver/pkg/urlbuilder"
|
||||||
steveauth "github.com/rancher/steve/pkg/auth"
|
steveauth "github.com/rancher/steve/pkg/auth"
|
||||||
"github.com/rancher/steve/pkg/schema"
|
"github.com/rancher/steve/pkg/schema"
|
||||||
"github.com/rancher/steve/pkg/server"
|
"github.com/rancher/steve/pkg/server"
|
||||||
@ -61,7 +62,11 @@ func ToServer(ctx context.Context, c *cli.Config, sqlCache bool) (*server.Server
|
|||||||
SQLCache: sqlCache,
|
SQLCache: sqlCache,
|
||||||
// router needs to hack here
|
// router needs to hack here
|
||||||
Router: func(h router.Handlers) http.Handler {
|
Router: func(h router.Handlers) http.Handler {
|
||||||
return rewriteLocalCluster(router.Routes(h))
|
return handleProxyHeader(
|
||||||
|
rewriteLocalCluster(
|
||||||
|
router.Routes(h),
|
||||||
|
),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -99,3 +104,12 @@ func rewriteLocalCluster(next http.Handler) http.Handler {
|
|||||||
next.ServeHTTP(rw, req)
|
next.ServeHTTP(rw, req)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleProxyHeader(next http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
if value := req.Header.Get("X-Forwarded-Prefix"); value != "" {
|
||||||
|
req.Header.Set(urlbuilder.PrefixHeader, value)
|
||||||
|
}
|
||||||
|
next.ServeHTTP(rw, req)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -18,3 +18,14 @@ go mod tidy
|
|||||||
|
|
||||||
echo Verifying modules
|
echo Verifying modules
|
||||||
go mod verify
|
go mod verify
|
||||||
|
|
||||||
|
dirty_files="$(git status --porcelain --untracked-files=no)"
|
||||||
|
if [ -n "$dirty_files" ]; then
|
||||||
|
echo "Encountered dirty repo! Aborting."
|
||||||
|
echo "If you're seeing this, it means there are uncommitted changes in the repo."
|
||||||
|
echo "If you're seeing this in CI, it probably means that your Go modules aren't tidy, or more generally that running"
|
||||||
|
echo "validation would result in changes to the repo. Make sure you're up to date with the upstream branch and run"
|
||||||
|
echo "'go mod tidy' and commit the changes, if any. The offending changed files are as follows:"
|
||||||
|
echo "$dirty_files"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user