mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
Remove unused flags / options (#693)
Some flags where unused and / or unnecessary as they are covered by alternatives implemented in PRs of milestone 0.15.0 and just complicated the setup. closes #681
This commit is contained in:
parent
e2f31c3039
commit
6af94d79e3
@ -60,12 +60,6 @@ func loop(c *cli.Context) error {
|
||||
}
|
||||
|
||||
zerolog.SetGlobalLevel(zerolog.WarnLevel)
|
||||
if c.Bool("debug") {
|
||||
if c.IsSet("debug") {
|
||||
log.Warn().Msg("--debug is deprecated, use --log-level instead")
|
||||
}
|
||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||
}
|
||||
if zerolog.GlobalLevel() <= zerolog.DebugLevel {
|
||||
log.Logger = log.With().Caller().Logger()
|
||||
}
|
||||
@ -95,7 +89,7 @@ func loop(c *cli.Context) error {
|
||||
|
||||
// grpc.Dial(target, ))
|
||||
var transport grpc.DialOption
|
||||
if c.Bool("secure-grpc") {
|
||||
if c.Bool("grpc-secure") {
|
||||
transport = grpc.WithTransportCredentials(grpccredentials.NewTLS(&tls.Config{InsecureSkipVerify: c.Bool("skip-insecure-grpc")}))
|
||||
} else {
|
||||
transport = grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||
@ -105,12 +99,12 @@ func loop(c *cli.Context) error {
|
||||
c.String("server"),
|
||||
transport,
|
||||
grpc.WithPerRPCCredentials(&credentials{
|
||||
username: c.String("username"),
|
||||
password: c.String("password"),
|
||||
username: c.String("grpc-username"),
|
||||
password: c.String("grpc-password"),
|
||||
}),
|
||||
grpc.WithKeepaliveParams(keepalive.ClientParameters{
|
||||
Time: c.Duration("keepalive-time"),
|
||||
Timeout: c.Duration("keepalive-timeout"),
|
||||
Time: c.Duration("grpc-keepalive-time"),
|
||||
Timeout: c.Duration("grpc-keepalive-timeout"),
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
|
@ -29,19 +29,24 @@ var flags = []cli.Flag{
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_USERNAME"},
|
||||
Name: "username",
|
||||
Name: "grpc-username",
|
||||
Usage: "auth username",
|
||||
Value: "x-oauth-basic",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_AGENT_SECRET"},
|
||||
Name: "password",
|
||||
Name: "grpc-password",
|
||||
Usage: "server-agent shared password",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_DEBUG"},
|
||||
Name: "debug",
|
||||
Usage: "enable agent debug mode",
|
||||
EnvVars: []string{"WOODPECKER_GRPC_SECURE"},
|
||||
Name: "grpc-secure",
|
||||
Usage: "should the connection to WOODPECKER_SERVER be made using a secure transport",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GRPC_VERIFY"},
|
||||
Name: "grpc-skip-insecure",
|
||||
Usage: "should the grpc server certificate be verified, only valid when WOODPECKER_GRPC_SECURE is true",
|
||||
Value: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
@ -93,17 +98,6 @@ var flags = []cli.Flag{
|
||||
Usage: "after pinging for a keepalive check, the agent waits for a duration of this time before closing the connection if no activity",
|
||||
Value: time.Second * 20,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GRPC_SECURE"},
|
||||
Name: "secure-grpc",
|
||||
Usage: "should the connection to WOODPECKER_SERVER be made using a secure transport",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GRPC_VERIFY"},
|
||||
Name: "skip-insecure-grpc",
|
||||
Usage: "should the grpc server certificate be verified, only valid when WOODPECKER_GRPC_SECURE is true",
|
||||
Value: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_BACKEND"},
|
||||
Name: "backend-engine",
|
||||
|
@ -23,11 +23,6 @@ import (
|
||||
)
|
||||
|
||||
var flags = []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_DEBUG"},
|
||||
Name: "debug",
|
||||
Usage: "enable server debug mode",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_LOG_LEVEL"},
|
||||
Name: "log-level",
|
||||
@ -76,11 +71,6 @@ var flags = []cli.Flag{
|
||||
Name: "lets-encrypt",
|
||||
Usage: "enable let's encrypt",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_QUIC"},
|
||||
Name: "quic",
|
||||
Usage: "enable quic",
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
EnvVars: []string{"WOODPECKER_ADMIN"},
|
||||
Name: "admin",
|
||||
@ -207,7 +197,7 @@ var flags = []cli.Flag{
|
||||
Usage: "set the cpus allowed to execute containers",
|
||||
},
|
||||
//
|
||||
// remote parameters
|
||||
// Github
|
||||
//
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_STATUS_CONTEXT", "WOODPECKER_GITHUB_CONTEXT", "WOODPECKER_GITEA_CONTEXT"},
|
||||
@ -215,13 +205,6 @@ var flags = []cli.Flag{
|
||||
Usage: "status context prefix",
|
||||
Value: "ci/woodpecker",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "flat-permissions",
|
||||
Usage: "no remote call for permissions should be made",
|
||||
EnvVars: []string{"WOODPECKER_FLAT_PERMISSIONS"},
|
||||
Hidden: true,
|
||||
// TODO(485) temporary workaround to not hit api rate limits
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITHUB"},
|
||||
Name: "github",
|
||||
@ -243,43 +226,20 @@ var flags = []cli.Flag{
|
||||
Name: "github-secret",
|
||||
Usage: "github oauth2 client secret",
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITHUB_SCOPE"},
|
||||
Name: "github-scope",
|
||||
Usage: "github oauth scope",
|
||||
Value: cli.NewStringSlice(
|
||||
"repo",
|
||||
"repo:status",
|
||||
"user:email",
|
||||
"read:org",
|
||||
),
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITHUB_GIT_USERNAME"},
|
||||
Name: "github-git-username",
|
||||
Usage: "github machine user username",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITHUB_GIT_PASSWORD"},
|
||||
Name: "github-git-password",
|
||||
Usage: "github machine user password",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITHUB_MERGE_REF"},
|
||||
Name: "github-merge-ref",
|
||||
Usage: "github pull requests use merge ref",
|
||||
Value: true,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITHUB_PRIVATE_MODE"},
|
||||
Name: "github-private-mode",
|
||||
Usage: "github is running in private mode",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITHUB_SKIP_VERIFY"},
|
||||
Name: "github-skip-verify",
|
||||
Usage: "github skip ssl verification",
|
||||
},
|
||||
//
|
||||
// Gogs
|
||||
//
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GOGS"},
|
||||
Name: "gogs",
|
||||
@ -311,6 +271,9 @@ var flags = []cli.Flag{
|
||||
Name: "gogs-skip-verify",
|
||||
Usage: "gogs skip ssl verification",
|
||||
},
|
||||
//
|
||||
// Gitea
|
||||
//
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITEA"},
|
||||
Name: "gitea",
|
||||
@ -332,26 +295,14 @@ var flags = []cli.Flag{
|
||||
Name: "gitea-secret",
|
||||
Usage: "gitea oauth2 client secret",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITEA_GIT_USERNAME"},
|
||||
Name: "gitea-git-username",
|
||||
Usage: "gitea service account username",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITEA_GIT_PASSWORD"},
|
||||
Name: "gitea-git-password",
|
||||
Usage: "gitea service account password",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITEA_PRIVATE_MODE"},
|
||||
Name: "gitea-private-mode",
|
||||
Usage: "gitea private mode enabled",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITEA_SKIP_VERIFY"},
|
||||
Name: "gitea-skip-verify",
|
||||
Usage: "gitea skip ssl verification",
|
||||
},
|
||||
//
|
||||
// Bitbucket
|
||||
//
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_BITBUCKET"},
|
||||
Name: "bitbucket",
|
||||
@ -367,6 +318,9 @@ var flags = []cli.Flag{
|
||||
Name: "bitbucket-secret",
|
||||
Usage: "bitbucket oauth2 client secret",
|
||||
},
|
||||
//
|
||||
// Gitlab
|
||||
//
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITLAB"},
|
||||
Name: "gitlab",
|
||||
@ -388,26 +342,14 @@ var flags = []cli.Flag{
|
||||
Name: "gitlab-secret",
|
||||
Usage: "gitlab oauth2 client secret",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITLAB_GIT_USERNAME"},
|
||||
Name: "gitlab-git-username",
|
||||
Usage: "gitlab service account username",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITLAB_GIT_PASSWORD"},
|
||||
Name: "gitlab-git-password",
|
||||
Usage: "gitlab service account password",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITLAB_SKIP_VERIFY"},
|
||||
Name: "gitlab-skip-verify",
|
||||
Usage: "gitlab skip ssl verification",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_GITLAB_PRIVATE_MODE"},
|
||||
Name: "gitlab-private-mode",
|
||||
Usage: "gitlab is running in private mode",
|
||||
},
|
||||
//
|
||||
// Bitbucket Stash
|
||||
//
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_STASH"},
|
||||
Name: "stash",
|
||||
@ -448,6 +390,9 @@ var flags = []cli.Flag{
|
||||
Name: "stash-skip-verify",
|
||||
Usage: "stash skip ssl verification",
|
||||
},
|
||||
//
|
||||
// Coding
|
||||
//
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_CODING"},
|
||||
Name: "coding",
|
||||
@ -505,7 +450,9 @@ var flags = []cli.Flag{
|
||||
Name: "keepalive-min-time",
|
||||
Usage: "server-side enforcement policy on the minimum amount of time a client should wait before sending a keepalive ping.",
|
||||
},
|
||||
//
|
||||
// development flags
|
||||
//
|
||||
&cli.StringFlag{
|
||||
EnvVars: []string{"WOODPECKER_DEV_WWW_PROXY"},
|
||||
Name: "www-proxy",
|
||||
@ -519,4 +466,14 @@ var flags = []cli.Flag{
|
||||
Value: "",
|
||||
Hidden: true,
|
||||
},
|
||||
//
|
||||
// misc
|
||||
//
|
||||
&cli.BoolFlag{
|
||||
EnvVars: []string{"WOODPECKER_FLAT_PERMISSIONS"},
|
||||
Name: "flat-permissions",
|
||||
Usage: "no remote call for permissions should be made",
|
||||
Hidden: true,
|
||||
// TODO(485) temporary workaround to not hit api rate limits
|
||||
},
|
||||
}
|
||||
|
@ -60,13 +60,8 @@ func run(c *cli.Context) error {
|
||||
)
|
||||
}
|
||||
|
||||
// debug level if requested by user
|
||||
// TODO: format output & options to switch to json aka. option to add channels to send logs to
|
||||
zerolog.SetGlobalLevel(zerolog.WarnLevel)
|
||||
if c.Bool("debug") {
|
||||
log.Warn().Msg("--debug is deprecated, use --log-level instead")
|
||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||
}
|
||||
if c.IsSet("log-level") {
|
||||
logLevelFlag := c.String("log-level")
|
||||
lvl, err := zerolog.ParseLevel(logLevelFlag)
|
||||
|
@ -228,13 +228,10 @@ func setupGitea(c *cli.Context) (remote.Remote, error) {
|
||||
return nil, err
|
||||
}
|
||||
opts := gitea.Opts{
|
||||
URL: strings.TrimRight(server.String(), "/"),
|
||||
Username: c.String("gitea-git-username"),
|
||||
Password: c.String("gitea-git-password"),
|
||||
Client: c.String("gitea-client"),
|
||||
Secret: c.String("gitea-secret"),
|
||||
PrivateMode: c.Bool("gitea-private-mode"),
|
||||
SkipVerify: c.Bool("gitea-skip-verify"),
|
||||
URL: strings.TrimRight(server.String(), "/"),
|
||||
Client: c.String("gitea-client"),
|
||||
Secret: c.String("gitea-secret"),
|
||||
SkipVerify: c.Bool("gitea-skip-verify"),
|
||||
}
|
||||
if len(opts.URL) == 0 {
|
||||
log.Fatal().Msg("WOODPECKER_GITEA_URL must be set")
|
||||
@ -264,9 +261,6 @@ func setupGitlab(c *cli.Context) (remote.Remote, error) {
|
||||
URL: c.String("gitlab-server"),
|
||||
ClientID: c.String("gitlab-client"),
|
||||
ClientSecret: c.String("gitlab-secret"),
|
||||
Username: c.String("gitlab-git-username"),
|
||||
Password: c.String("gitlab-git-password"),
|
||||
PrivateMode: c.Bool("gitlab-private-mode"),
|
||||
SkipVerify: c.Bool("gitlab-skip-verify"),
|
||||
})
|
||||
}
|
||||
@ -274,15 +268,11 @@ func setupGitlab(c *cli.Context) (remote.Remote, error) {
|
||||
// helper function to setup the GitHub remote from the CLI arguments.
|
||||
func setupGithub(c *cli.Context) (remote.Remote, error) {
|
||||
opts := github.Opts{
|
||||
URL: c.String("github-server"),
|
||||
Client: c.String("github-client"),
|
||||
Secret: c.String("github-secret"),
|
||||
Scopes: c.StringSlice("github-scope"),
|
||||
Username: c.String("github-git-username"),
|
||||
Password: c.String("github-git-password"),
|
||||
PrivateMode: c.Bool("github-private-mode"),
|
||||
SkipVerify: c.Bool("github-skip-verify"),
|
||||
MergeRef: c.Bool("github-merge-ref"),
|
||||
URL: c.String("github-server"),
|
||||
Client: c.String("github-client"),
|
||||
Secret: c.String("github-secret"),
|
||||
SkipVerify: c.Bool("github-skip-verify"),
|
||||
MergeRef: c.Bool("github-merge-ref"),
|
||||
}
|
||||
log.Trace().Msgf("Remote (github) opts: %#v", opts)
|
||||
return github.New(opts)
|
||||
|
@ -40,17 +40,7 @@ WOODPECKER_GITHUB_CLIENT=... # GitHub oauth2 client id
|
||||
|
||||
WOODPECKER_GITHUB_SECRET=... # GitHub oauth2 client secret.
|
||||
|
||||
WOODPECKER_GITHUB_SCOPE=repo,repo:status,user:email,read:org # Comma-separated GitHub oauth scope.
|
||||
|
||||
WOODPECKER_GITHUB_GIT_USERNAME=... # Optional. Use a single machine account username to clone all repositories.
|
||||
|
||||
WOODPECKER_GITHUB_GIT_PASSWORD=... # Optional. Use a single machine account password to clone all repositories.
|
||||
|
||||
WOODPECKER_GITHUB_PRIVATE_MODE=false # Set to true if GitHub is running in private mode.
|
||||
|
||||
WOODPECKER_GITHUB_MERGE_REF=true # Set to true to use the `refs/pulls/%d/merge` vs `refs/pulls/%d/head`
|
||||
|
||||
WOODPECKER_GITHUB_CONTEXT=continuous-integration/woodpecker # Customize the GitHub status message context
|
||||
|
||||
WOODPECKER_GITHUB_SKIP_VERIFY=false # Set to true to disable SSL verification
|
||||
```
|
||||
|
@ -48,13 +48,5 @@ WOODPECKER_GITEA_CLIENT=... # Gitea oauth2 client id
|
||||
|
||||
WOODPECKER_GITEA_SECRET=... # Gitea oauth2 client secret
|
||||
|
||||
WOODPECKER_GITEA_CONTEXT=continuous-integration/woodpecker # Customize the Gitea status message context
|
||||
|
||||
WOODPECKER_GITEA_GIT_USERNAME=... # Optional. Use a single machine account username to clone all repositories.
|
||||
|
||||
WOODPECKER_GITEA_GIT_PASSWORD=... # Optional. Use a single machine account password to clone all repositories.
|
||||
|
||||
WOODPECKER_GITEA_PRIVATE_MODE=true # Set to true if Gitea is running in private mode.
|
||||
|
||||
WOODPECKER_GITEA_SKIP_VERIFY=false # Set to true to disable SSL verification.
|
||||
```
|
||||
|
@ -40,11 +40,5 @@ WOODPECKER_GITLAB_CLIENT=... # GitLab oauth2 client id
|
||||
|
||||
WOODPECKER_GITLAB_SECRET=... # GitLab oauth2 client secret.
|
||||
|
||||
WOODPECKER_GITLAB_GIT_USERNAME=... # Optional. Use a single machine account username to clone all repositories
|
||||
|
||||
WOODPECKER_GITLAB_GIT_PASSWORD=... # Optional. Use a single machine account password to clone all repositories
|
||||
|
||||
WOODPECKER_GITLAB_SKIP_VERIFY=false # Set to true to disable SSL verification
|
||||
|
||||
WOODPECKER_GITLAB_PRIVATE_MODE=false # Set to true if GitLab is running in private mode
|
||||
```
|
||||
|
@ -65,6 +65,10 @@ Some versions need some changes to the server configuration or the pipeline conf
|
||||
+ setting2: bar
|
||||
```
|
||||
|
||||
- `WOODPECKER_DEBUG` option for server and agent got removed in favor of `WOODPECKER_LOG_LEVEL=debug`
|
||||
|
||||
- Remove unused server flags which can safely be removed from your server config: `WOODPECKER_QUIC`, `WOODPECKER_GITHUB_SCOPE`, `WOODPECKER_GITHUB_GIT_USERNAME`, `WOODPECKER_GITHUB_GIT_PASSWORD`, `WOODPECKER_GITHUB_PRIVATE_MODE`, `WOODPECKER_GITEA_GIT_USERNAME`, `WOODPECKER_GITEA_GIT_PASSWORD`, `WOODPECKER_GITEA_PRIVATE_MODE`, `WOODPECKER_GITLAB_GIT_USERNAME`, `WOODPECKER_GITLAB_GIT_PASSWORD`, `WOODPECKER_GITLAB_PRIVATE_MODE`
|
||||
|
||||
- Dropped support for manually setting the agents platform with `WOODPECKER_PLATFORM`. The platform is now automatically detected.
|
||||
|
||||
- Use `WOODPECKER_STATUS_CONTEXT` instead of the deprecated options `WOODPECKER_GITHUB_CONTEXT` and `WOODPECKER_GITEA_CONTEXT`.
|
||||
|
@ -44,25 +44,18 @@ const (
|
||||
|
||||
type Gitea struct {
|
||||
URL string
|
||||
Context string
|
||||
Machine string
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
Username string
|
||||
Password string
|
||||
PrivateMode bool
|
||||
SkipVerify bool
|
||||
}
|
||||
|
||||
// Opts defines configuration options.
|
||||
type Opts struct {
|
||||
URL string // Gitea server url.
|
||||
Client string // OAuth2 Client ID
|
||||
Secret string // OAuth2 Client Secret
|
||||
Username string // Optional machine account username.
|
||||
Password string // Optional machine account password.
|
||||
PrivateMode bool // Gitea is running in private mode.
|
||||
SkipVerify bool // Skip ssl verification.
|
||||
URL string // Gitea server url.
|
||||
Client string // OAuth2 Client ID
|
||||
Secret string // OAuth2 Client Secret
|
||||
SkipVerify bool // Skip ssl verification.
|
||||
}
|
||||
|
||||
// New returns a Remote implementation that integrates with Gitea,
|
||||
@ -81,9 +74,6 @@ func New(opts Opts) (remote.Remote, error) {
|
||||
Machine: u.Host,
|
||||
ClientID: opts.Client,
|
||||
ClientSecret: opts.Secret,
|
||||
Username: opts.Username,
|
||||
Password: opts.Password,
|
||||
PrivateMode: opts.PrivateMode,
|
||||
SkipVerify: opts.SkipVerify,
|
||||
}, nil
|
||||
}
|
||||
@ -231,10 +221,7 @@ func (c *Gitea) Repo(ctx context.Context, u *model.User, owner, name string) (*m
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if c.PrivateMode {
|
||||
repo.Private = true
|
||||
}
|
||||
return toRepo(repo, c.PrivateMode), nil
|
||||
return toRepo(repo), nil
|
||||
}
|
||||
|
||||
// Repos returns a list of all repositories for the Gitea account, including
|
||||
@ -263,7 +250,7 @@ func (c *Gitea) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error)
|
||||
}
|
||||
|
||||
for _, repo := range all {
|
||||
repos = append(repos, toRepo(repo, c.PrivateMode))
|
||||
repos = append(repos, toRepo(repo))
|
||||
}
|
||||
|
||||
if len(all) < perPage {
|
||||
@ -360,16 +347,17 @@ func (c *Gitea) Status(ctx context.Context, user *model.User, repo *model.Repo,
|
||||
// cloning Gitea repositories. The netrc will use the global machine account
|
||||
// when configured.
|
||||
func (c *Gitea) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
||||
if c.Password != "" {
|
||||
return &model.Netrc{
|
||||
Login: c.Username,
|
||||
Password: c.Password,
|
||||
Machine: c.Machine,
|
||||
}, nil
|
||||
login := ""
|
||||
token := ""
|
||||
|
||||
if u != nil {
|
||||
login = u.Login
|
||||
token = u.Token
|
||||
}
|
||||
|
||||
return &model.Netrc{
|
||||
Login: u.Login,
|
||||
Password: u.Token,
|
||||
Login: login,
|
||||
Password: token,
|
||||
Machine: c.Machine,
|
||||
}, nil
|
||||
}
|
||||
|
@ -45,18 +45,12 @@ func Test_gitea(t *testing.T) {
|
||||
g.Describe("Creating a remote", func() {
|
||||
g.It("Should return client with specified options", func() {
|
||||
remote, _ := New(Opts{
|
||||
URL: "http://localhost:8080",
|
||||
Username: "someuser",
|
||||
Password: "password",
|
||||
SkipVerify: true,
|
||||
PrivateMode: true,
|
||||
URL: "http://localhost:8080",
|
||||
SkipVerify: true,
|
||||
})
|
||||
g.Assert(remote.(*Gitea).URL).Equal("http://localhost:8080")
|
||||
g.Assert(remote.(*Gitea).Machine).Equal("localhost")
|
||||
g.Assert(remote.(*Gitea).Username).Equal("someuser")
|
||||
g.Assert(remote.(*Gitea).Password).Equal("password")
|
||||
g.Assert(remote.(*Gitea).SkipVerify).Equal(true)
|
||||
g.Assert(remote.(*Gitea).PrivateMode).Equal(true)
|
||||
})
|
||||
g.It("Should handle malformed url", func() {
|
||||
_, err := New(Opts{URL: "%gh&%ij"})
|
||||
@ -76,14 +70,12 @@ func Test_gitea(t *testing.T) {
|
||||
})
|
||||
g.It("Should return a netrc with the machine account", func() {
|
||||
remote, _ := New(Opts{
|
||||
URL: "http://gitea.com",
|
||||
Username: "someuser",
|
||||
Password: "password",
|
||||
URL: "http://gitea.com",
|
||||
})
|
||||
netrc, _ := remote.Netrc(nil, nil)
|
||||
g.Assert(netrc.Machine).Equal("gitea.com")
|
||||
g.Assert(netrc.Login).Equal("someuser")
|
||||
g.Assert(netrc.Password).Equal("password")
|
||||
g.Assert(netrc.Login).Equal("")
|
||||
g.Assert(netrc.Password).Equal("")
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -29,16 +29,12 @@ import (
|
||||
)
|
||||
|
||||
// helper function that converts a Gitea repository to a Woodpecker repository.
|
||||
func toRepo(from *gitea.Repository, privateMode bool) *model.Repo {
|
||||
func toRepo(from *gitea.Repository) *model.Repo {
|
||||
name := strings.Split(from.FullName, "/")[1]
|
||||
avatar := expandAvatar(
|
||||
from.HTMLURL,
|
||||
from.Owner.AvatarURL,
|
||||
)
|
||||
private := from.Private
|
||||
if privateMode {
|
||||
private = true
|
||||
}
|
||||
return &model.Repo{
|
||||
SCMKind: model.RepoGit,
|
||||
Name: name,
|
||||
@ -46,7 +42,7 @@ func toRepo(from *gitea.Repository, privateMode bool) *model.Repo {
|
||||
FullName: from.FullName,
|
||||
Avatar: avatar,
|
||||
Link: from.HTMLURL,
|
||||
IsSCMPrivate: private,
|
||||
IsSCMPrivate: from.Private,
|
||||
Clone: from.CloneURL,
|
||||
Branch: from.DefaultBranch,
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ func Test_parse(t *testing.T) {
|
||||
Private: true,
|
||||
DefaultBranch: "master",
|
||||
}
|
||||
repo := toRepo(&from, false)
|
||||
repo := toRepo(&from)
|
||||
g.Assert(repo.FullName).Equal(from.FullName)
|
||||
g.Assert(repo.Owner).Equal(from.Owner.UserName)
|
||||
g.Assert(repo.Name).Equal("hello-world")
|
||||
|
@ -80,7 +80,7 @@ func convertDesc(status model.StatusValue) string {
|
||||
|
||||
// convertRepo is a helper function used to convert a GitHub repository
|
||||
// structure to the common Woodpecker repository structure.
|
||||
func convertRepo(from *github.Repository, private bool) *model.Repo {
|
||||
func convertRepo(from *github.Repository) *model.Repo {
|
||||
repo := &model.Repo{
|
||||
Name: from.GetName(),
|
||||
FullName: from.GetFullName(),
|
||||
@ -96,9 +96,6 @@ func convertRepo(from *github.Repository, private bool) *model.Repo {
|
||||
if len(repo.Branch) == 0 {
|
||||
repo.Branch = defaultBranch
|
||||
}
|
||||
if private {
|
||||
repo.IsSCMPrivate = true
|
||||
}
|
||||
return repo
|
||||
}
|
||||
|
||||
@ -114,10 +111,10 @@ func convertPerm(perm map[string]bool) *model.Perm {
|
||||
|
||||
// convertRepoList is a helper function used to convert a GitHub repository
|
||||
// list to the common Woodpecker repository structure.
|
||||
func convertRepoList(from []*github.Repository, private bool) []*model.Repo {
|
||||
func convertRepoList(from []*github.Repository) []*model.Repo {
|
||||
var repos []*model.Repo
|
||||
for _, repo := range from {
|
||||
repos = append(repos, convertRepo(repo, private))
|
||||
repos = append(repos, convertRepo(repo))
|
||||
}
|
||||
return repos
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ func Test_helper(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
to := convertRepoList(from, false)
|
||||
to := convertRepoList(from)
|
||||
g.Assert(to[0].Avatar).Equal("http://...")
|
||||
g.Assert(to[0].FullName).Equal("octocat/hello-world")
|
||||
g.Assert(to[0].Owner).Equal("octocat")
|
||||
@ -108,7 +108,7 @@ func Test_helper(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
to := convertRepo(&from, false)
|
||||
to := convertRepo(&from)
|
||||
g.Assert(to.Avatar).Equal("http://...")
|
||||
g.Assert(to.FullName).Equal("octocat/hello-world")
|
||||
g.Assert(to.Owner).Equal("octocat")
|
||||
@ -204,7 +204,7 @@ func Test_helper(t *testing.T) {
|
||||
Login: github.String("octocat"),
|
||||
},
|
||||
}
|
||||
pull, _, build, err := parsePullHook(from, true, false)
|
||||
pull, _, build, err := parsePullHook(from, true)
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(pull).IsNotNil()
|
||||
g.Assert(build.Event).Equal(model.EventPull)
|
||||
@ -231,7 +231,7 @@ func Test_helper(t *testing.T) {
|
||||
from.Sender.Login = github.String("octocat")
|
||||
from.Sender.AvatarURL = github.String("https://avatars1.githubusercontent.com/u/583231")
|
||||
|
||||
_, build, err := parseDeployHook(from, false)
|
||||
_, build, err := parseDeployHook(from)
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(build.Event).Equal(model.EventDeploy)
|
||||
g.Assert(build.Branch).Equal("master")
|
||||
|
@ -44,15 +44,11 @@ const (
|
||||
|
||||
// Opts defines configuration options.
|
||||
type Opts struct {
|
||||
URL string // GitHub server url.
|
||||
Client string // GitHub oauth client id.
|
||||
Secret string // GitHub oauth client secret.
|
||||
Scopes []string // GitHub oauth scopes
|
||||
Username string // Optional machine account username.
|
||||
Password string // Optional machine account password.
|
||||
PrivateMode bool // GitHub is running in private mode.
|
||||
SkipVerify bool // Skip ssl verification.
|
||||
MergeRef bool // Clone pull requests using the merge ref.
|
||||
URL string // GitHub server url.
|
||||
Client string // GitHub oauth client id.
|
||||
Secret string // GitHub oauth client secret.
|
||||
SkipVerify bool // Skip ssl verification.
|
||||
MergeRef bool // Clone pull requests using the merge ref.
|
||||
}
|
||||
|
||||
// New returns a Remote implementation that integrates with a GitHub Cloud or
|
||||
@ -67,17 +63,13 @@ func New(opts Opts) (remote.Remote, error) {
|
||||
u.Host = host
|
||||
}
|
||||
r := &client{
|
||||
API: defaultAPI,
|
||||
URL: defaultURL,
|
||||
Client: opts.Client,
|
||||
Secret: opts.Secret,
|
||||
Scopes: opts.Scopes,
|
||||
PrivateMode: opts.PrivateMode,
|
||||
SkipVerify: opts.SkipVerify,
|
||||
MergeRef: opts.MergeRef,
|
||||
Machine: u.Host,
|
||||
Username: opts.Username,
|
||||
Password: opts.Password,
|
||||
API: defaultAPI,
|
||||
URL: defaultURL,
|
||||
Client: opts.Client,
|
||||
Secret: opts.Secret,
|
||||
SkipVerify: opts.SkipVerify,
|
||||
MergeRef: opts.MergeRef,
|
||||
Machine: u.Host,
|
||||
}
|
||||
if opts.URL != defaultURL {
|
||||
r.URL = strings.TrimSuffix(opts.URL, "/")
|
||||
@ -88,17 +80,13 @@ func New(opts Opts) (remote.Remote, error) {
|
||||
}
|
||||
|
||||
type client struct {
|
||||
URL string
|
||||
API string
|
||||
Client string
|
||||
Secret string
|
||||
Scopes []string
|
||||
Machine string
|
||||
Username string
|
||||
Password string
|
||||
PrivateMode bool
|
||||
SkipVerify bool
|
||||
MergeRef bool
|
||||
URL string
|
||||
API string
|
||||
Client string
|
||||
Secret string
|
||||
Machine string
|
||||
SkipVerify bool
|
||||
MergeRef bool
|
||||
}
|
||||
|
||||
// Login authenticates the session and returns the remote user details.
|
||||
@ -188,7 +176,7 @@ func (c *client) Repo(ctx context.Context, u *model.User, owner, name string) (*
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return convertRepo(repo, c.PrivateMode), nil
|
||||
return convertRepo(repo), nil
|
||||
}
|
||||
|
||||
// Repos returns a list of all repositories for GitHub account, including
|
||||
@ -206,7 +194,7 @@ func (c *client) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
repos = append(repos, convertRepoList(list, c.PrivateMode)...)
|
||||
repos = append(repos, convertRepoList(list)...)
|
||||
opts.Page = resp.NextPage
|
||||
}
|
||||
return repos, nil
|
||||
@ -287,16 +275,17 @@ func (c *client) Dir(ctx context.Context, u *model.User, r *model.Repo, b *model
|
||||
// cloning GitHub repositories. The netrc will use the global machine account
|
||||
// when configured.
|
||||
func (c *client) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
||||
if c.Password != "" {
|
||||
return &model.Netrc{
|
||||
Login: c.Username,
|
||||
Password: c.Password,
|
||||
Machine: c.Machine,
|
||||
}, nil
|
||||
login := ""
|
||||
token := ""
|
||||
|
||||
if u != nil {
|
||||
login = u.Token
|
||||
token = "x-oauth-basic"
|
||||
}
|
||||
|
||||
return &model.Netrc{
|
||||
Login: u.Token,
|
||||
Password: "x-oauth-basic",
|
||||
Login: login,
|
||||
Password: token,
|
||||
Machine: c.Machine,
|
||||
}, nil
|
||||
}
|
||||
@ -347,7 +336,7 @@ func (c *client) newConfig(req *http.Request) *oauth2.Config {
|
||||
return &oauth2.Config{
|
||||
ClientID: c.Client,
|
||||
ClientSecret: c.Secret,
|
||||
Scopes: c.Scopes,
|
||||
Scopes: []string{"repo", "repo:status", "user:email", "read:org"},
|
||||
Endpoint: oauth2.Endpoint{
|
||||
AuthURL: fmt.Sprintf("%s/login/oauth/authorize", c.URL),
|
||||
TokenURL: fmt.Sprintf("%s/login/oauth/access_token", c.URL),
|
||||
@ -492,7 +481,7 @@ func (c *client) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]
|
||||
// Hook parses the post-commit hook from the Request body
|
||||
// and returns the required data in a standard format.
|
||||
func (c *client) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model.Build, error) {
|
||||
pull, repo, build, err := parseHook(r, c.MergeRef, c.PrivateMode)
|
||||
pull, repo, build, err := parseHook(r, c.MergeRef)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -45,23 +45,17 @@ func Test_github(t *testing.T) {
|
||||
g.Describe("Creating a remote", func() {
|
||||
g.It("Should return client with specified options", func() {
|
||||
remote, _ := New(Opts{
|
||||
URL: "http://localhost:8080/",
|
||||
Client: "0ZXh0IjoiI",
|
||||
Secret: "I1NiIsInR5",
|
||||
Username: "someuser",
|
||||
Password: "password",
|
||||
SkipVerify: true,
|
||||
PrivateMode: true,
|
||||
URL: "http://localhost:8080/",
|
||||
Client: "0ZXh0IjoiI",
|
||||
Secret: "I1NiIsInR5",
|
||||
SkipVerify: true,
|
||||
})
|
||||
g.Assert(remote.(*client).URL).Equal("http://localhost:8080")
|
||||
g.Assert(remote.(*client).API).Equal("http://localhost:8080/api/v3/")
|
||||
g.Assert(remote.(*client).Machine).Equal("localhost")
|
||||
g.Assert(remote.(*client).Username).Equal("someuser")
|
||||
g.Assert(remote.(*client).Password).Equal("password")
|
||||
g.Assert(remote.(*client).Client).Equal("0ZXh0IjoiI")
|
||||
g.Assert(remote.(*client).Secret).Equal("I1NiIsInR5")
|
||||
g.Assert(remote.(*client).SkipVerify).Equal(true)
|
||||
g.Assert(remote.(*client).PrivateMode).Equal(true)
|
||||
})
|
||||
g.It("Should handle malformed url", func() {
|
||||
_, err := New(Opts{URL: "%gh&%ij"})
|
||||
@ -81,14 +75,12 @@ func Test_github(t *testing.T) {
|
||||
})
|
||||
g.It("Should return a netrc with the machine account", func() {
|
||||
remote, _ := New(Opts{
|
||||
URL: "http://github.com:443",
|
||||
Username: "someuser",
|
||||
Password: "password",
|
||||
URL: "http://github.com:443",
|
||||
})
|
||||
netrc, _ := remote.Netrc(nil, nil)
|
||||
g.Assert(netrc.Machine).Equal("github.com")
|
||||
g.Assert(netrc.Login).Equal("someuser")
|
||||
g.Assert(netrc.Password).Equal("password")
|
||||
g.Assert(netrc.Login).Equal("")
|
||||
g.Assert(netrc.Password).Equal("")
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -39,7 +39,7 @@ const (
|
||||
|
||||
// parseHook parses a GitHub hook from an http.Request request and returns
|
||||
// Repo and Build detail. If a hook type is unsupported nil values are returned.
|
||||
func parseHook(r *http.Request, merge, privateMode bool) (*github.PullRequest, *model.Repo, *model.Build, error) {
|
||||
func parseHook(r *http.Request, merge bool) (*github.PullRequest, *model.Repo, *model.Build, error) {
|
||||
var reader io.Reader = r.Body
|
||||
|
||||
if payload := r.FormValue(hookField); payload != "" {
|
||||
@ -61,10 +61,10 @@ func parseHook(r *http.Request, merge, privateMode bool) (*github.PullRequest, *
|
||||
repo, build, err := parsePushHook(hook)
|
||||
return nil, repo, build, err
|
||||
case *github.DeploymentEvent:
|
||||
repo, build, err := parseDeployHook(hook, privateMode)
|
||||
repo, build, err := parseDeployHook(hook)
|
||||
return nil, repo, build, err
|
||||
case *github.PullRequestEvent:
|
||||
return parsePullHook(hook, merge, privateMode)
|
||||
return parsePullHook(hook, merge)
|
||||
}
|
||||
return nil, nil, nil, nil
|
||||
}
|
||||
@ -114,7 +114,7 @@ func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Build, error) {
|
||||
|
||||
// parseDeployHook parses a deployment and returns the Repo and Build details.
|
||||
// If the commit type is unsupported nil values are returned.
|
||||
func parseDeployHook(hook *github.DeploymentEvent, privateMode bool) (*model.Repo, *model.Build, error) {
|
||||
func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Build, error) {
|
||||
build := &model.Build{
|
||||
Event: model.EventDeploy,
|
||||
Commit: hook.GetDeployment().GetSHA(),
|
||||
@ -140,12 +140,12 @@ func parseDeployHook(hook *github.DeploymentEvent, privateMode bool) (*model.Rep
|
||||
build.Ref = fmt.Sprintf("refs/heads/%s", build.Branch)
|
||||
}
|
||||
|
||||
return convertRepo(hook.GetRepo(), privateMode), build, nil
|
||||
return convertRepo(hook.GetRepo()), build, nil
|
||||
}
|
||||
|
||||
// parsePullHook parses a pull request hook and returns the Repo and Build
|
||||
// details. If the pull request is closed nil values are returned.
|
||||
func parsePullHook(hook *github.PullRequestEvent, merge, privateMode bool) (*github.PullRequest, *model.Repo, *model.Build, error) {
|
||||
func parsePullHook(hook *github.PullRequestEvent, merge bool) (*github.PullRequest, *model.Repo, *model.Build, error) {
|
||||
// only listen to new merge-requests and pushes to open ones
|
||||
if hook.GetAction() != actionOpen && hook.GetAction() != actionSync {
|
||||
return nil, nil, nil, nil
|
||||
@ -175,7 +175,7 @@ func parsePullHook(hook *github.PullRequestEvent, merge, privateMode bool) (*git
|
||||
build.Ref = fmt.Sprintf(mergeRefs, hook.GetPullRequest().GetNumber())
|
||||
}
|
||||
|
||||
return hook.GetPullRequest(), convertRepo(hook.GetRepo(), privateMode), build, nil
|
||||
return hook.GetPullRequest(), convertRepo(hook.GetRepo()), build, nil
|
||||
}
|
||||
|
||||
func getChangedFilesFromCommits(commits []*github.HeadCommit) []string {
|
||||
|
@ -46,7 +46,7 @@ func Test_parser(t *testing.T) {
|
||||
g.Describe("GitHub parser", func() {
|
||||
g.It("should ignore unsupported hook events", func() {
|
||||
req := testHookRequest([]byte(fixtures.HookPullRequest), "issues")
|
||||
p, r, b, err := parseHook(req, false, false)
|
||||
p, r, b, err := parseHook(req, false)
|
||||
g.Assert(r).IsNil()
|
||||
g.Assert(b).IsNil()
|
||||
g.Assert(err).IsNil()
|
||||
@ -56,7 +56,7 @@ func Test_parser(t *testing.T) {
|
||||
g.Describe("given a push hook", func() {
|
||||
g.It("should skip when action is deleted", func() {
|
||||
req := testHookRequest([]byte(fixtures.HookPushDeleted), hookPush)
|
||||
p, r, b, err := parseHook(req, false, false)
|
||||
p, r, b, err := parseHook(req, false)
|
||||
g.Assert(r).IsNil()
|
||||
g.Assert(b).IsNil()
|
||||
g.Assert(err).IsNil()
|
||||
@ -64,7 +64,7 @@ func Test_parser(t *testing.T) {
|
||||
})
|
||||
g.It("should extract repository and build details", func() {
|
||||
req := testHookRequest([]byte(fixtures.HookPush), hookPush)
|
||||
p, r, b, err := parseHook(req, false, false)
|
||||
p, r, b, err := parseHook(req, false)
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(p).IsNil()
|
||||
g.Assert(r).IsNotNil()
|
||||
@ -78,7 +78,7 @@ func Test_parser(t *testing.T) {
|
||||
g.Describe("given a pull request hook", func() {
|
||||
g.It("should skip when action is not open or sync", func() {
|
||||
req := testHookRequest([]byte(fixtures.HookPullRequestInvalidAction), hookPull)
|
||||
p, r, b, err := parseHook(req, false, false)
|
||||
p, r, b, err := parseHook(req, false)
|
||||
g.Assert(r).IsNil()
|
||||
g.Assert(b).IsNil()
|
||||
g.Assert(err).IsNil()
|
||||
@ -86,7 +86,7 @@ func Test_parser(t *testing.T) {
|
||||
})
|
||||
g.It("should skip when state is not open", func() {
|
||||
req := testHookRequest([]byte(fixtures.HookPullRequestInvalidState), hookPull)
|
||||
p, r, b, err := parseHook(req, false, false)
|
||||
p, r, b, err := parseHook(req, false)
|
||||
g.Assert(r).IsNil()
|
||||
g.Assert(b).IsNil()
|
||||
g.Assert(err).IsNil()
|
||||
@ -94,7 +94,7 @@ func Test_parser(t *testing.T) {
|
||||
})
|
||||
g.It("should extract repository and build details", func() {
|
||||
req := testHookRequest([]byte(fixtures.HookPullRequest), hookPull)
|
||||
p, r, b, err := parseHook(req, false, false)
|
||||
p, r, b, err := parseHook(req, false)
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(r).IsNotNil()
|
||||
g.Assert(b).IsNotNil()
|
||||
@ -106,7 +106,7 @@ func Test_parser(t *testing.T) {
|
||||
g.Describe("given a deployment hook", func() {
|
||||
g.It("should extract repository and build details", func() {
|
||||
req := testHookRequest([]byte(fixtures.HookDeploy), hookDeploy)
|
||||
p, r, b, err := parseHook(req, false, false)
|
||||
p, r, b, err := parseHook(req, false)
|
||||
g.Assert(err).IsNil()
|
||||
g.Assert(r).IsNotNil()
|
||||
g.Assert(b).IsNotNil()
|
||||
|
@ -37,14 +37,15 @@ func (g *Gitlab) convertGitlabRepo(_repo *gitlab.Project) (*model.Repo, error) {
|
||||
owner := strings.Join(parts[:len(parts)-1], "/")
|
||||
name := parts[len(parts)-1]
|
||||
repo := &model.Repo{
|
||||
Owner: owner,
|
||||
Name: name,
|
||||
FullName: _repo.PathWithNamespace,
|
||||
Avatar: _repo.AvatarURL,
|
||||
Link: _repo.WebURL,
|
||||
Clone: _repo.HTTPURLToRepo,
|
||||
Branch: _repo.DefaultBranch,
|
||||
Visibility: model.RepoVisibly(_repo.Visibility),
|
||||
Owner: owner,
|
||||
Name: name,
|
||||
FullName: _repo.PathWithNamespace,
|
||||
Avatar: _repo.AvatarURL,
|
||||
Link: _repo.WebURL,
|
||||
Clone: _repo.HTTPURLToRepo,
|
||||
Branch: _repo.DefaultBranch,
|
||||
Visibility: model.RepoVisibly(_repo.Visibility),
|
||||
IsSCMPrivate: !_repo.Public,
|
||||
}
|
||||
|
||||
if len(repo.Branch) == 0 { // TODO: do we need that?
|
||||
@ -55,12 +56,6 @@ func (g *Gitlab) convertGitlabRepo(_repo *gitlab.Project) (*model.Repo, error) {
|
||||
repo.Avatar = fmt.Sprintf("%s/%s", g.URL, repo.Avatar)
|
||||
}
|
||||
|
||||
if g.PrivateMode {
|
||||
repo.IsSCMPrivate = true
|
||||
} else {
|
||||
repo.IsSCMPrivate = !_repo.Public
|
||||
}
|
||||
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,6 @@ type Opts struct {
|
||||
URL string // Gitlab server url.
|
||||
ClientID string // Oauth2 client id.
|
||||
ClientSecret string // Oauth2 client secret.
|
||||
Username string // Optional machine account username.
|
||||
Password string // Optional machine account password.
|
||||
PrivateMode bool // Gogs is running in private mode.
|
||||
SkipVerify bool // Skip ssl verification.
|
||||
}
|
||||
|
||||
@ -58,9 +55,6 @@ type Gitlab struct {
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
Machine string
|
||||
Username string
|
||||
Password string
|
||||
PrivateMode bool
|
||||
SkipVerify bool
|
||||
HideArchives bool
|
||||
Search bool
|
||||
@ -82,9 +76,6 @@ func New(opts Opts) (remote.Remote, error) {
|
||||
ClientID: opts.ClientID,
|
||||
ClientSecret: opts.ClientSecret,
|
||||
Machine: u.Host,
|
||||
Username: opts.Username,
|
||||
Password: opts.Password,
|
||||
PrivateMode: opts.PrivateMode,
|
||||
SkipVerify: opts.SkipVerify,
|
||||
}, nil
|
||||
}
|
||||
@ -387,16 +378,17 @@ func (g *Gitlab) Status(ctx context.Context, user *model.User, repo *model.Repo,
|
||||
// cloning Gitlab repositories. The netrc will use the global machine account
|
||||
// when configured.
|
||||
func (g *Gitlab) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
||||
if g.Password != "" {
|
||||
return &model.Netrc{
|
||||
Login: g.Username,
|
||||
Password: g.Password,
|
||||
Machine: g.Machine,
|
||||
}, nil
|
||||
login := ""
|
||||
token := ""
|
||||
|
||||
if u != nil {
|
||||
login = "oauth2"
|
||||
token = u.Token
|
||||
}
|
||||
|
||||
return &model.Netrc{
|
||||
Login: "oauth2",
|
||||
Password: u.Token,
|
||||
Login: login,
|
||||
Password: token,
|
||||
Machine: g.Machine,
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user