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",
|
Name: "enable-swagger",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
EnvVars: []string{"WOODPECKER_DISABLE_VERSION_CHECK"},
|
||||||
|
Usage: "Disable version check in admin web ui.",
|
||||||
|
Name: "skip-version-check",
|
||||||
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ADDONS"},
|
EnvVars: []string{"WOODPECKER_ADDONS"},
|
||||||
Name: "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.Networks = c.StringSlice("network")
|
||||||
server.Config.Pipeline.Volumes = c.StringSlice("volume")
|
server.Config.Pipeline.Volumes = c.StringSlice("volume")
|
||||||
server.Config.Pipeline.Privileged = c.StringSlice("escalate")
|
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
|
// prometheus
|
||||||
server.Config.Prometheus.AuthToken = c.String("prometheus-auth-token")
|
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.
|
Enable the Swagger UI for API documentation.
|
||||||
|
|
||||||
|
### `WOODPECKER_DISABLE_VERSION_CHECK`
|
||||||
|
|
||||||
|
> Default: false
|
||||||
|
|
||||||
|
Disable version check in admin web UI.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### `WOODPECKER_GITHUB_...`
|
### `WOODPECKER_GITHUB_...`
|
||||||
|
|
|
@ -70,7 +70,10 @@ var Config = struct {
|
||||||
RootPath string
|
RootPath string
|
||||||
CustomCSSFile string
|
CustomCSSFile string
|
||||||
CustomJsFile string
|
CustomJsFile string
|
||||||
EnableSwagger bool
|
}
|
||||||
|
WebUI struct {
|
||||||
|
EnableSwagger bool
|
||||||
|
SkipVersionCheck bool
|
||||||
}
|
}
|
||||||
Prometheus struct {
|
Prometheus struct {
|
||||||
AuthToken string
|
AuthToken string
|
||||||
|
|
|
@ -72,7 +72,7 @@ func Load(noRouteHandler http.HandlerFunc, middleware ...gin.HandlerFunc) http.H
|
||||||
}
|
}
|
||||||
|
|
||||||
apiRoutes(base)
|
apiRoutes(base)
|
||||||
if server.Config.Server.EnableSwagger {
|
if server.Config.WebUI.EnableSwagger {
|
||||||
setupSwaggerConfigAndRoutes(e)
|
setupSwaggerConfigAndRoutes(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,13 @@ func Config(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
configData := map[string]any{
|
configData := map[string]any{
|
||||||
"user": user,
|
"user": user,
|
||||||
"csrf": csrf,
|
"csrf": csrf,
|
||||||
"version": version.String(),
|
"version": version.String(),
|
||||||
"forge": server.Config.Services.Forge.Name(),
|
"skip_version_check": server.Config.WebUI.SkipVersionCheck,
|
||||||
"root_path": server.Config.Server.RootPath,
|
"forge": server.Config.Services.Forge.Name(),
|
||||||
"enable_swagger": server.Config.Server.EnableSwagger,
|
"root_path": server.Config.Server.RootPath,
|
||||||
|
"enable_swagger": server.Config.WebUI.EnableSwagger,
|
||||||
}
|
}
|
||||||
|
|
||||||
// default func map with json parser.
|
// default func map with json parser.
|
||||||
|
@ -75,4 +76,5 @@ window.WOODPECKER_VERSION = "{{ .version }}";
|
||||||
window.WOODPECKER_FORGE = "{{ .forge }}";
|
window.WOODPECKER_FORGE = "{{ .forge }}";
|
||||||
window.WOODPECKER_ROOT_PATH = "{{ .root_path }}";
|
window.WOODPECKER_ROOT_PATH = "{{ .root_path }}";
|
||||||
window.WOODPECKER_ENABLE_SWAGGER = {{ .enable_swagger }};
|
window.WOODPECKER_ENABLE_SWAGGER = {{ .enable_swagger }};
|
||||||
|
window.WOODPECKER_SKIP_VERSION_CHECK = {{ .skip_version_check }}
|
||||||
`
|
`
|
||||||
|
|
|
@ -4,6 +4,7 @@ declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
WOODPECKER_USER: User | undefined;
|
WOODPECKER_USER: User | undefined;
|
||||||
WOODPECKER_VERSION: string | undefined;
|
WOODPECKER_VERSION: string | undefined;
|
||||||
|
WOODPECKER_SKIP_VERSION_CHECK: boolean | undefined;
|
||||||
WOODPECKER_CSRF: string | undefined;
|
WOODPECKER_CSRF: string | undefined;
|
||||||
WOODPECKER_FORGE: 'github' | 'gitlab' | 'gitea' | 'bitbucket' | undefined;
|
WOODPECKER_FORGE: 'github' | 'gitlab' | 'gitea' | 'bitbucket' | undefined;
|
||||||
WOODPECKER_ROOT_PATH: string | undefined;
|
WOODPECKER_ROOT_PATH: string | undefined;
|
||||||
|
@ -14,6 +15,7 @@ declare global {
|
||||||
export default () => ({
|
export default () => ({
|
||||||
user: window.WOODPECKER_USER || null,
|
user: window.WOODPECKER_USER || null,
|
||||||
version: window.WOODPECKER_VERSION,
|
version: window.WOODPECKER_VERSION,
|
||||||
|
skipVersionCheck: window.WOODPECKER_SKIP_VERSION_CHECK || false,
|
||||||
csrf: window.WOODPECKER_CSRF || null,
|
csrf: window.WOODPECKER_CSRF || null,
|
||||||
forge: window.WOODPECKER_FORGE || null,
|
forge: window.WOODPECKER_FORGE || null,
|
||||||
rootPath: window.WOODPECKER_ROOT_PATH || '',
|
rootPath: window.WOODPECKER_ROOT_PATH || '',
|
||||||
|
|
|
@ -42,7 +42,7 @@ export function useVersion() {
|
||||||
const usesNext = current.startsWith('next');
|
const usesNext = current.startsWith('next');
|
||||||
|
|
||||||
const { user } = useAuthentication();
|
const { user } = useAuthentication();
|
||||||
if (!user?.admin) {
|
if (config.skipVersionCheck || !user?.admin) {
|
||||||
version.value = {
|
version.value = {
|
||||||
latest: undefined,
|
latest: undefined,
|
||||||
current,
|
current,
|
||||||
|
|
Loading…
Reference in a new issue