2021-10-03 15:07:39 +02:00
|
|
|
// Copyright 2021 Woodpecker Authors
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2019-04-06 21:32:14 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2021-10-12 09:25:13 +02:00
|
|
|
_ "github.com/joho/godotenv/autoload"
|
2021-10-19 01:25:20 +02:00
|
|
|
"github.com/rs/zerolog"
|
|
|
|
zlog "github.com/rs/zerolog/log"
|
2021-10-12 09:25:13 +02:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
|
2021-09-21 16:36:41 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/build"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/deploy"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/exec"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/info"
|
2021-09-27 02:38:15 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/lint"
|
2021-09-21 16:36:41 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/log"
|
2021-10-19 01:25:20 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/loglevel"
|
2021-09-21 16:36:41 +02:00
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/registry"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/repo"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/secret"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/cli/user"
|
|
|
|
"github.com/woodpecker-ci/woodpecker/version"
|
2019-04-06 21:32:14 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
2021-09-21 16:36:41 +02:00
|
|
|
app.Name = "woodpecker-cli"
|
|
|
|
app.Version = version.String()
|
2019-04-06 21:32:14 +02:00
|
|
|
app.Usage = "command line utility"
|
|
|
|
app.EnableBashCompletion = true
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
cli.StringFlag{
|
Clean up config environment variables for server and agent (#218)
The goal here is to make consistent use of configuration environment variables prefixed `WOODPECKER_`. Where several variants existed, this PR aims to remove all but one option, leaving the most explicit.
This PR only changes server and agent code, but not documentation, in order to keep the PR digestible. Once we have consensus that this is correct, I'll change docs accordingly.
User (rather: admin) facing changes in this PR:
- In general, support for all server and agent config environment variables (env vars) starting with `DRONE_` is removed. The according `WOODPECKER_*` variables must be used instead.
- The env var `WOODPECKER_HOST` replaces `DRONE_HOST`, and `DRONE_SERVER_HOST`.
- The env var `WOODPECKER_AGENT_SECRET` is used to configure the shared secret which agents use to authenticate against the server. It replaces `WOODPECKER_SECRET`, `DRONE_SECRET`, `WOODPECKER_PASSWORD`, `DRONE_PASSWORD`, and `DRONE_AGENT_SECRET`.
- The env var `WOODPECKER_DATABASE_DRIVER` replaces `DRONE_DATABASE_DRIVER` and `DATABASE_DRIVER`.
- The env var `WOODPECKER_DATABASE_DATASOURCE` replaces `DRONE_DATABASE_DATASOURCE` and `DATABASE_CONFIG`.
2021-09-28 15:43:44 +02:00
|
|
|
EnvVar: "WOODPECKER_TOKEN",
|
|
|
|
// TODO: rename to `token`
|
|
|
|
Name: "t, token",
|
|
|
|
Usage: "server auth token",
|
2019-04-06 21:32:14 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
cli.StringFlag{
|
Clean up config environment variables for server and agent (#218)
The goal here is to make consistent use of configuration environment variables prefixed `WOODPECKER_`. Where several variants existed, this PR aims to remove all but one option, leaving the most explicit.
This PR only changes server and agent code, but not documentation, in order to keep the PR digestible. Once we have consensus that this is correct, I'll change docs accordingly.
User (rather: admin) facing changes in this PR:
- In general, support for all server and agent config environment variables (env vars) starting with `DRONE_` is removed. The according `WOODPECKER_*` variables must be used instead.
- The env var `WOODPECKER_HOST` replaces `DRONE_HOST`, and `DRONE_SERVER_HOST`.
- The env var `WOODPECKER_AGENT_SECRET` is used to configure the shared secret which agents use to authenticate against the server. It replaces `WOODPECKER_SECRET`, `DRONE_SECRET`, `WOODPECKER_PASSWORD`, `DRONE_PASSWORD`, and `DRONE_AGENT_SECRET`.
- The env var `WOODPECKER_DATABASE_DRIVER` replaces `DRONE_DATABASE_DRIVER` and `DATABASE_DRIVER`.
- The env var `WOODPECKER_DATABASE_DATASOURCE` replaces `DRONE_DATABASE_DATASOURCE` and `DATABASE_CONFIG`.
2021-09-28 15:43:44 +02:00
|
|
|
EnvVar: "WOODPECKER_SERVER",
|
|
|
|
// TODO: rename to `server`
|
|
|
|
Name: "s, server",
|
|
|
|
Usage: "server address",
|
2019-04-06 21:32:14 +02:00
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
Clean up config environment variables for server and agent (#218)
The goal here is to make consistent use of configuration environment variables prefixed `WOODPECKER_`. Where several variants existed, this PR aims to remove all but one option, leaving the most explicit.
This PR only changes server and agent code, but not documentation, in order to keep the PR digestible. Once we have consensus that this is correct, I'll change docs accordingly.
User (rather: admin) facing changes in this PR:
- In general, support for all server and agent config environment variables (env vars) starting with `DRONE_` is removed. The according `WOODPECKER_*` variables must be used instead.
- The env var `WOODPECKER_HOST` replaces `DRONE_HOST`, and `DRONE_SERVER_HOST`.
- The env var `WOODPECKER_AGENT_SECRET` is used to configure the shared secret which agents use to authenticate against the server. It replaces `WOODPECKER_SECRET`, `DRONE_SECRET`, `WOODPECKER_PASSWORD`, `DRONE_PASSWORD`, and `DRONE_AGENT_SECRET`.
- The env var `WOODPECKER_DATABASE_DRIVER` replaces `DRONE_DATABASE_DRIVER` and `DATABASE_DRIVER`.
- The env var `WOODPECKER_DATABASE_DATASOURCE` replaces `DRONE_DATABASE_DATASOURCE` and `DATABASE_CONFIG`.
2021-09-28 15:43:44 +02:00
|
|
|
EnvVar: "WOODPECKER_SKIP_VERIFY",
|
2021-09-21 16:36:41 +02:00
|
|
|
Name: "skip-verify",
|
|
|
|
Usage: "skip ssl verification",
|
2019-04-06 21:32:14 +02:00
|
|
|
Hidden: true,
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
2021-09-21 16:36:41 +02:00
|
|
|
EnvVar: "SOCKS_PROXY",
|
2019-04-06 21:32:14 +02:00
|
|
|
Name: "socks-proxy",
|
|
|
|
Usage: "socks proxy address",
|
|
|
|
Hidden: true,
|
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
2021-09-21 16:36:41 +02:00
|
|
|
EnvVar: "SOCKS_PROXY_OFF",
|
2019-04-06 21:32:14 +02:00
|
|
|
Name: "socks-proxy-off",
|
|
|
|
Usage: "socks proxy ignored",
|
|
|
|
Hidden: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
app.Commands = []cli.Command{
|
|
|
|
build.Command,
|
|
|
|
log.Command,
|
|
|
|
deploy.Command,
|
|
|
|
exec.Command,
|
|
|
|
info.Command,
|
|
|
|
registry.Command,
|
|
|
|
secret.Command,
|
|
|
|
repo.Command,
|
|
|
|
user.Command,
|
2021-09-27 02:38:15 +02:00
|
|
|
lint.Command,
|
2021-10-19 01:25:20 +02:00
|
|
|
loglevel.Command,
|
2019-04-06 21:32:14 +02:00
|
|
|
}
|
|
|
|
|
2021-10-19 01:25:20 +02:00
|
|
|
zlog.Logger = zlog.Output(
|
|
|
|
zerolog.ConsoleWriter{
|
|
|
|
Out: os.Stderr,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2019-04-06 21:32:14 +02:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
2021-10-19 01:25:20 +02:00
|
|
|
zlog.Fatal().Err(err).Msg("error running cli")
|
2019-04-06 21:32:14 +02:00
|
|
|
}
|
|
|
|
}
|