Lint code with gofumpt (#664)

This commit is contained in:
6543 2022-01-06 07:44:14 +01:00 committed by GitHub
parent eb51f19f3d
commit acbde30c3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 27 deletions

View file

@ -3,6 +3,9 @@ linters-settings:
simplify: true simplify: true
misspell: misspell:
locale: US locale: US
gofumpt:
lang-version: "1.16"
extra-rules: true
linters: linters:
disable-all: true disable-all: true
@ -23,6 +26,7 @@ linters:
- unused - unused
- varcheck - varcheck
- whitespace - whitespace
- gofumpt
run: run:
timeout: 5m timeout: 5m

View file

@ -32,8 +32,10 @@ import (
) )
// TODO: make it set system wide via environment variables // TODO: make it set system wide via environment variables
const defaultTimeout = 60 // 1 hour default build time const (
const maxTimeout = defaultTimeout * 2 defaultTimeout int64 = 60 // 1 hour default build time
maxTimeout int64 = defaultTimeout * 2
)
func PostRepo(c *gin.Context) { func PostRepo(c *gin.Context) {
remote := server.Config.Services.Remote remote := server.Config.Services.Remote

View file

@ -23,103 +23,86 @@ import (
// TODO: CreateX func should return new object to not indirect let storage change an existing object (alter ID etc...) // TODO: CreateX func should return new object to not indirect let storage change an existing object (alter ID etc...)
type Store interface { type Store interface {
// Users
// GetUser gets a user by unique ID. // GetUser gets a user by unique ID.
GetUser(int64) (*model.User, error) GetUser(int64) (*model.User, error)
// GetUserLogin gets a user by unique Login name. // GetUserLogin gets a user by unique Login name.
GetUserLogin(string) (*model.User, error) GetUserLogin(string) (*model.User, error)
// GetUserList gets a list of all users in the system. // GetUserList gets a list of all users in the system.
// TODO: paginate // TODO: paginate
GetUserList() ([]*model.User, error) GetUserList() ([]*model.User, error)
// GetUserCount gets a count of all users in the system. // GetUserCount gets a count of all users in the system.
GetUserCount() (int64, error) GetUserCount() (int64, error)
// CreateUser creates a new user account. // CreateUser creates a new user account.
CreateUser(*model.User) error CreateUser(*model.User) error
// UpdateUser updates a user account. // UpdateUser updates a user account.
UpdateUser(*model.User) error UpdateUser(*model.User) error
// DeleteUser deletes a user account. // DeleteUser deletes a user account.
DeleteUser(*model.User) error DeleteUser(*model.User) error
// Repos
// GetRepo gets a repo by unique ID. // GetRepo gets a repo by unique ID.
GetRepo(int64) (*model.Repo, error) GetRepo(int64) (*model.Repo, error)
// GetRepoName gets a repo by its full name. // GetRepoName gets a repo by its full name.
GetRepoName(string) (*model.Repo, error) GetRepoName(string) (*model.Repo, error)
// GetRepoCount gets a count of all repositories in the system. // GetRepoCount gets a count of all repositories in the system.
GetRepoCount() (int64, error) GetRepoCount() (int64, error)
// CreateRepo creates a new repository. // CreateRepo creates a new repository.
CreateRepo(*model.Repo) error CreateRepo(*model.Repo) error
// UpdateRepo updates a user repository. // UpdateRepo updates a user repository.
UpdateRepo(*model.Repo) error UpdateRepo(*model.Repo) error
// DeleteRepo deletes a user repository. // DeleteRepo deletes a user repository.
DeleteRepo(*model.Repo) error DeleteRepo(*model.Repo) error
// Builds
// GetBuild gets a build by unique ID. // GetBuild gets a build by unique ID.
GetBuild(int64) (*model.Build, error) GetBuild(int64) (*model.Build, error)
// GetBuildNumber gets a build by number. // GetBuildNumber gets a build by number.
GetBuildNumber(*model.Repo, int64) (*model.Build, error) GetBuildNumber(*model.Repo, int64) (*model.Build, error)
// GetBuildRef gets a build by its ref. // GetBuildRef gets a build by its ref.
GetBuildRef(*model.Repo, string) (*model.Build, error) GetBuildRef(*model.Repo, string) (*model.Build, error)
// GetBuildCommit gets a build by its commit sha. // GetBuildCommit gets a build by its commit sha.
GetBuildCommit(*model.Repo, string, string) (*model.Build, error) GetBuildCommit(*model.Repo, string, string) (*model.Build, error)
// GetBuildLast gets the last build for the branch. // GetBuildLast gets the last build for the branch.
GetBuildLast(*model.Repo, string) (*model.Build, error) GetBuildLast(*model.Repo, string) (*model.Build, error)
// GetBuildLastBefore gets the last build before build number N. // GetBuildLastBefore gets the last build before build number N.
GetBuildLastBefore(*model.Repo, string, int64) (*model.Build, error) GetBuildLastBefore(*model.Repo, string, int64) (*model.Build, error)
// GetBuildList gets a list of builds for the repository // GetBuildList gets a list of builds for the repository
// TODO: paginate // TODO: paginate
GetBuildList(*model.Repo, int) ([]*model.Build, error) GetBuildList(*model.Repo, int) ([]*model.Build, error)
// GetBuildQueue gets a list of build in queue. // GetBuildQueue gets a list of build in queue.
GetBuildQueue() ([]*model.Feed, error) GetBuildQueue() ([]*model.Feed, error)
// GetBuildCount gets a count of all builds in the system. // GetBuildCount gets a count of all builds in the system.
GetBuildCount() (int64, error) GetBuildCount() (int64, error)
// CreateBuild creates a new build and jobs. // CreateBuild creates a new build and jobs.
CreateBuild(*model.Build, ...*model.Proc) error CreateBuild(*model.Build, ...*model.Proc) error
// UpdateBuild updates a build. // UpdateBuild updates a build.
UpdateBuild(*model.Build) error UpdateBuild(*model.Build) error
// // Feeds
// new functions
//
UserFeed(*model.User) ([]*model.Feed, error) UserFeed(*model.User) ([]*model.Feed, error)
// Repositorys
// RepoList TODO: paginate // RepoList TODO: paginate
RepoList(user *model.User, owned bool) ([]*model.Repo, error) RepoList(user *model.User, owned bool) ([]*model.Repo, error)
RepoListLatest(*model.User) ([]*model.Feed, error) RepoListLatest(*model.User) ([]*model.Feed, error)
// RepoBatch Sync batch of repos from SCM (with permissions) to store (create if not exist else update) // RepoBatch Sync batch of repos from SCM (with permissions) to store (create if not exist else update)
RepoBatch([]*model.Repo) error RepoBatch([]*model.Repo) error
// Permissions
PermFind(user *model.User, repo *model.Repo) (*model.Perm, error) PermFind(user *model.User, repo *model.Repo) (*model.Perm, error)
PermUpsert(perm *model.Perm) error PermUpsert(perm *model.Perm) error
PermDelete(perm *model.Perm) error PermDelete(perm *model.Perm) error
PermFlush(user *model.User, before int64) error PermFlush(user *model.User, before int64) error
// Configs
ConfigsForBuild(buildID int64) ([]*model.Config, error) ConfigsForBuild(buildID int64) ([]*model.Config, error)
ConfigFindIdentical(repoID int64, hash string) (*model.Config, error) ConfigFindIdentical(repoID int64, hash string) (*model.Config, error)
ConfigFindApproved(*model.Config) (bool, error) ConfigFindApproved(*model.Config) (bool, error)
ConfigCreate(*model.Config) error ConfigCreate(*model.Config) error
BuildConfigCreate(*model.BuildConfig) error BuildConfigCreate(*model.BuildConfig) error
// Sender
SenderFind(*model.Repo, string) (*model.Sender, error) SenderFind(*model.Repo, string) (*model.Sender, error)
// SenderList TODO: paginate // SenderList TODO: paginate
SenderList(*model.Repo) ([]*model.Sender, error) SenderList(*model.Repo) ([]*model.Sender, error)
@ -127,18 +110,21 @@ type Store interface {
SenderUpdate(*model.Sender) error SenderUpdate(*model.Sender) error
SenderDelete(*model.Sender) error SenderDelete(*model.Sender) error
// Secrets
SecretFind(*model.Repo, string) (*model.Secret, error) SecretFind(*model.Repo, string) (*model.Secret, error)
SecretList(*model.Repo) ([]*model.Secret, error) SecretList(*model.Repo) ([]*model.Secret, error)
SecretCreate(*model.Secret) error SecretCreate(*model.Secret) error
SecretUpdate(*model.Secret) error SecretUpdate(*model.Secret) error
SecretDelete(*model.Secret) error SecretDelete(*model.Secret) error
// Registrys
RegistryFind(*model.Repo, string) (*model.Registry, error) RegistryFind(*model.Repo, string) (*model.Registry, error)
RegistryList(*model.Repo) ([]*model.Registry, error) RegistryList(*model.Repo) ([]*model.Registry, error)
RegistryCreate(*model.Registry) error RegistryCreate(*model.Registry) error
RegistryUpdate(*model.Registry) error RegistryUpdate(*model.Registry) error
RegistryDelete(repo *model.Repo, addr string) error RegistryDelete(repo *model.Repo, addr string) error
// Procs
ProcLoad(int64) (*model.Proc, error) ProcLoad(int64) (*model.Proc, error)
ProcFind(*model.Build, int) (*model.Proc, error) ProcFind(*model.Build, int) (*model.Proc, error)
ProcChild(*model.Build, int, string) (*model.Proc, error) ProcChild(*model.Build, int, string) (*model.Proc, error)
@ -147,21 +133,25 @@ type Store interface {
ProcUpdate(*model.Proc) error ProcUpdate(*model.Proc) error
ProcClear(*model.Build) error ProcClear(*model.Build) error
// Logs
LogFind(*model.Proc) (io.ReadCloser, error) LogFind(*model.Proc) (io.ReadCloser, error)
// TODO: since we do ReadAll in any case a ioReader is not the best idear // TODO: since we do ReadAll in any case a ioReader is not the best idear
// so either find a way to write log in chunks by xorm ... // so either find a way to write log in chunks by xorm ...
LogSave(*model.Proc, io.Reader) error LogSave(*model.Proc, io.Reader) error
// Files
FileList(*model.Build) ([]*model.File, error) FileList(*model.Build) ([]*model.File, error)
FileFind(*model.Proc, string) (*model.File, error) FileFind(*model.Proc, string) (*model.File, error)
FileRead(*model.Proc, string) (io.ReadCloser, error) FileRead(*model.Proc, string) (io.ReadCloser, error)
FileCreate(*model.File, io.Reader) error FileCreate(*model.File, io.Reader) error
// Tasks
// TaskList TODO: paginate & opt filter // TaskList TODO: paginate & opt filter
TaskList() ([]*model.Task, error) TaskList() ([]*model.Task, error)
TaskInsert(*model.Task) error TaskInsert(*model.Task) error
TaskDelete(string) error TaskDelete(string) error
// Store operations
Ping() error Ping() error
Close() error Close() error
Migrate() error Migrate() error