2024-07-17 23:26:35 +00:00
// Copyright 2023 Woodpecker Authors
2021-05-31 12:35:47 +00:00
// Copyright 2019 Laszlo Fogas
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
2022-03-01 15:09:33 +00:00
"os"
2021-05-31 12:35:47 +00:00
"time"
2024-07-17 23:26:35 +00:00
"github.com/urfave/cli/v3"
2021-12-19 11:46:36 +00:00
2023-12-08 07:15:08 +00:00
"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
2023-12-31 22:29:56 +00:00
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
2021-05-31 12:35:47 +00:00
)
2023-08-07 18:47:30 +00:00
var flags = append ( [ ] cli . Flag {
2023-07-14 23:15:13 +00:00
& cli . BoolFlag {
2024-11-05 14:03:22 +00:00
Sources : cli . EnvVars ( "WOODPECKER_DATABASE_LOG" , "WOODPECKER_LOG_XORM" ) ,
Name : "db-log" ,
Aliases : [ ] string { "log-xorm" } , // TODO: remove in v4.0.0
Usage : "enable logging in database engine (currently xorm)" ,
2023-07-14 23:15:13 +00:00
} ,
& cli . BoolFlag {
2024-11-05 14:03:22 +00:00
Sources : cli . EnvVars ( "WOODPECKER_DATABASE_LOG_SQL" , "WOODPECKER_LOG_XORM_SQL" ) ,
Name : "db-log-sql" ,
Aliases : [ ] string { "log-xorm-sql" } , // TODO: remove in v4.0.0
Usage : "enable logging of sql commands" ,
} ,
& cli . IntFlag {
Sources : cli . EnvVars ( "WOODPECKER_DATABASE_MAX_CONNECTIONS" ) ,
Name : "db-max-open-connections" ,
Usage : "max connections xorm is allowed create" ,
Value : 100 ,
} ,
& cli . IntFlag {
Sources : cli . EnvVars ( "WOODPECKER_DATABASE_IDLE_CONNECTIONS" ) ,
Name : "db-max-idle-connections" ,
Usage : "amount of connections xorm will hold open" ,
Value : 2 ,
} ,
& cli . DurationFlag {
Sources : cli . EnvVars ( "WOODPECKER_DATABASE_CONNECTION_TIMEOUT" ) ,
Name : "db-max-connection-timeout" ,
Usage : "time an active connection is allowed to stay open" ,
Value : 3 * time . Second ,
2023-07-14 23:15:13 +00:00
} ,
2021-10-27 19:03:14 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_HOST" ) ,
2021-10-27 19:03:14 +00:00
Name : "server-host" ,
2024-06-04 06:30:54 +00:00
Usage : "server fully qualified url. Format: <scheme>://<host>[/<prefix path>]" ,
2023-06-18 12:47:40 +00:00
} ,
2021-10-27 19:03:14 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_SERVER_ADDR" ) ,
2021-10-27 19:03:14 +00:00
Name : "server-addr" ,
Usage : "server address" ,
Value : ":8000" ,
} ,
2023-05-11 04:11:10 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_SERVER_ADDR_TLS" ) ,
2023-05-11 04:11:10 +00:00
Name : "server-addr-tls" ,
Usage : "port https with tls (:443)" ,
Value : ":443" ,
} ,
2021-10-27 19:03:14 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_SERVER_CERT" ) ,
2021-10-27 19:03:14 +00:00
Name : "server-cert" ,
Usage : "server ssl cert path" ,
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_SERVER_KEY" ) ,
2021-10-27 19:03:14 +00:00
Name : "server-key" ,
Usage : "server ssl key path" ,
} ,
support custom .JS and .CSS files for custom banner messages (white-labeling) (#1781)
This PR introduces two new server configuration options, for providing a
custom .JS and .CSS file.
These can be used to show custom banner messages, add
environment-dependent signals, or simply a corporate logo.
### Motivation (what problem I try to solve)
I'm operating Woodpecker in multiple k8s clusters for different
environments.
When having multiple browser tabs open, I prefer strong indicators for
each environment.
E.g. a red "PROD" banner, or just a blue "QA" banner.
Also, we sometimes need to have the chance for maintenance, and instead
of broadcasting emails,
I prefer a banner message, stating something like: "Heads-up: there's a
planned downtime, next Friday, blabla...".
Also, I like to have the firm's logo visible, which makes Woodpecker
look more like an integral part of our platform.
### Implementation notes
* Two new config options are introduced ```WOODPECKER_CUSTOM_CSS_FILE```
and ```WOODPECKER_CUSTOM_JS_FILE```
* I've piggy-bagged the existing handler for assets, as it seemed to me
a minimally invasive approach
* the option along with an example is documented
* a simple unit test for the Gin-handler ensures some regression safety
* no extra dependencies are introduced
### Visual example
The documented example will look like this.
![Screenshot 2023-05-27 at 17 00
44](https://github.com/woodpecker-ci/woodpecker/assets/1189394/8940392e-463c-4651-a1eb-f017cd3cd64d)
### Areas of uncertainty
This is my first contribution to Woodpecker and I tried my best to align
with your conventions.
That said, I found myself uncertain about these things and would be glad
about getting feedback.
* The handler tests are somewhat different than the other ones because I
wanted to keep them simple - I hope that still matches your coding
guidelines
* caching the page sometimes will let the browser not recognize changes
and a user must reload. I'm not fully into the details of how caching is
implemented and neither can judge if it's a real problem. Another pair
of eyes would be good.
2023-07-10 10:46:35 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_CUSTOM_CSS_FILE" ) ,
support custom .JS and .CSS files for custom banner messages (white-labeling) (#1781)
This PR introduces two new server configuration options, for providing a
custom .JS and .CSS file.
These can be used to show custom banner messages, add
environment-dependent signals, or simply a corporate logo.
### Motivation (what problem I try to solve)
I'm operating Woodpecker in multiple k8s clusters for different
environments.
When having multiple browser tabs open, I prefer strong indicators for
each environment.
E.g. a red "PROD" banner, or just a blue "QA" banner.
Also, we sometimes need to have the chance for maintenance, and instead
of broadcasting emails,
I prefer a banner message, stating something like: "Heads-up: there's a
planned downtime, next Friday, blabla...".
Also, I like to have the firm's logo visible, which makes Woodpecker
look more like an integral part of our platform.
### Implementation notes
* Two new config options are introduced ```WOODPECKER_CUSTOM_CSS_FILE```
and ```WOODPECKER_CUSTOM_JS_FILE```
* I've piggy-bagged the existing handler for assets, as it seemed to me
a minimally invasive approach
* the option along with an example is documented
* a simple unit test for the Gin-handler ensures some regression safety
* no extra dependencies are introduced
### Visual example
The documented example will look like this.
![Screenshot 2023-05-27 at 17 00
44](https://github.com/woodpecker-ci/woodpecker/assets/1189394/8940392e-463c-4651-a1eb-f017cd3cd64d)
### Areas of uncertainty
This is my first contribution to Woodpecker and I tried my best to align
with your conventions.
That said, I found myself uncertain about these things and would be glad
about getting feedback.
* The handler tests are somewhat different than the other ones because I
wanted to keep them simple - I hope that still matches your coding
guidelines
* caching the page sometimes will let the browser not recognize changes
and a user must reload. I'm not fully into the details of how caching is
implemented and neither can judge if it's a real problem. Another pair
of eyes would be good.
2023-07-10 10:46:35 +00:00
Name : "custom-css-file" ,
Usage : "file path for the server to serve a custom .CSS file, used for customizing the UI" ,
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_CUSTOM_JS_FILE" ) ,
support custom .JS and .CSS files for custom banner messages (white-labeling) (#1781)
This PR introduces two new server configuration options, for providing a
custom .JS and .CSS file.
These can be used to show custom banner messages, add
environment-dependent signals, or simply a corporate logo.
### Motivation (what problem I try to solve)
I'm operating Woodpecker in multiple k8s clusters for different
environments.
When having multiple browser tabs open, I prefer strong indicators for
each environment.
E.g. a red "PROD" banner, or just a blue "QA" banner.
Also, we sometimes need to have the chance for maintenance, and instead
of broadcasting emails,
I prefer a banner message, stating something like: "Heads-up: there's a
planned downtime, next Friday, blabla...".
Also, I like to have the firm's logo visible, which makes Woodpecker
look more like an integral part of our platform.
### Implementation notes
* Two new config options are introduced ```WOODPECKER_CUSTOM_CSS_FILE```
and ```WOODPECKER_CUSTOM_JS_FILE```
* I've piggy-bagged the existing handler for assets, as it seemed to me
a minimally invasive approach
* the option along with an example is documented
* a simple unit test for the Gin-handler ensures some regression safety
* no extra dependencies are introduced
### Visual example
The documented example will look like this.
![Screenshot 2023-05-27 at 17 00
44](https://github.com/woodpecker-ci/woodpecker/assets/1189394/8940392e-463c-4651-a1eb-f017cd3cd64d)
### Areas of uncertainty
This is my first contribution to Woodpecker and I tried my best to align
with your conventions.
That said, I found myself uncertain about these things and would be glad
about getting feedback.
* The handler tests are somewhat different than the other ones because I
wanted to keep them simple - I hope that still matches your coding
guidelines
* caching the page sometimes will let the browser not recognize changes
and a user must reload. I'm not fully into the details of how caching is
implemented and neither can judge if it's a real problem. Another pair
of eyes would be good.
2023-07-10 10:46:35 +00:00
Name : "custom-js-file" ,
Usage : "file path for the server to serve a custom .JS file, used for customizing the UI" ,
} ,
2022-09-04 01:24:42 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_LETS_ENCRYPT_EMAIL" ) ,
2022-09-04 01:24:42 +00:00
Name : "lets-encrypt-email" ,
Usage : "let's encrypt email" ,
} ,
2022-02-06 20:21:57 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_LETS_ENCRYPT" ) ,
2022-02-06 20:21:57 +00:00
Name : "lets-encrypt" ,
Usage : "enable let's encrypt" ,
} ,
2021-10-27 19:03:14 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_GRPC_ADDR" ) ,
2021-10-27 19:03:14 +00:00
Name : "grpc-addr" ,
Usage : "grpc address" ,
Value : ":9000" ,
} ,
2023-03-19 19:24:43 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . NewValueSourceChain (
cli . File ( os . Getenv ( "WOODPECKER_GRPC_SECRET_FILE" ) ) ,
cli . EnvVar ( "WOODPECKER_GRPC_SECRET" ) ) ,
Name : "grpc-secret" ,
Usage : "grpc jwt secret" ,
Value : "secret" ,
2023-03-19 19:24:43 +00:00
} ,
2023-03-12 08:41:10 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_METRICS_SERVER_ADDR" ) ,
2023-03-12 08:41:10 +00:00
Name : "metrics-server-addr" ,
Usage : "metrics server address" ,
Value : "" ,
} ,
2021-10-27 19:03:14 +00:00
& cli . StringSliceFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_ADMIN" ) ,
2021-10-27 19:03:14 +00:00
Name : "admin" ,
Usage : "list of admin users" ,
} ,
& cli . StringSliceFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_ORGS" ) ,
2021-10-27 19:03:14 +00:00
Name : "orgs" ,
Usage : "list of approved organizations" ,
} ,
& cli . StringSliceFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_REPO_OWNERS" ) ,
2021-10-27 19:03:14 +00:00
Name : "repo-owners" ,
2024-06-04 06:30:54 +00:00
Usage : "Repositories by those owners will be allowed to be used in woodpecker" ,
2021-10-27 19:03:14 +00:00
} ,
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_OPEN" ) ,
2021-10-27 19:03:14 +00:00
Name : "open" ,
Usage : "enable open user registration" ,
} ,
2022-02-08 16:55:08 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_AUTHENTICATE_PUBLIC_REPOS" ) ,
2022-02-08 16:55:08 +00:00
Name : "authenticate-public-repos" ,
Usage : "Always use authentication to clone repositories even if they are public. Needed if the SCM requires to always authenticate as used by many companies." ,
} ,
2022-05-09 09:26:09 +00:00
& cli . StringSliceFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_DEFAULT_CANCEL_PREVIOUS_PIPELINE_EVENTS" ) ,
2022-05-09 09:26:09 +00:00
Name : "default-cancel-previous-pipeline-events" ,
Usage : "List of event names that will be canceled when a new pipeline for the same context (tag, branch) is created." ,
2024-07-17 23:26:35 +00:00
Value : [ ] string { "push" , "pull_request" } ,
2022-05-09 09:26:09 +00:00
} ,
2022-02-10 16:05:19 +00:00
& cli . StringFlag {
2024-09-01 18:41:10 +00:00
Sources : cli . EnvVars ( "WOODPECKER_DEFAULT_CLONE_PLUGIN" , "WOODPECKER_DEFAULT_CLONE_IMAGE" ) ,
Name : "default-clone-plugin" ,
Aliases : [ ] string { "default-clone-image" } ,
2022-02-10 16:05:19 +00:00
Usage : "The default docker image to be used when cloning the repo" ,
2024-09-01 18:41:10 +00:00
Value : constant . DefaultClonePlugin ,
2022-02-10 16:05:19 +00:00
} ,
2024-07-17 23:26:35 +00:00
& cli . IntFlag {
Sources : cli . EnvVars ( "WOODPECKER_DEFAULT_PIPELINE_TIMEOUT" ) ,
2023-03-19 19:24:43 +00:00
Name : "default-pipeline-timeout" ,
Usage : "The default time in minutes for a repo in minutes before a pipeline gets killed" ,
Value : 60 ,
} ,
2024-07-17 23:26:35 +00:00
& cli . IntFlag {
Sources : cli . EnvVars ( "WOODPECKER_MAX_PIPELINE_TIMEOUT" ) ,
2023-03-19 19:24:43 +00:00
Name : "max-pipeline-timeout" ,
Usage : "The maximum time in minutes you can set in the repo settings before a pipeline gets killed" ,
Value : 120 ,
} ,
2024-11-14 21:23:42 +00:00
& cli . StringSliceFlag {
Sources : cli . EnvVars ( "WOODPECKER_DEFAULT_WORKFLOW_LABELS" ) ,
Name : "default-workflow-labels" ,
Usage : "The default label filter to set for workflows that has no label filter set. By default workflows will be allowed to run on any agent, if not specified in the workflow." ,
} ,
2021-10-27 19:03:14 +00:00
& cli . DurationFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_SESSION_EXPIRES" ) ,
2021-10-27 19:03:14 +00:00
Name : "session-expires" ,
Usage : "session expiration time" ,
Value : time . Hour * 72 ,
} ,
& cli . StringSliceFlag {
2024-09-02 08:41:20 +00:00
Sources : cli . EnvVars ( "WOODPECKER_PLUGINS_PRIVILEGED" ) ,
Name : "plugins-privileged" ,
2024-08-31 17:04:47 +00:00
Usage : "Allow plugins to run in privileged mode, if environment variable is defined but empty there will be none" ,
2021-10-27 19:03:14 +00:00
} ,
2024-09-01 18:41:10 +00:00
& cli . StringSliceFlag {
Sources : cli . EnvVars ( "WOODPECKER_PLUGINS_TRUSTED_CLONE" ) ,
Name : "plugins-trusted-clone" ,
2024-11-22 08:28:41 +00:00
Usage : "Plugins which are trusted to handle Git credentials in clone steps" ,
2024-09-01 18:41:10 +00:00
Value : constant . TrustedClonePlugins ,
} ,
2021-10-27 19:03:14 +00:00
& cli . StringSliceFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_VOLUME" ) ,
2021-10-27 19:03:14 +00:00
Name : "volume" ,
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_DOCKER_CONFIG" ) ,
2021-10-27 19:03:14 +00:00
Name : "docker-config" ,
} ,
& cli . StringSliceFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_ENVIRONMENT" ) ,
2021-10-27 19:03:14 +00:00
Name : "environment" ,
} ,
& cli . StringSliceFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_NETWORK" ) ,
2021-10-27 19:03:14 +00:00
Name : "network" ,
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . NewValueSourceChain (
cli . File ( os . Getenv ( "WOODPECKER_AGENT_SECRET_FILE" ) ) ,
cli . EnvVar ( "WOODPECKER_AGENT_SECRET" ) ) ,
Name : "agent-secret" ,
Usage : "server-agent shared password" ,
2021-10-27 19:03:14 +00:00
} ,
2024-11-11 17:51:14 +00:00
& cli . BoolFlag {
Sources : cli . EnvVars ( "WOODPECKER_DISABLE_USER_AGENT_REGISTRATION" ) ,
Name : "disable-user-agent-registration" ,
Usage : "Disable user registered agents" ,
} ,
2022-02-06 20:21:57 +00:00
& cli . DurationFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_KEEPALIVE_MIN_TIME" ) ,
2022-02-06 20:21:57 +00:00
Name : "keepalive-min-time" ,
Usage : "server-side enforcement policy on the minimum amount of time a client should wait before sending a keepalive ping." ,
} ,
2022-02-28 09:56:23 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_CONFIG_SERVICE_ENDPOINT" ) ,
2022-02-28 09:56:23 +00:00
Name : "config-service-endpoint" ,
Usage : "url used for calling configuration service endpoint" ,
} ,
2021-10-27 19:03:14 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_DATABASE_DRIVER" ) ,
2024-11-05 14:03:22 +00:00
Name : "db-driver" ,
Aliases : [ ] string { "driver" } , // TODO: remove in v4.0.0
2021-10-27 19:03:14 +00:00
Usage : "database driver" ,
Value : "sqlite3" ,
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . NewValueSourceChain (
cli . File ( os . Getenv ( "WOODPECKER_DATABASE_DATASOURCE_FILE" ) ) ,
cli . EnvVar ( "WOODPECKER_DATABASE_DATASOURCE" ) ) ,
2024-11-05 14:03:22 +00:00
Name : "db-datasource" ,
Aliases : [ ] string { "datasource" } , // TODO: remove in v4.0.0
Usage : "database driver configuration string" ,
Value : datasourceDefaultValue ( ) ,
2021-10-27 19:03:14 +00:00
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . NewValueSourceChain (
cli . File ( os . Getenv ( "WOODPECKER_PROMETHEUS_AUTH_TOKEN_FILE" ) ) ,
cli . EnvVar ( "WOODPECKER_PROMETHEUS_AUTH_TOKEN" ) ) ,
Name : "prometheus-auth-token" ,
Usage : "token to secure prometheus metrics endpoint" ,
2021-05-31 12:35:47 +00:00
} ,
2022-02-06 20:21:57 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_STATUS_CONTEXT" , "WOODPECKER_GITHUB_CONTEXT" , "WOODPECKER_GITEA_CONTEXT" ) ,
2022-02-06 20:21:57 +00:00
Name : "status-context" ,
Usage : "status context prefix" ,
Value : "ci/woodpecker" ,
} ,
2022-05-12 17:07:33 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_STATUS_CONTEXT_FORMAT" ) ,
2022-05-12 17:07:33 +00:00
Name : "status-context-format" ,
Usage : "status context format" ,
2023-11-03 12:00:34 +00:00
Value : "{{ .context }}/{{ .event }}/{{ .workflow }}{{if not (eq .axis_id 0)}}/{{.axis_id}}{{end}}" ,
2022-05-12 17:07:33 +00:00
} ,
2023-06-12 20:43:14 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_MIGRATIONS_ALLOW_LONG" ) ,
2023-06-12 20:43:14 +00:00
Name : "migrations-allow-long" ,
Value : false ,
} ,
2023-08-03 00:42:30 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_ENABLE_SWAGGER" ) ,
2023-08-03 00:42:30 +00:00
Name : "enable-swagger" ,
Value : true ,
} ,
2023-12-27 21:16:15 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_DISABLE_VERSION_CHECK" ) ,
2023-12-27 21:16:15 +00:00
Usage : "Disable version check in admin web ui." ,
Name : "skip-version-check" ,
} ,
2024-06-06 12:34:57 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_LOG_STORE" ) ,
2024-06-06 12:34:57 +00:00
Name : "log-store" ,
Usage : "log store to use ('database' or 'file')" ,
Value : "database" ,
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_LOG_STORE_FILE_PATH" ) ,
2024-06-06 12:34:57 +00:00
Name : "log-store-file-path" ,
Usage : "directory used for file based log storage" ,
} ,
2021-05-31 12:35:47 +00:00
//
2023-08-07 19:13:26 +00:00
// backend options for pipeline compiler
//
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_BACKEND_NO_PROXY" , "NO_PROXY" , "no_proxy" ) ,
2023-08-07 19:13:26 +00:00
Usage : "if set, pass the environment variable down as \"NO_PROXY\" to steps" ,
Name : "backend-no-proxy" ,
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_BACKEND_HTTP_PROXY" , "HTTP_PROXY" , "http_proxy" ) ,
2023-08-19 14:27:21 +00:00
Usage : "if set, pass the environment variable down as \"HTTP_PROXY\" to steps" ,
2023-08-07 19:13:26 +00:00
Name : "backend-http-proxy" ,
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_BACKEND_HTTPS_PROXY" , "HTTPS_PROXY" , "https_proxy" ) ,
2023-08-07 19:13:26 +00:00
Usage : "if set, pass the environment variable down as \"HTTPS_PROXY\" to steps" ,
Name : "backend-https-proxy" ,
} ,
//
2021-05-31 12:35:47 +00:00
// resource limit parameters
//
2023-02-01 17:53:19 +00:00
& cli . DurationFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_FORGE_TIMEOUT" ) ,
2023-02-01 17:53:19 +00:00
Name : "forge-timeout" ,
Usage : "how many seconds before timeout when fetching the Woodpecker configuration from a Forge" ,
2024-10-27 10:21:40 +00:00
Value : time . Second * 5 ,
2023-02-01 17:53:19 +00:00
} ,
2024-05-13 17:43:45 +00:00
& cli . UintFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_FORGE_RETRY" ) ,
2024-05-13 17:43:45 +00:00
Name : "forge-retry" ,
Usage : "How many retries of fetching the Woodpecker configuration from a forge are done before we fail" ,
Value : 3 ,
} ,
2024-09-26 15:56:59 +00:00
//
// generic forge settings
2021-05-31 12:35:47 +00:00
//
2024-04-16 06:04:55 +00:00
& cli . StringFlag {
Name : "forge-url" ,
Usage : "url of the forge" ,
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_FORGE_URL" , "WOODPECKER_GITHUB_URL" , "WOODPECKER_GITLAB_URL" , "WOODPECKER_GITEA_URL" , "WOODPECKER_FORGEJO_URL" , "WOODPECKER_BITBUCKET_URL" , "WOODPECKER_BITBUCKET_DC_URL" ) ,
} ,
& cli . StringFlag {
Sources : cli . NewValueSourceChain (
cli . File ( getFirstNonEmptyEnvVar (
"WOODPECKER_FORGE_CLIENT_FILE" ,
"WOODPECKER_GITHUB_CLIENT_FILE" ,
"WOODPECKER_GITLAB_CLIENT_FILE" ,
"WOODPECKER_GITEA_CLIENT_FILE" ,
"WOODPECKER_FORGEJO_CLIENT_FILE" ,
"WOODPECKER_BITBUCKET_CLIENT_FILE" ,
"WOODPECKER_BITBUCKET_DC_CLIENT_ID_FILE" ) ) ,
cli . EnvVar ( "WOODPECKER_FORGE_CLIENT" ) ,
cli . EnvVar ( "WOODPECKER_GITHUB_CLIENT" ) ,
cli . EnvVar ( "WOODPECKER_GITLAB_CLIENT" ) ,
cli . EnvVar ( "WOODPECKER_GITEA_CLIENT" ) ,
cli . EnvVar ( "WOODPECKER_FORGEJO_CLIENT" ) ,
cli . EnvVar ( "WOODPECKER_BITBUCKET_CLIENT" ) ,
cli . EnvVar ( "WOODPECKER_BITBUCKET_DC_CLIENT_ID" ) ) ,
Name : "forge-oauth-client" ,
Usage : "oauth2 client id" ,
} ,
& cli . StringFlag {
Sources : cli . NewValueSourceChain (
cli . File ( getFirstNonEmptyEnvVar (
"WOODPECKER_FORGE_SECRET_FILE" ,
"WOODPECKER_GITHUB_SECRET_FILE" ,
"WOODPECKER_GITLAB_SECRET_FILE" ,
"WOODPECKER_GITEA_SECRET_FILE" ,
"WOODPECKER_FORGEJO_SECRET_FILE" ,
"WOODPECKER_BITBUCKET_SECRET_FILE" ,
"WOODPECKER_BITBUCKET_DC_CLIENT_SECRET_FILE" ,
) ) ,
cli . EnvVar ( "WOODPECKER_FORGE_SECRET" ) ,
cli . EnvVar ( "WOODPECKER_GITHUB_SECRET" ) ,
cli . EnvVar ( "WOODPECKER_GITLAB_SECRET" ) ,
cli . EnvVar ( "WOODPECKER_GITEA_SECRET" ) ,
cli . EnvVar ( "WOODPECKER_FORGEJO_SECRET" ) ,
cli . EnvVar ( "WOODPECKER_BITBUCKET_SECRET" ) ,
cli . EnvVar ( "WOODPECKER_BITBUCKET_DC_CLIENT_SECRET" ) ) ,
Name : "forge-oauth-secret" ,
Usage : "oauth2 client secret" ,
2021-10-27 19:03:14 +00:00
} ,
2024-04-16 06:04:55 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Name : "forge-skip-verify" ,
Usage : "skip ssl verification" ,
Sources : cli . EnvVars (
"WOODPECKER_FORGE_SKIP_VERIFY" ,
"WOODPECKER_GITHUB_SKIP_VERIFY" ,
"WOODPECKER_GITLAB_SKIP_VERIFY" ,
"WOODPECKER_GITEA_SKIP_VERIFY" ,
"WOODPECKER_FORGEJO_SKIP_VERIFY" ,
"WOODPECKER_BITBUCKET_SKIP_VERIFY" ) ,
} ,
& cli . StringFlag {
2024-07-23 12:25:39 +00:00
Sources : cli . EnvVars ( "WOODPECKER_EXPERT_FORGE_OAUTH_HOST" ) ,
2024-05-15 13:45:08 +00:00
Name : "forge-oauth-host" ,
2024-06-04 06:30:54 +00:00
Usage : "!!!for experts!!! fully qualified public forge url. Use it if your forge url WOODPECKER_FORGE_URL or WOODPECKER_GITEA_URL, ... isn't a public url. Format: <scheme>://<host>[/<prefix path>]" ,
2024-05-15 13:45:08 +00:00
} ,
2024-04-16 06:04:55 +00:00
//
// Addon
//
2021-10-27 19:03:14 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_ADDON_FORGE" ) ,
2024-04-16 06:04:55 +00:00
Name : "addon-forge" ,
Usage : "path to forge addon executable" ,
} ,
//
// GitHub
//
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_GITHUB" ) ,
2024-04-16 06:04:55 +00:00
Name : "github" ,
Usage : "github driver is enabled" ,
2021-10-27 19:03:14 +00:00
} ,
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_GITHUB_MERGE_REF" ) ,
2021-10-27 19:03:14 +00:00
Name : "github-merge-ref" ,
Usage : "github pull requests use merge ref" ,
Value : true ,
} ,
2024-03-29 13:36:48 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_GITHUB_PUBLIC_ONLY" ) ,
2024-03-29 13:36:48 +00:00
Name : "github-public-only" ,
Usage : "github tokens should only get access to public repos" ,
Value : false ,
} ,
2022-01-31 14:38:00 +00:00
//
// Gitea
//
2021-10-27 19:03:14 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_GITEA" ) ,
2021-10-27 19:03:14 +00:00
Name : "gitea" ,
Usage : "gitea driver is enabled" ,
} ,
2022-01-31 14:38:00 +00:00
//
2024-06-01 09:23:19 +00:00
// Forgejo
//
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_FORGEJO" ) ,
2024-06-01 09:23:19 +00:00
Name : "forgejo" ,
Usage : "forgejo driver is enabled" ,
} ,
//
2022-01-31 14:38:00 +00:00
// Bitbucket
//
2021-10-27 19:03:14 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_BITBUCKET" ) ,
2021-10-27 19:03:14 +00:00
Name : "bitbucket" ,
Usage : "bitbucket driver is enabled" ,
} ,
2022-01-31 14:38:00 +00:00
//
// Gitlab
//
2021-10-27 19:03:14 +00:00
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_GITLAB" ) ,
2021-10-27 19:03:14 +00:00
Name : "gitlab" ,
Usage : "gitlab driver is enabled" ,
} ,
2022-01-31 14:38:00 +00:00
//
2024-02-20 14:58:02 +00:00
// Bitbucket DataCenter/Server (previously Stash)
//
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_BITBUCKET_DC" ) ,
2024-02-20 14:58:02 +00:00
Name : "bitbucket-dc" ,
Usage : "Bitbucket DataCenter/Server driver is enabled" ,
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . NewValueSourceChain (
cli . File ( os . Getenv ( "WOODPECKER_BITBUCKET_DC_GIT_USERNAME_FILE" ) ) ,
cli . EnvVar ( "WOODPECKER_BITBUCKET_DC_GIT_USERNAME" ) ) ,
Name : "bitbucket-dc-git-username" ,
Usage : "Bitbucket DataCenter/Server service account username" ,
2024-02-20 14:58:02 +00:00
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . NewValueSourceChain (
cli . File ( os . Getenv ( "WOODPECKER_BITBUCKET_DC_GIT_PASSWORD_FILE" ) ) ,
cli . EnvVar ( "WOODPECKER_BITBUCKET_DC_GIT_PASSWORD" ) ) ,
Name : "bitbucket-dc-git-password" ,
Usage : "Bitbucket DataCenter/Server service account password" ,
2024-02-20 14:58:02 +00:00
} ,
//
2021-12-13 19:22:09 +00:00
// development flags
2022-01-31 14:38:00 +00:00
//
2021-12-13 19:22:09 +00:00
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_DEV_WWW_PROXY" ) ,
2021-12-13 19:22:09 +00:00
Name : "www-proxy" ,
Usage : "serve the website by using a proxy (used for development)" ,
Hidden : true ,
} ,
2024-05-15 13:45:08 +00:00
//
// expert flags
//
& cli . StringFlag {
2024-07-25 15:17:09 +00:00
Sources : cli . EnvVars ( "WOODPECKER_EXPERT_WEBHOOK_HOST" ) ,
2024-05-15 13:45:08 +00:00
Name : "server-webhook-host" ,
2024-06-04 06:30:54 +00:00
Usage : "!!!for experts!!! fully qualified woodpecker server url called by forge's webhooks. Format: <scheme>://<host>[/<prefix path>]" ,
2024-05-15 13:45:08 +00:00
} ,
2022-01-31 14:38:00 +00:00
//
2023-01-12 19:59:07 +00:00
// secrets encryption in DB
//
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . NewValueSourceChain (
cli . File ( os . Getenv ( "WOODPECKER_ENCRYPTION_KEY_FILE" ) ) ,
cli . EnvVar ( "WOODPECKER_ENCRYPTION_KEY" ) ) ,
Name : "encryption-raw-key" ,
Usage : "Raw encryption key" ,
2023-01-12 19:59:07 +00:00
} ,
& cli . StringFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_ENCRYPTION_TINK_KEYSET_FILE" ) ,
2023-01-12 19:59:07 +00:00
Name : "encryption-tink-keyset" ,
Usage : "Google tink AEAD-compatible keyset file to encrypt secrets in DB" ,
} ,
& cli . BoolFlag {
2024-07-17 23:26:35 +00:00
Sources : cli . EnvVars ( "WOODPECKER_ENCRYPTION_DISABLE" ) ,
2023-01-12 19:59:07 +00:00
Name : "encryption-disable-flag" ,
Usage : "Flag to decrypt all encrypted data and disable encryption on server" ,
} ,
2023-12-31 22:29:56 +00:00
} , logger . GlobalLoggerFlags ... )
2024-02-26 19:12:41 +00:00
// If woodpecker is running inside a container the default value for
// the datasource is different from running outside a container.
func datasourceDefaultValue ( ) string {
_ , found := os . LookupEnv ( "WOODPECKER_IN_CONTAINER" )
if found {
return "/var/lib/woodpecker/woodpecker.sqlite"
}
return "woodpecker.sqlite"
}
2024-05-27 09:22:31 +00:00
2024-07-17 23:26:35 +00:00
func getFirstNonEmptyEnvVar ( envVars ... string ) string {
2024-05-27 09:22:31 +00:00
for _ , envVar := range envVars {
val := os . Getenv ( envVar )
if val != "" {
return val
}
}
return ""
}