mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 19:31:05 +00:00
Add option to disable version check in admin web UI (#3040)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
This commit is contained in:
parent
8280655e0f
commit
74f6824d03
8 changed files with 29 additions and 10 deletions
|
@ -251,6 +251,11 @@ var flags = append([]cli.Flag{
|
|||
Name: "enable-swagger",
|
||||
Value: true,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_DISABLE_VERSION_CHECK"},
|
||||
Usage: "Disable version check in admin web ui.",
|
||||
Name: "skip-version-check",
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
EnvVars: []string{"WOODPECKER_ADDONS"},
|
||||
Name: "addons",
|
||||
|
|
|
@ -370,7 +370,8 @@ func setupEvilGlobals(c *cli.Context, v store.Store, f forge.Forge) error {
|
|||
server.Config.Pipeline.Networks = c.StringSlice("network")
|
||||
server.Config.Pipeline.Volumes = c.StringSlice("volume")
|
||||
server.Config.Pipeline.Privileged = c.StringSlice("escalate")
|
||||
server.Config.Server.EnableSwagger = c.Bool("enable-swagger")
|
||||
server.Config.WebUI.EnableSwagger = c.Bool("enable-swagger")
|
||||
server.Config.WebUI.SkipVersionCheck = c.Bool("skip-version-check")
|
||||
|
||||
// prometheus
|
||||
server.Config.Prometheus.AuthToken = c.String("prometheus-auth-token")
|
||||
|
|
|
@ -592,6 +592,12 @@ Specify how many seconds before timeout when fetching the Woodpecker configurati
|
|||
|
||||
Enable the Swagger UI for API documentation.
|
||||
|
||||
### `WOODPECKER_DISABLE_VERSION_CHECK`
|
||||
|
||||
> Default: false
|
||||
|
||||
Disable version check in admin web UI.
|
||||
|
||||
---
|
||||
|
||||
### `WOODPECKER_GITHUB_...`
|
||||
|
|
|
@ -70,7 +70,10 @@ var Config = struct {
|
|||
RootPath string
|
||||
CustomCSSFile string
|
||||
CustomJsFile string
|
||||
}
|
||||
WebUI struct {
|
||||
EnableSwagger bool
|
||||
SkipVersionCheck bool
|
||||
}
|
||||
Prometheus struct {
|
||||
AuthToken string
|
||||
|
|
|
@ -72,7 +72,7 @@ func Load(noRouteHandler http.HandlerFunc, middleware ...gin.HandlerFunc) http.H
|
|||
}
|
||||
|
||||
apiRoutes(base)
|
||||
if server.Config.Server.EnableSwagger {
|
||||
if server.Config.WebUI.EnableSwagger {
|
||||
setupSwaggerConfigAndRoutes(e)
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,10 @@ func Config(c *gin.Context) {
|
|||
"user": user,
|
||||
"csrf": csrf,
|
||||
"version": version.String(),
|
||||
"skip_version_check": server.Config.WebUI.SkipVersionCheck,
|
||||
"forge": server.Config.Services.Forge.Name(),
|
||||
"root_path": server.Config.Server.RootPath,
|
||||
"enable_swagger": server.Config.Server.EnableSwagger,
|
||||
"enable_swagger": server.Config.WebUI.EnableSwagger,
|
||||
}
|
||||
|
||||
// default func map with json parser.
|
||||
|
@ -75,4 +76,5 @@ window.WOODPECKER_VERSION = "{{ .version }}";
|
|||
window.WOODPECKER_FORGE = "{{ .forge }}";
|
||||
window.WOODPECKER_ROOT_PATH = "{{ .root_path }}";
|
||||
window.WOODPECKER_ENABLE_SWAGGER = {{ .enable_swagger }};
|
||||
window.WOODPECKER_SKIP_VERSION_CHECK = {{ .skip_version_check }}
|
||||
`
|
||||
|
|
|
@ -4,6 +4,7 @@ declare global {
|
|||
interface Window {
|
||||
WOODPECKER_USER: User | undefined;
|
||||
WOODPECKER_VERSION: string | undefined;
|
||||
WOODPECKER_SKIP_VERSION_CHECK: boolean | undefined;
|
||||
WOODPECKER_CSRF: string | undefined;
|
||||
WOODPECKER_FORGE: 'github' | 'gitlab' | 'gitea' | 'bitbucket' | undefined;
|
||||
WOODPECKER_ROOT_PATH: string | undefined;
|
||||
|
@ -14,6 +15,7 @@ declare global {
|
|||
export default () => ({
|
||||
user: window.WOODPECKER_USER || null,
|
||||
version: window.WOODPECKER_VERSION,
|
||||
skipVersionCheck: window.WOODPECKER_SKIP_VERSION_CHECK || false,
|
||||
csrf: window.WOODPECKER_CSRF || null,
|
||||
forge: window.WOODPECKER_FORGE || null,
|
||||
rootPath: window.WOODPECKER_ROOT_PATH || '',
|
||||
|
|
|
@ -42,7 +42,7 @@ export function useVersion() {
|
|||
const usesNext = current.startsWith('next');
|
||||
|
||||
const { user } = useAuthentication();
|
||||
if (!user?.admin) {
|
||||
if (config.skipVersionCheck || !user?.admin) {
|
||||
version.value = {
|
||||
latest: undefined,
|
||||
current,
|
||||
|
|
Loading…
Reference in a new issue