Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim space to all config flags that allow to read value from file #4468

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/agent/core/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {

agentConfig := readAgentConfig(agentConfigPath)

agentToken := strings.TrimSpace(c.String("grpc-token"))
agentToken := c.String("grpc-token")
grpcClientCtx, grpcClientCtxCancel := context.WithCancelCause(context.Background())
defer grpcClientCtxCancel(nil)
authClient := agent_rpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID)
Expand Down
3 changes: 3 additions & 0 deletions cmd/agent/core/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ var flags = []cli.Flag{
Sources: cli.NewValueSourceChain(
cli.File(os.Getenv("WOODPECKER_AGENT_SECRET_FILE")),
cli.EnvVar("WOODPECKER_AGENT_SECRET")),
Config: cli.StringConfig{
TrimSpace: true,
},
},
&cli.BoolFlag{
Sources: cli.EnvVars("WOODPECKER_GRPC_SECURE"),
Expand Down
27 changes: 27 additions & 0 deletions cmd/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ var flags = append([]cli.Flag{
Name: "grpc-secret",
Usage: "grpc jwt secret",
Value: "secret",
Config: cli.StringConfig{
TrimSpace: true,
},
},
&cli.StringFlag{
Sources: cli.EnvVars("WOODPECKER_METRICS_SERVER_ADDR"),
Expand Down Expand Up @@ -217,6 +220,9 @@ var flags = append([]cli.Flag{
cli.EnvVar("WOODPECKER_AGENT_SECRET")),
Name: "agent-secret",
Usage: "server-agent shared password",
Config: cli.StringConfig{
TrimSpace: true,
},
},
&cli.BoolFlag{
Sources: cli.EnvVars("WOODPECKER_DISABLE_USER_AGENT_REGISTRATION"),
Expand Down Expand Up @@ -248,13 +254,19 @@ var flags = append([]cli.Flag{
Aliases: []string{"datasource"}, // TODO: remove in v4.0.0
Usage: "database driver configuration string",
Value: datasourceDefaultValue(),
Config: cli.StringConfig{
TrimSpace: true,
},
},
&cli.StringFlag{
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",
Config: cli.StringConfig{
TrimSpace: true,
},
},
&cli.StringFlag{
Sources: cli.EnvVars("WOODPECKER_STATUS_CONTEXT", "WOODPECKER_GITHUB_CONTEXT", "WOODPECKER_GITEA_CONTEXT"),
Expand Down Expand Up @@ -354,6 +366,9 @@ var flags = append([]cli.Flag{
cli.EnvVar("WOODPECKER_BITBUCKET_DC_CLIENT_ID")),
Name: "forge-oauth-client",
Usage: "oauth2 client id",
Config: cli.StringConfig{
TrimSpace: true,
},
},
&cli.StringFlag{
Sources: cli.NewValueSourceChain(
Expand All @@ -375,6 +390,9 @@ var flags = append([]cli.Flag{
cli.EnvVar("WOODPECKER_BITBUCKET_DC_CLIENT_SECRET")),
Name: "forge-oauth-secret",
Usage: "oauth2 client secret",
Config: cli.StringConfig{
TrimSpace: true,
},
},
&cli.BoolFlag{
Name: "forge-skip-verify",
Expand Down Expand Up @@ -466,13 +484,19 @@ var flags = append([]cli.Flag{
cli.EnvVar("WOODPECKER_BITBUCKET_DC_GIT_USERNAME")),
Name: "bitbucket-dc-git-username",
Usage: "Bitbucket DataCenter/Server service account username",
Config: cli.StringConfig{
TrimSpace: true,
},
},
&cli.StringFlag{
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",
Config: cli.StringConfig{
TrimSpace: true,
},
},
//
// development flags
Expand Down Expand Up @@ -500,6 +524,9 @@ var flags = append([]cli.Flag{
cli.EnvVar("WOODPECKER_ENCRYPTION_KEY")),
Name: "encryption-raw-key",
Usage: "Raw encryption key",
Config: cli.StringConfig{
TrimSpace: true,
},
},
&cli.StringFlag{
Sources: cli.EnvVars("WOODPECKER_ENCRYPTION_TINK_KEYSET_FILE"),
Expand Down