Fix linter (#1647)

This commit is contained in:
Anbraten 2023-03-18 20:35:27 +01:00 committed by GitHub
parent af2ef30205
commit fa5b0fb96e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 180 additions and 280 deletions

View file

@ -46,15 +46,16 @@ func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Pipeline, error)
res, err = c.client.Next(ctx, req) res, err = c.client.Next(ctx, req)
if err == nil { if err == nil {
break break
} else {
// TODO: remove after adding continuous data exchange by something like #536
if strings.Contains(err.Error(), "\"too_many_pings\"") {
// https://github.com/woodpecker-ci/woodpecker/issues/717#issuecomment-1049365104
log.Trace().Err(err).Msg("grpc: to many keepalive pings without sending data")
} else {
log.Err(err).Msgf("grpc error: done(): code: %v: %s", status.Code(err), err)
}
} }
// TODO: remove after adding continuous data exchange by something like #536
if strings.Contains(err.Error(), "\"too_many_pings\"") {
// https://github.com/woodpecker-ci/woodpecker/issues/717#issuecomment-1049365104
log.Trace().Err(err).Msg("grpc: to many keepalive pings without sending data")
} else {
log.Err(err).Msgf("grpc error: done(): code: %v: %s", status.Code(err), err)
}
switch status.Code(err) { switch status.Code(err) {
case case
codes.Aborted, codes.Aborted,
@ -94,9 +95,10 @@ func (c *client) Wait(ctx context.Context, id string) (err error) {
_, err = c.client.Wait(ctx, req) _, err = c.client.Wait(ctx, req)
if err == nil { if err == nil {
break break
} else {
log.Err(err).Msgf("grpc error: wait(): code: %v: %s", status.Code(err), err)
} }
log.Err(err).Msgf("grpc error: wait(): code: %v: %s", status.Code(err), err)
switch status.Code(err) { switch status.Code(err) {
case case
codes.Aborted, codes.Aborted,
@ -128,9 +130,10 @@ func (c *client) Init(ctx context.Context, id string, state rpc.State) (err erro
_, err = c.client.Init(ctx, req) _, err = c.client.Init(ctx, req)
if err == nil { if err == nil {
break break
} else {
log.Err(err).Msgf("grpc error: init(): code: %v: %s", status.Code(err), err)
} }
log.Err(err).Msgf("grpc error: init(): code: %v: %s", status.Code(err), err)
switch status.Code(err) { switch status.Code(err) {
case case
codes.Aborted, codes.Aborted,
@ -162,9 +165,10 @@ func (c *client) Done(ctx context.Context, id string, state rpc.State) (err erro
_, err = c.client.Done(ctx, req) _, err = c.client.Done(ctx, req)
if err == nil { if err == nil {
break break
} else {
log.Err(err).Msgf("grpc error: done(): code: %v: %s", status.Code(err), err)
} }
log.Err(err).Msgf("grpc error: done(): code: %v: %s", status.Code(err), err)
switch status.Code(err) { switch status.Code(err) {
case case
codes.Aborted, codes.Aborted,
@ -189,9 +193,10 @@ func (c *client) Extend(ctx context.Context, id string) (err error) {
_, err = c.client.Extend(ctx, req) _, err = c.client.Extend(ctx, req)
if err == nil { if err == nil {
break break
} else {
log.Err(err).Msgf("grpc error: extend(): code: %v: %s", status.Code(err), err)
} }
log.Err(err).Msgf("grpc error: extend(): code: %v: %s", status.Code(err), err)
switch status.Code(err) { switch status.Code(err) {
case case
codes.Aborted, codes.Aborted,
@ -223,9 +228,10 @@ func (c *client) Update(ctx context.Context, id string, state rpc.State) (err er
_, err = c.client.Update(ctx, req) _, err = c.client.Update(ctx, req)
if err == nil { if err == nil {
break break
} else {
log.Err(err).Msgf("grpc error: update(): code: %v: %s", status.Code(err), err)
} }
log.Err(err).Msgf("grpc error: update(): code: %v: %s", status.Code(err), err)
switch status.Code(err) { switch status.Code(err) {
case case
codes.Aborted, codes.Aborted,
@ -258,9 +264,10 @@ func (c *client) Upload(ctx context.Context, id string, file *rpc.File) (err err
_, err = c.client.Upload(ctx, req) _, err = c.client.Upload(ctx, req)
if err == nil { if err == nil {
break break
} else {
log.Err(err).Msgf("grpc error: upload(): code: %v: %s", status.Code(err), err)
} }
log.Err(err).Msgf("grpc error: upload(): code: %v: %s", status.Code(err), err)
switch status.Code(err) { switch status.Code(err) {
case case
codes.Aborted, codes.Aborted,
@ -290,9 +297,10 @@ func (c *client) Log(ctx context.Context, id string, line *rpc.Line) (err error)
_, err = c.client.Log(ctx, req) _, err = c.client.Log(ctx, req)
if err == nil { if err == nil {
break break
} else {
log.Err(err).Msgf("grpc error: log(): code: %v: %s", status.Code(err), err)
} }
log.Err(err).Msgf("grpc error: log(): code: %v: %s", status.Code(err), err)
switch status.Code(err) { switch status.Code(err) {
case case
codes.Aborted, codes.Aborted,

View file

@ -84,9 +84,5 @@ func pipelineCreate(c *cli.Context) error {
return err return err
} }
if err := tmpl.Execute(os.Stdout, pipeline); err != nil { return tmpl.Execute(os.Stdout, pipeline)
return err
}
return nil
} }

View file

@ -37,7 +37,7 @@ func init() {
http.HandleFunc("/version", handleVersion) http.HandleFunc("/version", handleVersion)
} }
func handleHeartbeat(w http.ResponseWriter, r *http.Request) { func handleHeartbeat(w http.ResponseWriter, _ *http.Request) {
if counter.Healthy() { if counter.Healthy() {
w.WriteHeader(200) w.WriteHeader(200)
} else { } else {
@ -45,7 +45,7 @@ func handleHeartbeat(w http.ResponseWriter, r *http.Request) {
} }
} }
func handleVersion(w http.ResponseWriter, r *http.Request) { func handleVersion(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(200) w.WriteHeader(200)
w.Header().Add("Content-Type", "text/json") w.Header().Add("Content-Type", "text/json")
_ = json.NewEncoder(w).Encode(versionResp{ _ = json.NewEncoder(w).Encode(versionResp{
@ -54,7 +54,7 @@ func handleVersion(w http.ResponseWriter, r *http.Request) {
}) })
} }
func handleStats(w http.ResponseWriter, r *http.Request) { func handleStats(w http.ResponseWriter, _ *http.Request) {
if counter.Healthy() { if counter.Healthy() {
w.WriteHeader(200) w.WriteHeader(200)
} else { } else {

View file

@ -71,10 +71,10 @@ func setupStore(c *cli.Context) (store.Store, error) {
} }
if driver == "sqlite3" { if driver == "sqlite3" {
if new, err := fallbackSqlite3File(datasource); err != nil { if newDatasource, err := fallbackSqlite3File(datasource); err != nil {
log.Fatal().Err(err).Msg("fallback to old sqlite3 file failed") log.Fatal().Err(err).Msg("fallback to old sqlite3 file failed")
} else { } else {
datasource = new datasource = newDatasource
} }
} }
@ -178,7 +178,7 @@ func setupRegistryService(c *cli.Context, s store.Store) model.RegistryService {
return registry.New(s) return registry.New(s)
} }
func setupEnvironService(c *cli.Context, s store.Store) model.EnvironService { func setupEnvironService(c *cli.Context, _ store.Store) model.EnvironService {
return environments.Parse(c.StringSlice("environment")) return environments.Parse(c.StringSlice("environment"))
} }

View file

@ -78,8 +78,7 @@ func TestSplitVolumeParts(t *testing.T) {
} }
for _, test := range testdata { for _, test := range testdata {
results, err := splitVolumeParts(test.from) results, err := splitVolumeParts(test.from)
if test.success == (err != nil) { if test.success != (err == nil) {
} else {
if reflect.DeepEqual(results, test.to) != test.success { if reflect.DeepEqual(results, test.to) != test.success {
t.Errorf("Expect %q matches %q is %v", test.from, results, test.to) t.Errorf("Expect %q matches %q is %v", test.from, results, test.to)
} }

View file

@ -70,7 +70,7 @@ func (e *local) Load() error {
} }
// Setup the pipeline environment. // Setup the pipeline environment.
func (e *local) Setup(ctx context.Context, config *types.Config) error { func (e *local) Setup(_ context.Context, _ *types.Config) error {
return nil return nil
} }

View file

@ -84,7 +84,7 @@ func (e *ssh) Load() error {
} }
// Setup the pipeline environment. // Setup the pipeline environment.
func (e *ssh) Setup(ctx context.Context, config *types.Config) error { func (e *ssh) Setup(_ context.Context, _ *types.Config) error {
return nil return nil
} }

View file

@ -18,49 +18,49 @@ package pipeline
// layer. Main purpose is to be compatible with drone plugins. // layer. Main purpose is to be compatible with drone plugins.
func SetDroneEnviron(env map[string]string) { func SetDroneEnviron(env map[string]string) {
// webhook // webhook
copy("CI_COMMIT_BRANCH", "DRONE_BRANCH", env) copyEnv("CI_COMMIT_BRANCH", "DRONE_BRANCH", env)
copy("CI_COMMIT_PULL_REQUEST", "DRONE_PULL_REQUEST", env) copyEnv("CI_COMMIT_PULL_REQUEST", "DRONE_PULL_REQUEST", env)
copy("CI_COMMIT_TAG", "DRONE_TAG", env) copyEnv("CI_COMMIT_TAG", "DRONE_TAG", env)
copy("CI_COMMIT_SOURCE_BRANCH", "DRONE_SOURCE_BRANCH", env) copyEnv("CI_COMMIT_SOURCE_BRANCH", "DRONE_SOURCE_BRANCH", env)
copy("CI_COMMIT_TARGET_BRANCH", "DRONE_TARGET_BRANCH", env) copyEnv("CI_COMMIT_TARGET_BRANCH", "DRONE_TARGET_BRANCH", env)
// pipeline // pipeline
copy("CI_PIPELINE_NUMBER", "DRONE_BUILD_NUMBER", env) copyEnv("CI_PIPELINE_NUMBER", "DRONE_BUILD_NUMBER", env)
copy("CI_PIPELINE_PARENT", "DRONE_BUILD_PARENT", env) copyEnv("CI_PIPELINE_PARENT", "DRONE_BUILD_PARENT", env)
copy("CI_PIPELINE_EVENT", "DRONE_BUILD_EVENT", env) copyEnv("CI_PIPELINE_EVENT", "DRONE_BUILD_EVENT", env)
copy("CI_PIPELINE_STATUS", "DRONE_BUILD_STATUS", env) copyEnv("CI_PIPELINE_STATUS", "DRONE_BUILD_STATUS", env)
copy("CI_PIPELINE_LINK", "DRONE_BUILD_LINK", env) copyEnv("CI_PIPELINE_LINK", "DRONE_BUILD_LINK", env)
copy("CI_PIPELINE_CREATED", "DRONE_BUILD_CREATED", env) copyEnv("CI_PIPELINE_CREATED", "DRONE_BUILD_CREATED", env)
copy("CI_PIPELINE_STARTED", "DRONE_BUILD_STARTED", env) copyEnv("CI_PIPELINE_STARTED", "DRONE_BUILD_STARTED", env)
copy("CI_PIPELINE_FINISHED", "DRONE_BUILD_FINISHED", env) copyEnv("CI_PIPELINE_FINISHED", "DRONE_BUILD_FINISHED", env)
// commit // commit
copy("CI_COMMIT_SHA", "DRONE_COMMIT", env) copyEnv("CI_COMMIT_SHA", "DRONE_COMMIT", env)
copy("CI_COMMIT_SHA", "DRONE_COMMIT_SHA", env) copyEnv("CI_COMMIT_SHA", "DRONE_COMMIT_SHA", env)
copy("CI_PREV_COMMIT_SHA", "DRONE_COMMIT_BEFORE", env) copyEnv("CI_PREV_COMMIT_SHA", "DRONE_COMMIT_BEFORE", env)
copy("CI_COMMIT_REF", "DRONE_COMMIT_REF", env) copyEnv("CI_COMMIT_REF", "DRONE_COMMIT_REF", env)
copy("CI_COMMIT_BRANCH", "DRONE_COMMIT_BRANCH", env) copyEnv("CI_COMMIT_BRANCH", "DRONE_COMMIT_BRANCH", env)
copy("CI_COMMIT_LINK", "DRONE_COMMIT_LINK", env) copyEnv("CI_COMMIT_LINK", "DRONE_COMMIT_LINK", env)
copy("CI_COMMIT_MESSAGE", "DRONE_COMMIT_MESSAGE", env) copyEnv("CI_COMMIT_MESSAGE", "DRONE_COMMIT_MESSAGE", env)
copy("CI_COMMIT_AUTHOR", "DRONE_COMMIT_AUTHOR", env) copyEnv("CI_COMMIT_AUTHOR", "DRONE_COMMIT_AUTHOR", env)
copy("CI_COMMIT_AUTHOR", "DRONE_COMMIT_AUTHOR_NAME", env) copyEnv("CI_COMMIT_AUTHOR", "DRONE_COMMIT_AUTHOR_NAME", env)
copy("CI_COMMIT_AUTHOR_EMAIL", "DRONE_COMMIT_AUTHOR_EMAIL", env) copyEnv("CI_COMMIT_AUTHOR_EMAIL", "DRONE_COMMIT_AUTHOR_EMAIL", env)
copy("CI_COMMIT_AUTHOR_AVATAR", "DRONE_COMMIT_AUTHOR_AVATAR", env) copyEnv("CI_COMMIT_AUTHOR_AVATAR", "DRONE_COMMIT_AUTHOR_AVATAR", env)
// repo // repo
copy("CI_REPO", "DRONE_REPO", env) copyEnv("CI_REPO", "DRONE_REPO", env)
copy("CI_REPO_SCM", "DRONE_REPO_SCM", env) copyEnv("CI_REPO_SCM", "DRONE_REPO_SCM", env)
copy("CI_REPO_OWNER", "DRONE_REPO_OWNER", env) copyEnv("CI_REPO_OWNER", "DRONE_REPO_OWNER", env)
copy("CI_REPO_NAME", "DRONE_REPO_NAME", env) copyEnv("CI_REPO_NAME", "DRONE_REPO_NAME", env)
copy("CI_REPO_LINK", "DRONE_REPO_LINK", env) copyEnv("CI_REPO_LINK", "DRONE_REPO_LINK", env)
copy("CI_REPO_DEFAULT_BRANCH", "DRONE_REPO_BRANCH", env) copyEnv("CI_REPO_DEFAULT_BRANCH", "DRONE_REPO_BRANCH", env)
copy("CI_REPO_PRIVATE", "DRONE_REPO_PRIVATE", env) copyEnv("CI_REPO_PRIVATE", "DRONE_REPO_PRIVATE", env)
// clone // clone
copy("CI_REPO_CLONE_URL", "DRONE_REMOTE_URL", env) copyEnv("CI_REPO_CLONE_URL", "DRONE_REMOTE_URL", env)
copy("CI_REPO_CLONE_URL", "DRONE_GIT_HTTP_URL", env) copyEnv("CI_REPO_CLONE_URL", "DRONE_GIT_HTTP_URL", env)
// misc // misc
copy("CI_SYSTEM_HOST", "DRONE_SYSTEM_HOST", env) copyEnv("CI_SYSTEM_HOST", "DRONE_SYSTEM_HOST", env)
copy("CI_STEP_NUMBER", "DRONE_STEP_NUMBER", env) copyEnv("CI_STEP_NUMBER", "DRONE_STEP_NUMBER", env)
} }
func copy(woodpecker, drone string, env map[string]string) { func copyEnv(woodpecker, drone string, env map[string]string) {
var present bool var present bool
var value string var value string

View file

@ -72,7 +72,7 @@ type s3Cacher struct {
region string region string
} }
func (c *s3Cacher) Restore(repo, branch string, mounts []string) *yaml.Container { func (c *s3Cacher) Restore(_, _ string, mounts []string) *yaml.Container {
return &yaml.Container{ return &yaml.Container{
Name: "rebuild_cache", Name: "rebuild_cache",
Image: "plugins/s3-cache:latest", Image: "plugins/s3-cache:latest",
@ -87,7 +87,7 @@ func (c *s3Cacher) Restore(repo, branch string, mounts []string) *yaml.Container
} }
} }
func (c *s3Cacher) Rebuild(repo, branch string, mounts []string) *yaml.Container { func (c *s3Cacher) Rebuild(_, _ string, mounts []string) *yaml.Container {
return &yaml.Container{ return &yaml.Container{
Name: "rebuild_cache", Name: "rebuild_cache",
Image: "plugins/s3-cache:latest", Image: "plugins/s3-cache:latest",

View file

@ -37,13 +37,10 @@ func (l *Linter) Lint(c *yaml.Config) error {
if err := l.lint(c.Pipeline.Containers, blockPipeline); err != nil { if err := l.lint(c.Pipeline.Containers, blockPipeline); err != nil {
return err return err
} }
if err := l.lint(c.Services.Containers, blockServices); err != nil { return l.lint(c.Services.Containers, blockServices)
return err
}
return nil
} }
func (l *Linter) lint(containers []*yaml.Container, block uint8) error { func (l *Linter) lint(containers []*yaml.Container, _ uint8) error {
for _, container := range containers { for _, container := range containers {
if err := l.lintImage(container); err != nil { if err := l.lintImage(container); err != nil {
return err return err

View file

@ -223,12 +223,12 @@ func (c *config) File(ctx context.Context, u *model.User, r *model.Repo, p *mode
return []byte(*config), err return []byte(*config), err
} }
func (c *config) Dir(ctx context.Context, u *model.User, r *model.Repo, p *model.Pipeline, f string) ([]*forge_types.FileMeta, error) { func (c *config) Dir(_ context.Context, _ *model.User, _ *model.Repo, _ *model.Pipeline, _ string) ([]*forge_types.FileMeta, error) {
return nil, forge_types.ErrNotImplemented return nil, forge_types.ErrNotImplemented
} }
// Status creates a pipeline status for the Bitbucket commit. // Status creates a pipeline status for the Bitbucket commit.
func (c *config) Status(ctx context.Context, user *model.User, repo *model.Repo, pipeline *model.Pipeline, step *model.Step) error { func (c *config) Status(ctx context.Context, user *model.User, repo *model.Repo, pipeline *model.Pipeline, _ *model.Step) error {
status := internal.PipelineStatus{ status := internal.PipelineStatus{
State: convertStatus(pipeline.Status), State: convertStatus(pipeline.Status),
Desc: common.GetPipelineStatusDescription(pipeline.Status), Desc: common.GetPipelineStatusDescription(pipeline.Status),
@ -274,7 +274,7 @@ func (c *config) Deactivate(ctx context.Context, u *model.User, r *model.Repo, l
// Netrc returns a netrc file capable of authenticating Bitbucket requests and // Netrc returns a netrc file capable of authenticating Bitbucket requests and
// cloning Bitbucket repositories. // cloning Bitbucket repositories.
func (c *config) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) { func (c *config) Netrc(u *model.User, _ *model.Repo) (*model.Netrc, error) {
return &model.Netrc{ return &model.Netrc{
Machine: "bitbucket.org", Machine: "bitbucket.org",
Login: "x-token-auth", Login: "x-token-auth",
@ -297,14 +297,14 @@ func (c *config) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]
} }
// BranchHead returns the sha of the head (latest commit) of the specified branch // BranchHead returns the sha of the head (latest commit) of the specified branch
func (c *config) BranchHead(ctx context.Context, u *model.User, r *model.Repo, branch string) (string, error) { func (c *config) BranchHead(_ context.Context, _ *model.User, _ *model.Repo, _ string) (string, error) {
// TODO(1138): missing implementation // TODO(1138): missing implementation
return "", forge_types.ErrNotImplemented return "", forge_types.ErrNotImplemented
} }
// Hook parses the incoming Bitbucket hook and returns the Repository and // Hook parses the incoming Bitbucket hook and returns the Repository and
// Pipeline details. If the hook is unsupported nil values are returned. // Pipeline details. If the hook is unsupported nil values are returned.
func (c *config) Hook(ctx context.Context, req *http.Request) (*model.Repo, *model.Pipeline, error) { func (c *config) Hook(_ context.Context, req *http.Request) (*model.Repo, *model.Pipeline, error) {
return parseHook(req) return parseHook(req)
} }

View file

@ -138,18 +138,18 @@ func (c *Config) Login(ctx context.Context, res http.ResponseWriter, req *http.R
} }
// Auth is not supported by the Stash driver. // Auth is not supported by the Stash driver.
func (*Config) Auth(ctx context.Context, token, secret string) (string, error) { func (*Config) Auth(_ context.Context, _, _ string) (string, error) {
return "", fmt.Errorf("Not Implemented") return "", fmt.Errorf("Not Implemented")
} }
// Teams is not supported by the Stash driver. // Teams is not supported by the Stash driver.
func (*Config) Teams(ctx context.Context, u *model.User) ([]*model.Team, error) { func (*Config) Teams(_ context.Context, _ *model.User) ([]*model.Team, error) {
var teams []*model.Team var teams []*model.Team
return teams, nil return teams, nil
} }
// TeamPerm is not supported by the Stash driver. // TeamPerm is not supported by the Stash driver.
func (*Config) TeamPerm(u *model.User, org string) (*model.Perm, error) { func (*Config) TeamPerm(_ *model.User, _ string) (*model.Perm, error) {
return nil, nil return nil, nil
} }
@ -186,12 +186,12 @@ func (c *Config) File(ctx context.Context, u *model.User, r *model.Repo, p *mode
return client.FindFileForRepo(r.Owner, r.Name, f, p.Ref) return client.FindFileForRepo(r.Owner, r.Name, f, p.Ref)
} }
func (c *Config) Dir(ctx context.Context, u *model.User, r *model.Repo, p *model.Pipeline, f string) ([]*forge_types.FileMeta, error) { func (c *Config) Dir(_ context.Context, _ *model.User, _ *model.Repo, _ *model.Pipeline, _ string) ([]*forge_types.FileMeta, error) {
return nil, forge_types.ErrNotImplemented return nil, forge_types.ErrNotImplemented
} }
// Status is not supported by the bitbucketserver driver. // Status is not supported by the bitbucketserver driver.
func (c *Config) Status(ctx context.Context, user *model.User, repo *model.Repo, pipeline *model.Pipeline, step *model.Step) error { func (c *Config) Status(ctx context.Context, user *model.User, repo *model.Repo, pipeline *model.Pipeline, _ *model.Step) error {
status := internal.PipelineStatus{ status := internal.PipelineStatus{
State: convertStatus(pipeline.Status), State: convertStatus(pipeline.Status),
Desc: common.GetPipelineStatusDescription(pipeline.Status), Desc: common.GetPipelineStatusDescription(pipeline.Status),
@ -205,7 +205,7 @@ func (c *Config) Status(ctx context.Context, user *model.User, repo *model.Repo,
return client.CreateStatus(pipeline.Commit, &status) return client.CreateStatus(pipeline.Commit, &status)
} }
func (c *Config) Netrc(user *model.User, r *model.Repo) (*model.Netrc, error) { func (c *Config) Netrc(_ *model.User, r *model.Repo) (*model.Netrc, error) {
host, err := common.ExtractHostFromCloneURL(r.Clone) host, err := common.ExtractHostFromCloneURL(r.Clone)
if err != nil { if err != nil {
return nil, err return nil, err
@ -239,7 +239,7 @@ func (c *Config) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]
} }
// BranchHead returns the sha of the head (latest commit) of the specified branch // BranchHead returns the sha of the head (latest commit) of the specified branch
func (c *Config) BranchHead(ctx context.Context, u *model.User, r *model.Repo, branch string) (string, error) { func (c *Config) BranchHead(_ context.Context, _ *model.User, _ *model.Repo, _ string) (string, error) {
// TODO(1138): missing implementation // TODO(1138): missing implementation
return "", forge_types.ErrNotImplemented return "", forge_types.ErrNotImplemented
} }
@ -249,13 +249,13 @@ func (c *Config) Deactivate(ctx context.Context, u *model.User, r *model.Repo, l
return client.DeleteHook(r.Owner, r.Name, link) return client.DeleteHook(r.Owner, r.Name, link)
} }
func (c *Config) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model.Pipeline, error) { func (c *Config) Hook(_ context.Context, r *http.Request) (*model.Repo, *model.Pipeline, error) {
return parseHook(r, c.URL) return parseHook(r, c.URL)
} }
// OrgMembership returns if user is member of organization and if user // OrgMembership returns if user is member of organization and if user
// is admin/owner in this organization. // is admin/owner in this organization.
func (c *Config) OrgMembership(ctx context.Context, u *model.User, owner string) (*model.OrgPerm, error) { func (c *Config) OrgMembership(_ context.Context, _ *model.User, _ string) (*model.OrgPerm, error) {
// TODO: Not implemented currently // TODO: Not implemented currently
return nil, nil return nil, nil
} }

View file

@ -124,7 +124,7 @@ func (c *Coding) Login(ctx context.Context, res http.ResponseWriter, req *http.R
// Auth authenticates the session and returns the forge user // Auth authenticates the session and returns the forge user
// login for the given token and secret // login for the given token and secret
func (c *Coding) Auth(ctx context.Context, token, secret string) (string, error) { func (c *Coding) Auth(ctx context.Context, token, _ string) (string, error) {
user, err := c.newClientToken(ctx, token).GetCurrentUser() user, err := c.newClientToken(ctx, token).GetCurrentUser()
if err != nil { if err != nil {
return "", err return "", err
@ -150,14 +150,14 @@ func (c *Coding) Refresh(ctx context.Context, u *model.User) (bool, error) {
} }
// Teams fetches a list of team memberships from the forge. // Teams fetches a list of team memberships from the forge.
func (c *Coding) Teams(ctx context.Context, u *model.User) ([]*model.Team, error) { func (c *Coding) Teams(_ context.Context, _ *model.User) ([]*model.Team, error) {
// EMPTY: not implemented in Coding OAuth API // EMPTY: not implemented in Coding OAuth API
return nil, forge_types.ErrNotImplemented return nil, forge_types.ErrNotImplemented
} }
// TeamPerm fetches the named organization permissions from // TeamPerm fetches the named organization permissions from
// the forge for the specified user. // the forge for the specified user.
func (c *Coding) TeamPerm(u *model.User, org string) (*model.Perm, error) { func (c *Coding) TeamPerm(_ *model.User, _ string) (*model.Perm, error) {
// EMPTY: not implemented in Coding OAuth API // EMPTY: not implemented in Coding OAuth API
return nil, nil return nil, nil
} }
@ -245,12 +245,12 @@ func (c *Coding) File(ctx context.Context, u *model.User, r *model.Repo, b *mode
return data, nil return data, nil
} }
func (c *Coding) Dir(ctx context.Context, u *model.User, r *model.Repo, b *model.Pipeline, f string) ([]*forge_types.FileMeta, error) { func (c *Coding) Dir(_ context.Context, _ *model.User, _ *model.Repo, _ *model.Pipeline, _ string) ([]*forge_types.FileMeta, error) {
return nil, forge_types.ErrNotImplemented return nil, forge_types.ErrNotImplemented
} }
// Status sends the commit status to the forge. // Status sends the commit status to the forge.
func (c *Coding) Status(ctx context.Context, u *model.User, r *model.Repo, b *model.Pipeline, step *model.Step) error { func (c *Coding) Status(_ context.Context, _ *model.User, _ *model.Repo, _ *model.Pipeline, _ *model.Step) error {
// EMPTY: not implemented in Coding OAuth API // EMPTY: not implemented in Coding OAuth API
return nil return nil
} }
@ -290,20 +290,20 @@ func (c *Coding) Deactivate(ctx context.Context, u *model.User, r *model.Repo, l
} }
// Branches returns the names of all branches for the named repository. // Branches returns the names of all branches for the named repository.
func (c *Coding) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]string, error) { func (c *Coding) Branches(_ context.Context, _ *model.User, r *model.Repo) ([]string, error) {
// TODO: fetch all branches // TODO: fetch all branches
return []string{r.Branch}, nil return []string{r.Branch}, nil
} }
// BranchHead returns the sha of the head (latest commit) of the specified branch // BranchHead returns the sha of the head (latest commit) of the specified branch
func (c *Coding) BranchHead(ctx context.Context, u *model.User, r *model.Repo, branch string) (string, error) { func (c *Coding) BranchHead(_ context.Context, _ *model.User, _ *model.Repo, _ string) (string, error) {
// TODO(1138): missing implementation // TODO(1138): missing implementation
return "", forge_types.ErrNotImplemented return "", forge_types.ErrNotImplemented
} }
// Hook parses the post-commit hook from the Request body and returns the // Hook parses the post-commit hook from the Request body and returns the
// required data in a standard format. // required data in a standard format.
func (c *Coding) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model.Pipeline, error) { func (c *Coding) Hook(_ context.Context, r *http.Request) (*model.Repo, *model.Pipeline, error) {
repo, pipeline, err := parseHook(r) repo, pipeline, err := parseHook(r)
if pipeline != nil { if pipeline != nil {
pipeline.Avatar = c.resourceLink(pipeline.Avatar) pipeline.Avatar = c.resourceLink(pipeline.Avatar)
@ -313,7 +313,7 @@ func (c *Coding) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model
// OrgMembership returns if user is member of organization and if user // OrgMembership returns if user is member of organization and if user
// is admin/owner in this organization. // is admin/owner in this organization.
func (c *Coding) OrgMembership(ctx context.Context, u *model.User, owner string) (*model.OrgPerm, error) { func (c *Coding) OrgMembership(_ context.Context, _ *model.User, _ string) (*model.OrgPerm, error) {
// TODO: Not supported in Coding OAuth API // TODO: Not supported in Coding OAuth API
return nil, nil return nil, nil
} }

View file

@ -153,7 +153,7 @@ func (c *Gitea) Login(ctx context.Context, w http.ResponseWriter, req *http.Requ
// Auth uses the Gitea oauth2 access token and refresh token to authenticate // Auth uses the Gitea oauth2 access token and refresh token to authenticate
// a session and return the Gitea account login. // a session and return the Gitea account login.
func (c *Gitea) Auth(ctx context.Context, token, secret string) (string, error) { func (c *Gitea) Auth(ctx context.Context, token, _ string) (string, error) {
client, err := c.newClientToken(ctx, token) client, err := c.newClientToken(ctx, token)
if err != nil { if err != nil {
return "", err return "", err
@ -213,7 +213,7 @@ func (c *Gitea) Teams(ctx context.Context, u *model.User) ([]*model.Team, error)
} }
// TeamPerm is not supported by the Gitea driver. // TeamPerm is not supported by the Gitea driver.
func (c *Gitea) TeamPerm(u *model.User, org string) (*model.Perm, error) { func (c *Gitea) TeamPerm(_ *model.User, _ string) (*model.Perm, error) {
return nil, nil return nil, nil
} }

View file

@ -137,7 +137,7 @@ func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.R
} }
// Auth returns the GitHub user login for the given access token. // Auth returns the GitHub user login for the given access token.
func (c *client) Auth(ctx context.Context, token, secret string) (string, error) { func (c *client) Auth(ctx context.Context, token, _ string) (string, error) {
client := c.newClientToken(ctx, token) client := c.newClientToken(ctx, token)
user, _, err := client.Users.Get(ctx, "") user, _, err := client.Users.Get(ctx, "")
if err != nil { if err != nil {

View file

@ -76,7 +76,7 @@ func (c *client) Name() string {
// Login authenticates an account with Gogs using basic authentication. The // Login authenticates an account with Gogs using basic authentication. The
// Gogs account details are returned when the user is successfully authenticated. // Gogs account details are returned when the user is successfully authenticated.
func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) { func (c *client) Login(_ context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
var ( var (
username = req.FormValue("username") username = req.FormValue("username")
password = req.FormValue("password") password = req.FormValue("password")
@ -130,12 +130,12 @@ func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.R
} }
// Auth is not supported by the Gogs driver. // Auth is not supported by the Gogs driver.
func (c *client) Auth(ctx context.Context, token, secret string) (string, error) { func (c *client) Auth(_ context.Context, _, _ string) (string, error) {
return "", fmt.Errorf("Not Implemented") return "", fmt.Errorf("Not Implemented")
} }
// Teams is not supported by the Gogs driver. // Teams is not supported by the Gogs driver.
func (c *client) Teams(ctx context.Context, u *model.User) ([]*model.Team, error) { func (c *client) Teams(_ context.Context, u *model.User) ([]*model.Team, error) {
client := c.newClientToken(u.Token) client := c.newClientToken(u.Token)
orgs, err := client.ListMyOrgs() orgs, err := client.ListMyOrgs()
if err != nil { if err != nil {
@ -150,7 +150,7 @@ func (c *client) Teams(ctx context.Context, u *model.User) ([]*model.Team, error
} }
// Repo returns the named Gogs repository. // Repo returns the named Gogs repository.
func (c *client) Repo(ctx context.Context, u *model.User, _ model.ForgeRemoteID, owner, name string) (*model.Repo, error) { func (c *client) Repo(_ context.Context, u *model.User, _ model.ForgeRemoteID, owner, name string) (*model.Repo, error) {
client := c.newClientToken(u.Token) client := c.newClientToken(u.Token)
repo, err := client.GetRepo(owner, name) repo, err := client.GetRepo(owner, name)
if err != nil { if err != nil {
@ -161,7 +161,7 @@ func (c *client) Repo(ctx context.Context, u *model.User, _ model.ForgeRemoteID,
// Repos returns a list of all repositories for the Gogs account, including // Repos returns a list of all repositories for the Gogs account, including
// organization repositories. // organization repositories.
func (c *client) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error) { func (c *client) Repos(_ context.Context, u *model.User) ([]*model.Repo, error) {
var repos []*model.Repo var repos []*model.Repo
client := c.newClientToken(u.Token) client := c.newClientToken(u.Token)
@ -177,7 +177,7 @@ func (c *client) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error
} }
// Perm returns the user permissions for the named Gogs repository. // Perm returns the user permissions for the named Gogs repository.
func (c *client) Perm(ctx context.Context, u *model.User, r *model.Repo) (*model.Perm, error) { func (c *client) Perm(_ context.Context, u *model.User, r *model.Repo) (*model.Perm, error) {
client := c.newClientToken(u.Token) client := c.newClientToken(u.Token)
repo, err := client.GetRepo(r.Owner, r.Name) repo, err := client.GetRepo(r.Owner, r.Name)
if err != nil { if err != nil {
@ -187,7 +187,7 @@ func (c *client) Perm(ctx context.Context, u *model.User, r *model.Repo) (*model
} }
// File fetches the file from the Gogs repository and returns its contents. // File fetches the file from the Gogs repository and returns its contents.
func (c *client) File(ctx context.Context, u *model.User, r *model.Repo, b *model.Pipeline, f string) ([]byte, error) { func (c *client) File(_ context.Context, u *model.User, r *model.Repo, b *model.Pipeline, f string) ([]byte, error) {
client := c.newClientToken(u.Token) client := c.newClientToken(u.Token)
ref := b.Commit ref := b.Commit
@ -210,12 +210,12 @@ func (c *client) File(ctx context.Context, u *model.User, r *model.Repo, b *mode
return cfg, err return cfg, err
} }
func (c *client) Dir(ctx context.Context, u *model.User, r *model.Repo, b *model.Pipeline, f string) ([]*forge_types.FileMeta, error) { func (c *client) Dir(_ context.Context, _ *model.User, _ *model.Repo, _ *model.Pipeline, _ string) ([]*forge_types.FileMeta, error) {
return nil, forge_types.ErrNotImplemented return nil, forge_types.ErrNotImplemented
} }
// Status is not supported by the Gogs driver. // Status is not supported by the Gogs driver.
func (c *client) Status(ctx context.Context, u *model.User, r *model.Repo, b *model.Pipeline, step *model.Step) error { func (c *client) Status(_ context.Context, _ *model.User, _ *model.Repo, _ *model.Pipeline, _ *model.Step) error {
return nil return nil
} }
@ -244,7 +244,7 @@ func (c *client) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
// Activate activates the repository by registering post-commit hooks with // Activate activates the repository by registering post-commit hooks with
// the Gogs repository. // the Gogs repository.
func (c *client) Activate(ctx context.Context, u *model.User, r *model.Repo, link string) error { func (c *client) Activate(_ context.Context, u *model.User, r *model.Repo, link string) error {
config := map[string]string{ config := map[string]string{
"url": link, "url": link,
"secret": r.Hash, "secret": r.Hash,
@ -263,12 +263,12 @@ func (c *client) Activate(ctx context.Context, u *model.User, r *model.Repo, lin
} }
// Deactivate is not supported by the Gogs driver. // Deactivate is not supported by the Gogs driver.
func (c *client) Deactivate(ctx context.Context, u *model.User, r *model.Repo, link string) error { func (c *client) Deactivate(_ context.Context, _ *model.User, _ *model.Repo, _ string) error {
return nil return nil
} }
// Branches returns the names of all branches for the named repository. // Branches returns the names of all branches for the named repository.
func (c *client) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]string, error) { func (c *client) Branches(_ context.Context, u *model.User, r *model.Repo) ([]string, error) {
token := "" token := ""
if u != nil { if u != nil {
token = u.Token token = u.Token
@ -287,7 +287,7 @@ func (c *client) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]
} }
// BranchHead returns sha of commit on top of the specified branch // BranchHead returns sha of commit on top of the specified branch
func (c *client) BranchHead(ctx context.Context, u *model.User, r *model.Repo, branch string) (string, error) { func (c *client) BranchHead(_ context.Context, u *model.User, r *model.Repo, branch string) (string, error) {
token := "" token := ""
if u != nil { if u != nil {
token = u.Token token = u.Token
@ -301,13 +301,13 @@ func (c *client) BranchHead(ctx context.Context, u *model.User, r *model.Repo, b
// Hook parses the incoming Gogs hook and returns the Repository and Pipeline // Hook parses the incoming Gogs hook and returns the Repository and Pipeline
// details. If the hook is unsupported nil values are returned. // details. If the hook is unsupported nil values are returned.
func (c *client) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model.Pipeline, error) { func (c *client) Hook(_ context.Context, r *http.Request) (*model.Repo, *model.Pipeline, error) {
return parseHook(r, c.PrivateMode) return parseHook(r, c.PrivateMode)
} }
// OrgMembership returns if user is member of organization and if user // OrgMembership returns if user is member of organization and if user
// is admin/owner in this organization. // is admin/owner in this organization.
func (c *client) OrgMembership(ctx context.Context, u *model.User, owner string) (*model.OrgPerm, error) { func (c *client) OrgMembership(_ context.Context, u *model.User, owner string) (*model.OrgPerm, error) {
client := c.newClientToken(u.Token) client := c.newClientToken(u.Token)
orgs, err := client.ListMyOrgs() orgs, err := client.ListMyOrgs()

View file

@ -22,8 +22,8 @@ func NewWoodpeckerAuthServer(jwtManager *JWTManager, agentMasterToken string, st
return &WoodpeckerAuthServer{jwtManager: jwtManager, agentMasterToken: agentMasterToken, store: store} return &WoodpeckerAuthServer{jwtManager: jwtManager, agentMasterToken: agentMasterToken, store: store}
} }
func (s *WoodpeckerAuthServer) Auth(c context.Context, req *proto.AuthRequest) (*proto.AuthReply, error) { func (s *WoodpeckerAuthServer) Auth(_ context.Context, req *proto.AuthRequest) (*proto.AuthReply, error) {
agent, err := s.getAgent(c, req.AgentId, req.AgentToken) agent, err := s.getAgent(req.AgentId, req.AgentToken)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -40,7 +40,7 @@ func (s *WoodpeckerAuthServer) Auth(c context.Context, req *proto.AuthRequest) (
}, nil }, nil
} }
func (s *WoodpeckerAuthServer) getAgent(c context.Context, agentID int64, agentToken string) (*model.Agent, error) { func (s *WoodpeckerAuthServer) getAgent(agentID int64, agentToken string) (*model.Agent, error) {
if agentToken == s.agentMasterToken && agentID == -1 { if agentToken == s.agentMasterToken && agentID == -1 {
agent := new(model.Agent) agent := new(model.Agent)
agent.Name = "" agent.Name = ""

View file

@ -174,7 +174,7 @@ func (s *RPC) Update(c context.Context, id string, state rpc.State) error {
} }
// Upload implements the rpc.Upload function // Upload implements the rpc.Upload function
func (s *RPC) Upload(c context.Context, id string, file *rpc.File) error { func (s *RPC) Upload(_ context.Context, id string, file *rpc.File) error {
stepID, err := strconv.ParseInt(id, 10, 64) stepID, err := strconv.ParseInt(id, 10, 64)
if err != nil { if err != nil {
return err return err

View file

@ -46,7 +46,7 @@ func New() Log {
} }
} }
func (l *log) Open(c context.Context, path string) error { func (l *log) Open(_ context.Context, path string) error {
l.Lock() l.Lock()
_, ok := l.streams[path] _, ok := l.streams[path]
if !ok { if !ok {
@ -60,7 +60,7 @@ func (l *log) Open(c context.Context, path string) error {
return nil return nil
} }
func (l *log) Write(c context.Context, path string, entry *Entry) error { func (l *log) Write(_ context.Context, path string, entry *Entry) error {
l.Lock() l.Lock()
s, ok := l.streams[path] s, ok := l.streams[path]
l.Unlock() l.Unlock()
@ -105,7 +105,7 @@ func (l *log) Tail(c context.Context, path string, handler Handler) error {
return nil return nil
} }
func (l *log) Close(c context.Context, path string) error { func (l *log) Close(_ context.Context, path string) error {
l.Lock() l.Lock()
s, ok := l.streams[path] s, ok := l.streams[path]
l.Unlock() l.Unlock()
@ -123,7 +123,7 @@ func (l *log) Close(c context.Context, path string) error {
return nil return nil
} }
func (l *log) Snapshot(c context.Context, path string, w io.Writer) error { func (l *log) Snapshot(_ context.Context, path string, w io.Writer) error {
l.Lock() l.Lock()
s, ok := l.streams[path] s, ok := l.streams[path]
l.Unlock() l.Unlock()

View file

@ -28,7 +28,7 @@ import (
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
) )
func createPipelineItems(ctx context.Context, store store.Store, func createPipelineItems(_ context.Context, store store.Store,
currentPipeline *model.Pipeline, user *model.User, repo *model.Repo, currentPipeline *model.Pipeline, user *model.User, repo *model.Repo,
yamls []*forge_types.FileMeta, envs map[string]string, yamls []*forge_types.FileMeta, envs map[string]string,
) (*model.Pipeline, []*pipeline.Item, error) { ) (*model.Pipeline, []*pipeline.Item, error) {

View file

@ -25,7 +25,7 @@ import (
type mockUpdatePipelineStore struct{} type mockUpdatePipelineStore struct{}
func (m *mockUpdatePipelineStore) UpdatePipeline(pipeline *model.Pipeline) error { func (m *mockUpdatePipelineStore) UpdatePipeline(_ *model.Pipeline) error {
return nil return nil
} }

View file

@ -26,7 +26,7 @@ import (
"github.com/woodpecker-ci/woodpecker/server/queue" "github.com/woodpecker-ci/woodpecker/server/queue"
) )
func queueBuild(pipeline *model.Pipeline, repo *model.Repo, pipelineItems []*pipeline.Item) error { func queuePipeline(repo *model.Repo, pipelineItems []*pipeline.Item) error {
var tasks []*queue.Task var tasks []*queue.Task
for _, item := range pipelineItems { for _, item := range pipelineItems {
if item.Step.State == model.StatusSkipped { if item.Step.State == model.StatusSkipped {

View file

@ -128,13 +128,13 @@ func persistPipelineConfigs(store store.Store, configs []*model.Config, pipeline
} }
func createNewOutOfOld(old *model.Pipeline) *model.Pipeline { func createNewOutOfOld(old *model.Pipeline) *model.Pipeline {
new := *old newPipeline := *old
new.ID = 0 newPipeline.ID = 0
new.Number = 0 newPipeline.Number = 0
new.Status = model.StatusPending newPipeline.Status = model.StatusPending
new.Started = 0 newPipeline.Started = 0
new.Finished = 0 newPipeline.Finished = 0
new.Enqueued = time.Now().UTC().Unix() newPipeline.Enqueued = time.Now().UTC().Unix()
new.Error = "" newPipeline.Error = ""
return &new return &newPipeline
} }

View file

@ -41,8 +41,8 @@ func start(ctx context.Context, store store.Store, activePipeline *model.Pipelin
log.Error().Err(err).Msg("publishToTopic") log.Error().Err(err).Msg("publishToTopic")
} }
if err := queueBuild(activePipeline, repo, pipelineItems); err != nil { if err := queuePipeline(repo, pipelineItems); err != nil {
log.Error().Err(err).Msg("queueBuild") log.Error().Err(err).Msg("queuePipeline")
return nil, err return nil, err
} }

View file

@ -25,7 +25,7 @@ import (
type mockUpdateStepStore struct{} type mockUpdateStepStore struct{}
func (m *mockUpdateStepStore) StepUpdate(build *model.Step) error { func (m *mockUpdateStepStore) StepUpdate(_ *model.Step) error {
return nil return nil
} }

View file

@ -28,6 +28,6 @@ func Parse(params []string) model.EnvironService {
return &builtin{globals} return &builtin{globals}
} }
func (b *builtin) EnvironList(repo *model.Repo) ([]*model.Environ, error) { func (b *builtin) EnvironList(_ *model.Repo) ([]*model.Environ, error) {
return b.globals, nil return b.globals, nil
} }

View file

@ -21,11 +21,11 @@ func (b *db) RegistryList(repo *model.Repo) ([]*model.Registry, error) {
return b.store.RegistryList(repo) return b.store.RegistryList(repo)
} }
func (b *db) RegistryCreate(repo *model.Repo, in *model.Registry) error { func (b *db) RegistryCreate(_ *model.Repo, in *model.Registry) error {
return b.store.RegistryCreate(in) return b.store.RegistryCreate(in)
} }
func (b *db) RegistryUpdate(repo *model.Repo, in *model.Registry) error { func (b *db) RegistryUpdate(_ *model.Repo, in *model.Registry) error {
return b.store.RegistryUpdate(in) return b.store.RegistryUpdate(in)
} }

View file

@ -38,7 +38,7 @@ func (b *builtin) SecretList(repo *model.Repo) ([]*model.Secret, error) {
return b.store.SecretList(repo, false) return b.store.SecretList(repo, false)
} }
func (b *builtin) SecretListPipeline(repo *model.Repo, pipeline *model.Pipeline) ([]*model.Secret, error) { func (b *builtin) SecretListPipeline(repo *model.Repo, _ *model.Pipeline) ([]*model.Secret, error) {
s, err := b.store.SecretList(repo, true) s, err := b.store.SecretList(repo, true)
if err != nil { if err != nil {
return nil, err return nil, err
@ -70,11 +70,11 @@ func (b *builtin) SecretListPipeline(repo *model.Repo, pipeline *model.Pipeline)
return secrets, nil return secrets, nil
} }
func (b *builtin) SecretCreate(repo *model.Repo, in *model.Secret) error { func (b *builtin) SecretCreate(_ *model.Repo, in *model.Secret) error {
return b.store.SecretCreate(in) return b.store.SecretCreate(in)
} }
func (b *builtin) SecretUpdate(repo *model.Repo, in *model.Secret) error { func (b *builtin) SecretUpdate(_ *model.Repo, in *model.Secret) error {
return b.store.SecretUpdate(in) return b.store.SecretUpdate(in)
} }
@ -94,11 +94,11 @@ func (b *builtin) OrgSecretList(owner string) ([]*model.Secret, error) {
return b.store.OrgSecretList(owner) return b.store.OrgSecretList(owner)
} }
func (b *builtin) OrgSecretCreate(owner string, in *model.Secret) error { func (b *builtin) OrgSecretCreate(_ string, in *model.Secret) error {
return b.store.SecretCreate(in) return b.store.SecretCreate(in)
} }
func (b *builtin) OrgSecretUpdate(owner string, in *model.Secret) error { func (b *builtin) OrgSecretUpdate(_ string, in *model.Secret) error {
return b.store.SecretUpdate(in) return b.store.SecretUpdate(in)
} }

View file

@ -22,7 +22,7 @@ func New() Publisher {
} }
} }
func (p *publisher) Create(c context.Context, dest string) error { func (p *publisher) Create(_ context.Context, dest string) error {
p.Lock() p.Lock()
_, ok := p.topics[dest] _, ok := p.topics[dest]
if !ok { if !ok {
@ -33,7 +33,7 @@ func (p *publisher) Create(c context.Context, dest string) error {
return nil return nil
} }
func (p *publisher) Publish(c context.Context, dest string, message Message) error { func (p *publisher) Publish(_ context.Context, dest string, message Message) error {
p.Lock() p.Lock()
t, ok := p.topics[dest] t, ok := p.topics[dest]
p.Unlock() p.Unlock()
@ -63,7 +63,7 @@ func (p *publisher) Subscribe(c context.Context, dest string, receiver Receiver)
return nil return nil
} }
func (p *publisher) Remove(c context.Context, dest string) error { func (p *publisher) Remove(_ context.Context, dest string) error {
p.Lock() p.Lock()
t, ok := p.topics[dest] t, ok := p.topics[dest]
if ok { if ok {

View file

@ -56,7 +56,7 @@ type fifo struct {
} }
// New returns a new fifo queue. // New returns a new fifo queue.
func New(ctx context.Context) Queue { func New(_ context.Context) Queue {
return &fifo{ return &fifo{
workers: map[*worker]struct{}{}, workers: map[*worker]struct{}{},
running: map[string]*entry{}, running: map[string]*entry{},
@ -68,7 +68,7 @@ func New(ctx context.Context) Queue {
} }
// Push pushes an item to the tail of this queue. // Push pushes an item to the tail of this queue.
func (q *fifo) Push(c context.Context, task *Task) error { func (q *fifo) Push(_ context.Context, task *Task) error {
q.Lock() q.Lock()
q.pending.PushBack(task) q.pending.PushBack(task)
q.Unlock() q.Unlock()
@ -77,7 +77,7 @@ func (q *fifo) Push(c context.Context, task *Task) error {
} }
// Push pushes an item to the tail of this queue. // Push pushes an item to the tail of this queue.
func (q *fifo) PushAtOnce(c context.Context, tasks []*Task) error { func (q *fifo) PushAtOnce(_ context.Context, tasks []*Task) error {
q.Lock() q.Lock()
for _, task := range tasks { for _, task := range tasks {
q.pending.PushBack(task) q.pending.PushBack(task)
@ -112,17 +112,17 @@ func (q *fifo) Poll(c context.Context, f FilterFn) (*Task, error) {
} }
// Done signals that the item is done executing. // Done signals that the item is done executing.
func (q *fifo) Done(c context.Context, id string, exitStatus model.StatusValue) error { func (q *fifo) Done(_ context.Context, id string, exitStatus model.StatusValue) error {
return q.finished([]string{id}, string(exitStatus), nil) return q.finished([]string{id}, string(exitStatus), nil)
} }
// Error signals that the item is done executing with error. // Error signals that the item is done executing with error.
func (q *fifo) Error(c context.Context, id string, err error) error { func (q *fifo) Error(_ context.Context, id string, err error) error {
return q.finished([]string{id}, StatusFailure, err) return q.finished([]string{id}, StatusFailure, err)
} }
// Error signals that the item is done executing with error. // Error signals that the item is done executing with error.
func (q *fifo) ErrorAtOnce(c context.Context, id []string, err error) error { func (q *fifo) ErrorAtOnce(_ context.Context, id []string, err error) error {
return q.finished(id, StatusFailure, err) return q.finished(id, StatusFailure, err)
} }
@ -151,7 +151,7 @@ func (q *fifo) Evict(c context.Context, id string) error {
} }
// Evict removes a pending task from the queue. // Evict removes a pending task from the queue.
func (q *fifo) EvictAtOnce(c context.Context, ids []string) error { func (q *fifo) EvictAtOnce(_ context.Context, ids []string) error {
q.Lock() q.Lock()
defer q.Unlock() defer q.Unlock()
@ -185,7 +185,7 @@ func (q *fifo) Wait(c context.Context, id string) error {
} }
// Extend extends the task execution deadline. // Extend extends the task execution deadline.
func (q *fifo) Extend(c context.Context, id string) error { func (q *fifo) Extend(_ context.Context, id string) error {
q.Lock() q.Lock()
defer q.Unlock() defer q.Unlock()
@ -198,7 +198,7 @@ func (q *fifo) Extend(c context.Context, id string) error {
} }
// Info returns internal queue information. // Info returns internal queue information.
func (q *fifo) Info(c context.Context) InfoT { func (q *fifo) Info(_ context.Context) InfoT {
q.Lock() q.Lock()
stats := InfoT{} stats := InfoT{}
stats.Stats.Workers = len(q.workers) stats.Stats.Workers = len(q.workers)

View file

@ -23,7 +23,7 @@ import (
// Store is a middleware function that initializes the Datastore and attaches to // Store is a middleware function that initializes the Datastore and attaches to
// the context of every http.Request. // the context of every http.Request.
func Store(cli *cli.Context, v store.Store) gin.HandlerFunc { func Store(_ *cli.Context, v store.Store) gin.HandlerFunc {
return func(c *gin.Context) { return func(c *gin.Context) {
store.ToContext(c, v) store.ToContext(c, v)
c.Next() c.Next()

View file

@ -41,7 +41,7 @@ func (s storage) CronList(repo *model.Repo) ([]*model.Cron, error) {
return crons, s.engine.Where("repo_id = ?", repo.ID).Find(&crons) return crons, s.engine.Where("repo_id = ?", repo.ID).Find(&crons)
} }
func (s storage) CronUpdate(repo *model.Repo, cron *model.Cron) error { func (s storage) CronUpdate(_ *model.Repo, cron *model.Cron) error {
_, err := s.engine.ID(cron.ID).AllCols().Update(cron) _, err := s.engine.ID(cron.ID).AllCols().Update(cron)
return err return err
} }

View file

@ -39,10 +39,7 @@ var renameRemoteToForge = task{
if err := sess.Sync2(new(oldRepo012)); err != nil { if err := sess.Sync2(new(oldRepo012)); err != nil {
return err return err
} }
if err := renameColumn(sess, "repos", "remote_id", "forge_id"); err != nil {
return err
}
return nil return renameColumn(sess, "repos", "remote_id", "forge_id")
}, },
} }

View file

@ -22,10 +22,6 @@ var renameForgeIDToForgeRemoteID = task{
name: "rename-forge-id-to-forge-remote-id", name: "rename-forge-id-to-forge-remote-id",
required: true, required: true,
fn: func(sess *xorm.Session) error { fn: func(sess *xorm.Session) error {
if err := renameColumn(sess, "repos", "forge_id", "forge_remote_id"); err != nil { return renameColumn(sess, "repos", "forge_id", "forge_remote_id")
return err
}
return nil
}, },
} }

View file

@ -43,16 +43,16 @@ func createSQLiteDB(t *testing.T) string {
return tmpF.Name() return tmpF.Name()
} }
func testDB(t *testing.T, new bool) (engine *xorm.Engine, close func()) { func testDB(t *testing.T, new bool) (engine *xorm.Engine, closeDB func()) {
driver := testDriver() driver := testDriver()
var err error var err error
close = func() {} closeDB = func() {}
switch driver { switch driver {
case "sqlite3": case "sqlite3":
config := ":memory:" config := ":memory:"
if !new { if !new {
config = createSQLiteDB(t) config = createSQLiteDB(t)
close = func() { closeDB = func() {
_ = os.Remove(config) _ = os.Remove(config)
} }
} }
@ -86,9 +86,9 @@ func TestMigrate(t *testing.T) {
} }
// init new db // init new db
engine, close := testDB(t, true) engine, closeDB := testDB(t, true)
assert.NoError(t, Migrate(engine)) assert.NoError(t, Migrate(engine))
close() closeDB()
dbType := engine.Dialect().URI().DBType dbType := engine.Dialect().URI().DBType
if dbType == schemas.MYSQL || dbType == schemas.POSTGRES { if dbType == schemas.MYSQL || dbType == schemas.POSTGRES {
@ -97,7 +97,7 @@ func TestMigrate(t *testing.T) {
} }
// migrate old db // migrate old db
engine, close = testDB(t, false) engine, closeDB = testDB(t, false)
assert.NoError(t, Migrate(engine)) assert.NoError(t, Migrate(engine))
close() closeDB()
} }

View file

@ -1,93 +0,0 @@
// Copyright 2018 Drone.IO Inc.
//
// 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 swagger
import (
"net/http"
"github.com/woodpecker-ci/woodpecker/server/model"
)
// swagger:route GET /users/{login} user getUser
//
// Get the user with the matching login.
//
// Responses:
// 200: user
func userFind(w http.ResponseWriter, r *http.Request) {}
// swagger:route GET /user user getCurrentUser
//
// Get the currently authenticated user.
//
// Responses:
// 200: user
func userCurrent(w http.ResponseWriter, r *http.Request) {}
// swagger:route GET /users user getUserList
//
// Get the list of all registered users.
//
// Responses:
// 200: user
func userList(w http.ResponseWriter, r *http.Request) {}
// swagger:route GET /user/feed user getUserFeed
//
// Get the currently authenticated user's pipeline feed.
//
// Responses:
// 200: feed
func userFeed(w http.ResponseWriter, r *http.Request) {}
// swagger:route DELETE /users/{login} user deleteUserLogin
//
// Delete the user with the matching login.
//
// Responses:
// 200: user
func userDelete(w http.ResponseWriter, r *http.Request) {}
// swagger:route GET /user/repos user getUserRepos
//
// Get the currently authenticated user's active repository list.
//
// Responses:
// 200: repos
func repoList(w http.ResponseWriter, r *http.Request) {}
// swagger:response user
type userResp struct {
// in: body
Body model.User
}
// swagger:response users
type usersResp struct {
// in: body
Body []model.User
}
// swagger:response feed
type feedResp struct {
// in: body
Body []model.Feed
}
// swagger:response repos
type reposResp struct {
// in: body
Body []model.Repo
}

View file

@ -530,9 +530,9 @@ func (c *client) post(rawurl string, in, out interface{}) error {
} }
// helper function for making an http PUT request. // helper function for making an http PUT request.
func (c *client) put(rawurl string, in, out interface{}) error { // func (c *client) put(rawurl string, in, out interface{}) error {
return c.do(rawurl, "PUT", in, out) // return c.do(rawurl, "PUT", in, out)
} // }
// helper function for making an http PATCH request. // helper function for making an http PATCH request.
func (c *client) patch(rawurl string, in, out interface{}) error { func (c *client) patch(rawurl string, in, out interface{}) error {
@ -546,7 +546,7 @@ func (c *client) delete(rawurl string) error {
// helper function to make an http request // helper function to make an http request
func (c *client) do(rawurl, method string, in, out interface{}) error { func (c *client) do(rawurl, method string, in, out interface{}) error {
body, err := c.open(rawurl, method, in, out) body, err := c.open(rawurl, method, in)
if err != nil { if err != nil {
return err return err
} }
@ -558,7 +558,7 @@ func (c *client) do(rawurl, method string, in, out interface{}) error {
} }
// helper function to open an http request // helper function to open an http request
func (c *client) open(rawurl, method string, in, out interface{}) (io.ReadCloser, error) { func (c *client) open(rawurl, method string, in interface{}) (io.ReadCloser, error) {
uri, err := url.Parse(rawurl) uri, err := url.Parse(rawurl)
if err != nil { if err != nil {
return nil, err return nil, err