mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-29 05:11:04 +00:00
Add linter whitespace (#531)
This commit is contained in:
parent
57db3227ab
commit
25bf91bd37
37 changed files with 1 additions and 71 deletions
|
@ -13,6 +13,7 @@ linters:
|
|||
- typecheck
|
||||
- errcheck
|
||||
- bidichk
|
||||
- whitespace
|
||||
|
||||
run:
|
||||
timeout: 5m
|
||||
|
|
|
@ -139,7 +139,6 @@ func (r *Runner) Run(ctx context.Context) error {
|
|||
|
||||
var uploads sync.WaitGroup
|
||||
defaultLogger := pipeline.LogFunc(func(proc *backend.Step, rc multipart.Reader) error {
|
||||
|
||||
loglogger := logger.With().
|
||||
Str("image", proc.Image).
|
||||
Str("stage", proc.Alias).
|
||||
|
|
|
@ -22,7 +22,6 @@ var buildQueueCmd = &cli.Command{
|
|||
}
|
||||
|
||||
func buildQueue(c *cli.Context) error {
|
||||
|
||||
client, err := internal.NewClient(c)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -50,7 +50,6 @@ import (
|
|||
)
|
||||
|
||||
func run(c *cli.Context) error {
|
||||
|
||||
if c.Bool("pretty") {
|
||||
log.Logger = log.Output(
|
||||
zerolog.ConsoleWriter{
|
||||
|
@ -151,7 +150,6 @@ func run(c *cli.Context) error {
|
|||
|
||||
// start the grpc server
|
||||
g.Go(func() error {
|
||||
|
||||
lis, err := net.Listen("tcp", c.String("grpc-addr"))
|
||||
if err != nil {
|
||||
log.Err(err).Msg("")
|
||||
|
@ -252,7 +250,6 @@ func run(c *cli.Context) error {
|
|||
}
|
||||
|
||||
func setupEvilGlobals(c *cli.Context, v store.Store, r remote.Remote) {
|
||||
|
||||
// storage
|
||||
server.Config.Storage.Files = v
|
||||
server.Config.Storage.Config = v
|
||||
|
|
|
@ -161,7 +161,6 @@ func (c *Compiler) Compile(conf *yaml.Config) *backend.Config {
|
|||
name := fmt.Sprintf("%s_services_%d", c.prefix, i)
|
||||
step := c.createProcess(name, container, "services")
|
||||
stage.Steps = append(stage.Steps, step)
|
||||
|
||||
}
|
||||
config.Stages = append(config.Stages, stage)
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ func TestParse(t *testing.T) {
|
|||
|
||||
g.Describe("Parser", func() {
|
||||
g.Describe("Given a yaml file", func() {
|
||||
|
||||
g.It("Should unmarshal a string", func() {
|
||||
out, err := ParseString(sampleYaml)
|
||||
if err != nil {
|
||||
|
|
|
@ -29,7 +29,6 @@ func (a Axis) String() string {
|
|||
|
||||
// Parse parses the Yaml matrix definition.
|
||||
func Parse(data []byte) ([]Axis, error) {
|
||||
|
||||
axis, err := parseList(data)
|
||||
if err == nil && len(axis) != 0 {
|
||||
return axis, nil
|
||||
|
|
|
@ -7,10 +7,8 @@ import (
|
|||
)
|
||||
|
||||
func TestMatrix(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Calculate matrix", func() {
|
||||
|
||||
axis, _ := ParseString(fakeMatrix)
|
||||
|
||||
g.It("Should calculate permutations", func() {
|
||||
|
|
|
@ -12,7 +12,6 @@ func TestBoolTrue(t *testing.T) {
|
|||
|
||||
g.Describe("Yaml bool type", func() {
|
||||
g.Describe("given a yaml file", func() {
|
||||
|
||||
g.It("should unmarshal true", func() {
|
||||
in := []byte("true")
|
||||
out := BoolTrue{}
|
||||
|
|
|
@ -91,7 +91,6 @@ type SliceorMap map[string]string
|
|||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (s *SliceorMap) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
|
||||
var sliceType []interface{}
|
||||
if err := unmarshal(&sliceType); err == nil {
|
||||
parts := map[string]string{}
|
||||
|
|
|
@ -49,7 +49,6 @@ func TestMarshalUlimit(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, ulimit := range ulimits {
|
||||
|
||||
bytes, err := yaml.Marshal(ulimit.ulimits)
|
||||
|
||||
assert.Nil(t, err)
|
||||
|
|
|
@ -71,7 +71,6 @@ func HandleAuth(c *gin.Context) {
|
|||
// get the user from the database
|
||||
u, err := store_.GetUserLogin(tmpuser.Login)
|
||||
if err != nil {
|
||||
|
||||
// if self-registration is disabled we should return a not authorized error
|
||||
if !config.Open && !config.IsAdmin(tmpuser) {
|
||||
log.Error().Msgf("cannot register %s. registration closed", tmpuser.Login)
|
||||
|
|
|
@ -431,7 +431,6 @@ func (s *RPC) updateRemoteStatus(ctx context.Context, repo *model.Repo, build *m
|
|||
if err := s.store.UpdateUser(user); err != nil {
|
||||
log.Error().Err(err).Msg("fail to save user to store after refresh oauth token")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
uri := fmt.Sprintf("%s/%s/%d", server.Config.Server.Host, repo.FullName, build.Number)
|
||||
|
|
|
@ -22,10 +22,8 @@ import (
|
|||
)
|
||||
|
||||
func TestCC(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("CC", func() {
|
||||
|
||||
g.It("Should create a project", func() {
|
||||
now := time.Now().Unix()
|
||||
now_fmt := time.Unix(now, 0).Format(time.RFC3339)
|
||||
|
|
|
@ -21,10 +21,8 @@ import (
|
|||
)
|
||||
|
||||
func TestSecret(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Secret", func() {
|
||||
|
||||
g.It("should match event", func() {
|
||||
secret := Secret{}
|
||||
secret.Events = []string{"pull_request"}
|
||||
|
|
|
@ -38,7 +38,6 @@ func Test_bitbucket(t *testing.T) {
|
|||
g := goblin.Goblin(t)
|
||||
ctx := context.Background()
|
||||
g.Describe("Bitbucket client", func() {
|
||||
|
||||
g.After(func() {
|
||||
s.Close()
|
||||
})
|
||||
|
@ -269,7 +268,6 @@ func Test_bitbucket(t *testing.T) {
|
|||
g.Assert(err).IsNil()
|
||||
g.Assert(r.FullName).Equal("user_name/repo_name")
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,8 @@ import (
|
|||
)
|
||||
|
||||
func Test_helper(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Bitbucket converter", func() {
|
||||
|
||||
g.It("should convert passing status", func() {
|
||||
g.Assert(convertStatus(model.StatusSuccess)).Equal(statusSuccess)
|
||||
})
|
||||
|
|
|
@ -25,10 +25,8 @@ import (
|
|||
)
|
||||
|
||||
func Test_parser(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Bitbucket parser", func() {
|
||||
|
||||
g.It("Should ignore unsupported hook", func() {
|
||||
buf := bytes.NewBufferString(fixtures.HookPush)
|
||||
req, _ := http.NewRequest("POST", "/hook", buf)
|
||||
|
@ -42,7 +40,6 @@ func Test_parser(t *testing.T) {
|
|||
})
|
||||
|
||||
g.Describe("Given a pull request hook payload", func() {
|
||||
|
||||
g.It("Should return err when malformed", func() {
|
||||
buf := bytes.NewBufferString("[]")
|
||||
req, _ := http.NewRequest("POST", "/hook", buf)
|
||||
|
@ -79,7 +76,6 @@ func Test_parser(t *testing.T) {
|
|||
})
|
||||
|
||||
g.Describe("Given a push hook payload", func() {
|
||||
|
||||
g.It("Should return err when malformed", func() {
|
||||
buf := bytes.NewBufferString("[]")
|
||||
req, _ := http.NewRequest("POST", "/hook", buf)
|
||||
|
|
|
@ -129,7 +129,6 @@ func (c *Config) Login(ctx context.Context, res http.ResponseWriter, req *http.R
|
|||
}
|
||||
|
||||
return convertUser(user, accessToken), nil
|
||||
|
||||
}
|
||||
|
||||
// Auth is not supported by the Stash driver.
|
||||
|
|
|
@ -72,7 +72,6 @@ func convertDesc(status model.StatusValue) string {
|
|||
// convertRepo is a helper function used to convert a Bitbucket server repository
|
||||
// structure to the common Woodpecker repository structure.
|
||||
func convertRepo(from *internal.Repo) *model.Repo {
|
||||
|
||||
repo := model.Repo{
|
||||
Name: from.Slug,
|
||||
Owner: from.Project.Key,
|
||||
|
@ -98,7 +97,6 @@ func convertRepo(from *internal.Repo) *model.Repo {
|
|||
}
|
||||
}
|
||||
return &repo
|
||||
|
||||
}
|
||||
|
||||
// convertPushHook is a helper function used to convert a Bitbucket push
|
||||
|
|
|
@ -25,10 +25,8 @@ import (
|
|||
)
|
||||
|
||||
func Test_helper(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Bitbucket Server converter", func() {
|
||||
|
||||
g.It("should convert repository", func() {
|
||||
from := &internal.Repo{
|
||||
Slug: "hello-world",
|
||||
|
|
|
@ -103,7 +103,6 @@ func (c *Client) FindCurrentUser() (*User, error) {
|
|||
}
|
||||
|
||||
return &user, nil
|
||||
|
||||
}
|
||||
|
||||
func (c *Client) FindRepo(owner string, name string) (*Repo, error) {
|
||||
|
@ -178,7 +177,6 @@ func (c *Client) CreateHook(owner string, name string, callBackLink string) erro
|
|||
return err
|
||||
}
|
||||
hooks = hookSettingsToArray(hookSettings)
|
||||
|
||||
}
|
||||
if !stringInSlice(callBackLink, hooks) {
|
||||
hooks = append(hooks, callBackLink)
|
||||
|
@ -195,13 +193,11 @@ func (c *Client) CreateStatus(revision string, status *BuildStatus) error {
|
|||
}
|
||||
|
||||
func (c *Client) DeleteHook(owner string, name string, link string) error {
|
||||
|
||||
hookSettings, err := c.GetHooks(owner, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
putHooks := filter(hookSettingsToArray(hookSettings), func(item string) bool {
|
||||
|
||||
return !strings.Contains(item, link)
|
||||
})
|
||||
putHookSettings := arrayToHookSettings(putHooks)
|
||||
|
|
|
@ -37,7 +37,6 @@ func Test_coding(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Coding", func() {
|
||||
|
||||
g.After(func() {
|
||||
s.Close()
|
||||
})
|
||||
|
@ -229,7 +228,6 @@ func Test_coding(t *testing.T) {
|
|||
g.Assert(r.FullName).Equal("demo1/test1")
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,9 @@ import (
|
|||
)
|
||||
|
||||
func Test_hook(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Coding hook", func() {
|
||||
|
||||
g.It("Should parse hook", func() {
|
||||
|
||||
reader := ioutil.NopCloser(strings.NewReader(fixtures.PushHook))
|
||||
r := &http.Request{
|
||||
Header: map[string][]string{
|
||||
|
@ -107,7 +104,6 @@ func Test_hook(t *testing.T) {
|
|||
})
|
||||
|
||||
g.It("Should parse push hook", func() {
|
||||
|
||||
repo := &model.Repo{
|
||||
Owner: "demo1",
|
||||
Name: "test1",
|
||||
|
@ -143,7 +139,6 @@ func Test_hook(t *testing.T) {
|
|||
})
|
||||
|
||||
g.It("Should parse pull request hook", func() {
|
||||
|
||||
repo := &model.Repo{
|
||||
Owner: "demo1",
|
||||
Name: "test2",
|
||||
|
@ -173,7 +168,6 @@ func Test_hook(t *testing.T) {
|
|||
})
|
||||
|
||||
g.It("Should parse merge request hook", func() {
|
||||
|
||||
repo := &model.Repo{
|
||||
Owner: "demo1",
|
||||
Name: "test1",
|
||||
|
@ -201,6 +195,5 @@ func Test_hook(t *testing.T) {
|
|||
g.Assert(actualRepo).Equal(repo)
|
||||
g.Assert(actualBuild).Equal(build)
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
|
|
@ -21,10 +21,8 @@ import (
|
|||
)
|
||||
|
||||
func Test_util(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Coding util", func() {
|
||||
|
||||
g.It("Should form project full name", func() {
|
||||
g.Assert(projectFullName("gk", "prj")).Equal("gk/prj")
|
||||
})
|
||||
|
|
|
@ -38,7 +38,6 @@ func Test_gitea(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Gitea", func() {
|
||||
|
||||
g.After(func() {
|
||||
s.Close()
|
||||
})
|
||||
|
|
|
@ -26,10 +26,8 @@ import (
|
|||
)
|
||||
|
||||
func Test_parse(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Gitea", func() {
|
||||
|
||||
g.It("Should parse push hook payload", func() {
|
||||
buf := bytes.NewBufferString(fixtures.HookPush)
|
||||
hook, err := parsePush(buf)
|
||||
|
@ -108,7 +106,6 @@ func Test_parse(t *testing.T) {
|
|||
g.Assert(build.Message).Equal(hook.Commits[0].Message)
|
||||
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||
g.Assert(build.Author).Equal(hook.Sender.Login)
|
||||
|
||||
})
|
||||
|
||||
g.It("Should return a Repo struct from a push hook", func() {
|
||||
|
@ -146,7 +143,6 @@ func Test_parse(t *testing.T) {
|
|||
g.Assert(build.Message).Equal(hook.PullRequest.Title)
|
||||
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||
g.Assert(build.Author).Equal(hook.PullRequest.User.Username)
|
||||
|
||||
})
|
||||
|
||||
g.It("Should return a Repo struct from a pull_request hook", func() {
|
||||
|
@ -220,7 +216,6 @@ func Test_parse(t *testing.T) {
|
|||
})
|
||||
|
||||
g.It("Should correct a malformed avatar url", func() {
|
||||
|
||||
var urls = []struct {
|
||||
Before string
|
||||
After string
|
||||
|
|
|
@ -24,10 +24,8 @@ import (
|
|||
)
|
||||
|
||||
func Test_helper(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("GitHub converter", func() {
|
||||
|
||||
g.It("should convert passing status", func() {
|
||||
g.Assert(convertStatus(model.StatusSuccess)).Equal(statusSuccess)
|
||||
})
|
||||
|
|
|
@ -38,7 +38,6 @@ func Test_github(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("GitHub", func() {
|
||||
|
||||
g.After(func() {
|
||||
s.Close()
|
||||
})
|
||||
|
|
|
@ -26,10 +26,8 @@ import (
|
|||
)
|
||||
|
||||
func Test_parser(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("GitHub parser", func() {
|
||||
|
||||
g.It("should ignore unsupported hook events", func() {
|
||||
buf := bytes.NewBufferString(fixtures.HookPullRequest)
|
||||
req, _ := http.NewRequest("POST", "/hook", buf)
|
||||
|
@ -109,6 +107,5 @@ func Test_parser(t *testing.T) {
|
|||
g.Assert(b.Event).Equal(model.EventDeploy)
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ func Test_gogs(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Gogs", func() {
|
||||
|
||||
g.After(func() {
|
||||
s.Close()
|
||||
})
|
||||
|
|
|
@ -26,10 +26,8 @@ import (
|
|||
)
|
||||
|
||||
func Test_parse(t *testing.T) {
|
||||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Gogs", func() {
|
||||
|
||||
g.It("Should parse push hook payload", func() {
|
||||
buf := bytes.NewBufferString(fixtures.HookPush)
|
||||
hook, err := parsePush(buf)
|
||||
|
@ -105,7 +103,6 @@ func Test_parse(t *testing.T) {
|
|||
g.Assert(build.Message).Equal(hook.Commits[0].Message)
|
||||
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||
g.Assert(build.Author).Equal(hook.Sender.Login)
|
||||
|
||||
})
|
||||
|
||||
g.It("Should return a Repo struct from a push hook", func() {
|
||||
|
@ -130,7 +127,6 @@ func Test_parse(t *testing.T) {
|
|||
g.Assert(build.Message).Equal(hook.PullRequest.Title)
|
||||
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||
g.Assert(build.Author).Equal(hook.PullRequest.User.Username)
|
||||
|
||||
})
|
||||
|
||||
g.It("Should return a Repo struct from a pull_request hook", func() {
|
||||
|
@ -192,7 +188,6 @@ func Test_parse(t *testing.T) {
|
|||
})
|
||||
|
||||
g.It("Should correct a malformed avatar url", func() {
|
||||
|
||||
var urls = []struct {
|
||||
Before string
|
||||
After string
|
||||
|
|
|
@ -132,7 +132,6 @@ func SetPerm() gin.HandlerFunc {
|
|||
if user != nil {
|
||||
log.Debug().Msgf("%s granted %+v permission to %s",
|
||||
user.Login, perm, repo.FullName)
|
||||
|
||||
} else {
|
||||
log.Debug().Msgf("Guest granted %+v to %s", perm, repo.FullName)
|
||||
}
|
||||
|
@ -181,7 +180,6 @@ func MustPush(c *gin.Context) {
|
|||
c.AbortWithStatus(http.StatusNotFound)
|
||||
log.Debug().Msgf("User %s denied write access to %s",
|
||||
user.Login, c.Request.URL.Path)
|
||||
|
||||
} else {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
log.Debug().Msgf("Guest denied write access to %s %s",
|
||||
|
|
|
@ -454,5 +454,4 @@ func TestSanitizePath(t *testing.T) {
|
|||
t.Fatal("Path hasn't been sanitized correctly")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ func TestRepos(t *testing.T) {
|
|||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("Repo", func() {
|
||||
|
||||
// before each test be sure to purge the package
|
||||
// table data from the database.
|
||||
g.BeforeEach(func() {
|
||||
|
|
|
@ -28,7 +28,6 @@ func TestUsers(t *testing.T) {
|
|||
|
||||
g := goblin.Goblin(t)
|
||||
g.Describe("User", func() {
|
||||
|
||||
// before each test be sure to purge the package
|
||||
// table data from the database.
|
||||
g.BeforeEach(func() {
|
||||
|
|
|
@ -82,7 +82,6 @@ func ParseRequest(r *http.Request, fn SecretFunc) (*Token, error) {
|
|||
}
|
||||
|
||||
func CheckCsrf(r *http.Request, fn SecretFunc) error {
|
||||
|
||||
// get and options requests are always
|
||||
// enabled, without CSRF checks.
|
||||
switch r.Method {
|
||||
|
|
Loading…
Reference in a new issue