mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
gofumpt -w -l -extra . (#661)
This commit is contained in:
parent
dec0eeeed7
commit
2f91bdd4a0
@ -75,7 +75,7 @@ func NewClient(c *cli.Context) (woodpecker.Client, error) {
|
||||
|
||||
// ParseRepo parses the repository owner and name from a string.
|
||||
func ParseRepo(str string) (user, repo string, err error) {
|
||||
var parts = strings.Split(str, "/")
|
||||
parts := strings.Split(str, "/")
|
||||
if len(parts) != 2 {
|
||||
err = fmt.Errorf("Error: Invalid or missing repository. eg octocat/hello-world")
|
||||
return
|
||||
|
@ -93,7 +93,7 @@ func loop(c *cli.Context) error {
|
||||
|
||||
// grpc.Dial(target, ))
|
||||
|
||||
var transport = grpc.WithInsecure()
|
||||
transport := grpc.WithInsecure()
|
||||
|
||||
if c.Bool("secure-grpc") {
|
||||
transport = grpc.WithTransportCredentials(grpccredentials.NewTLS(&tls.Config{InsecureSkipVerify: c.Bool("skip-insecure-grpc")}))
|
||||
@ -111,7 +111,6 @@ func loop(c *cli.Context) error {
|
||||
Timeout: c.Duration("keepalive-timeout"),
|
||||
}),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ func run(c *cli.Context) error {
|
||||
}
|
||||
|
||||
dir := cacheDir()
|
||||
if err := os.MkdirAll(dir, 0700); err != nil {
|
||||
if err := os.MkdirAll(dir, 0o700); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,7 @@ import (
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
||||
)
|
||||
|
||||
var (
|
||||
engines map[string]types.Engine
|
||||
)
|
||||
var engines map[string]types.Engine
|
||||
|
||||
func init() {
|
||||
engines = make(map[string]types.Engine)
|
||||
|
@ -9,9 +9,7 @@ import (
|
||||
// to create and manage container resources.
|
||||
type Engine interface {
|
||||
Name() string
|
||||
|
||||
IsAvailable() bool
|
||||
|
||||
Load() error
|
||||
|
||||
// Setup the pipeline environment.
|
||||
|
@ -168,7 +168,7 @@ func (c *Compiler) Compile(conf *yaml.Config) *backend.Config {
|
||||
var stage *backend.Stage
|
||||
var group string
|
||||
for i, container := range conf.Pipeline.Containers {
|
||||
//Skip if local and should not run local
|
||||
// Skip if local and should not run local
|
||||
if c.local && !container.Constraints.Local.Bool() {
|
||||
continue
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ func (c *Constraint) Excludes(v string) bool {
|
||||
|
||||
// UnmarshalYAML unmarshals the constraint.
|
||||
func (c *Constraint) UnmarshalYAML(value *yaml.Node) error {
|
||||
var out1 = struct {
|
||||
out1 := struct {
|
||||
Include types.Stringorslice
|
||||
Exclude types.Stringorslice
|
||||
}{}
|
||||
@ -177,7 +177,7 @@ func (c *ConstraintMap) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
|
||||
// UnmarshalYAML unmarshals the constraint.
|
||||
func (c *ConstraintPath) UnmarshalYAML(value *yaml.Node) error {
|
||||
var out1 = struct {
|
||||
out1 := struct {
|
||||
Include types.Stringorslice `yaml:"include,omitempty"`
|
||||
Exclude types.Stringorslice `yaml:"exclude,omitempty"`
|
||||
IgnoreMessage string `yaml:"ignore_message,omitempty"`
|
||||
|
@ -24,7 +24,6 @@ func (s *StringorInt) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var stringType string
|
||||
if err := unmarshal(&stringType); err == nil {
|
||||
intType, err := strconv.ParseInt(stringType, 10, 64)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -50,7 +49,6 @@ func (s *MemStringorInt) UnmarshalYAML(unmarshal func(interface{}) error) error
|
||||
var stringType string
|
||||
if err := unmarshal(&stringType); err == nil {
|
||||
intType, err := units.RAMInBytes(stringType)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ func PostBuild(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Read query string parameters into buildParams, exclude reserved params
|
||||
var envs = map[string]string{}
|
||||
envs := map[string]string{}
|
||||
for key, val := range c.Request.URL.Query() {
|
||||
switch key {
|
||||
// Skip some options of the endpoint
|
||||
|
@ -24,10 +24,8 @@ import (
|
||||
"github.com/woodpecker-ci/woodpecker/server"
|
||||
)
|
||||
|
||||
var (
|
||||
// errInvalidToken is returned when the api request token is invalid.
|
||||
errInvalidToken = errors.New("Invalid or missing token")
|
||||
)
|
||||
// errInvalidToken is returned when the api request token is invalid.
|
||||
var errInvalidToken = errors.New("Invalid or missing token")
|
||||
|
||||
// PromHandler will pass the call from /api/metrics/prometheus to prometheus
|
||||
func PromHandler() gin.HandlerFunc {
|
||||
|
@ -61,7 +61,7 @@ func (r *Repo) ResetVisibility() {
|
||||
|
||||
// ParseRepo parses the repository owner and name from a string.
|
||||
func ParseRepo(str string) (user, repo string, err error) {
|
||||
var parts = strings.Split(str, "/")
|
||||
parts := strings.Split(str, "/")
|
||||
if len(parts) != 2 {
|
||||
err = fmt.Errorf("Error: Invalid or missing repository. eg octocat/hello-world")
|
||||
return
|
||||
|
@ -17,7 +17,7 @@ package model
|
||||
import "testing"
|
||||
|
||||
func TestUserValidate(t *testing.T) {
|
||||
var tests = []struct {
|
||||
tests := []struct {
|
||||
user User
|
||||
err error
|
||||
}{
|
||||
|
@ -336,7 +336,7 @@ func (q *fifo) depsInQueue(task *Task) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (q *fifo) updateDepStatusInQueue(taskID string, status string) {
|
||||
func (q *fifo) updateDepStatusInQueue(taskID, status string) {
|
||||
var next *list.Element
|
||||
for e := q.pending.Front(); e != nil; e = next {
|
||||
next = e.Next()
|
||||
|
@ -106,7 +106,7 @@ func (c *Client) ListRepos(account string, opts *ListOpts) (*RepoResp, error) {
|
||||
}
|
||||
|
||||
func (c *Client) ListReposAll(account string) ([]*Repo, error) {
|
||||
var page = 1
|
||||
page := 1
|
||||
var repos []*Repo
|
||||
|
||||
for {
|
||||
@ -164,7 +164,6 @@ func (c *Client) GetPermission(fullName string) (*RepoPerm, error) {
|
||||
out := new(RepoPermResp)
|
||||
uri := fmt.Sprintf(pathPermissions, c.base, fullName)
|
||||
_, err := c.do(uri, get, nil, out)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ func (c *Config) Login(ctx context.Context, res http.ResponseWriter, req *http.R
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var code = req.FormValue("oauth_verifier")
|
||||
code := req.FormValue("oauth_verifier")
|
||||
if len(code) == 0 {
|
||||
http.Redirect(res, req, u, http.StatusSeeOther)
|
||||
return nil, nil
|
||||
@ -205,9 +205,9 @@ func (c *Config) Netrc(user *model.User, r *model.Repo) (*model.Netrc, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//remove the port
|
||||
// remove the port
|
||||
tmp := strings.Split(u.Host, ":")
|
||||
var host = tmp[0]
|
||||
host := tmp[0]
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -240,7 +240,7 @@ func (c *Config) Hook(r *http.Request) (*model.Repo, *model.Build, error) {
|
||||
return parseHook(r, c.URL)
|
||||
}
|
||||
|
||||
func CreateConsumer(URL string, ConsumerKey string, PrivateKey *rsa.PrivateKey) *oauth.Consumer {
|
||||
func CreateConsumer(URL, ConsumerKey string, PrivateKey *rsa.PrivateKey) *oauth.Consumer {
|
||||
consumer := oauth.NewRSAConsumer(
|
||||
ConsumerKey,
|
||||
PrivateKey,
|
||||
|
@ -88,7 +88,7 @@ func convertPushHook(hook *internal.PostHook, baseURL string) *model.Build {
|
||||
"refs/tags/",
|
||||
)
|
||||
|
||||
//Ensuring the author label is not longer then 40 for the label of the commit author (default size in the db)
|
||||
// Ensuring the author label is not longer then 40 for the label of the commit author (default size in the db)
|
||||
authorLabel := hook.Changesets.Values[0].ToCommit.Author.Name
|
||||
if len(authorLabel) > 40 {
|
||||
authorLabel = authorLabel[0:37] + "..."
|
||||
@ -97,7 +97,7 @@ func convertPushHook(hook *internal.PostHook, baseURL string) *model.Build {
|
||||
build := &model.Build{
|
||||
Commit: hook.RefChanges[0].ToHash, // TODO check for index value
|
||||
Branch: branch,
|
||||
Message: hook.Changesets.Values[0].ToCommit.Message, //TODO check for index Values
|
||||
Message: hook.Changesets.Values[0].ToCommit.Message, // TODO check for index Values
|
||||
Avatar: avatarLink(hook.Changesets.Values[0].ToCommit.Author.EmailAddress),
|
||||
Author: authorLabel,
|
||||
Email: hook.Changesets.Values[0].ToCommit.Author.EmailAddress,
|
||||
|
@ -33,7 +33,7 @@ func Test_helper(t *testing.T) {
|
||||
}
|
||||
from.Project.Key = "octocat"
|
||||
|
||||
//var links [1]internal.LinkType
|
||||
// var links [1]internal.LinkType
|
||||
link := internal.CloneLink{
|
||||
Name: "http",
|
||||
Href: "https://x7hw@server.org/foo/bar.git",
|
||||
|
@ -105,7 +105,7 @@ func (c *Client) FindCurrentUser() (*User, error) {
|
||||
return &user, nil
|
||||
}
|
||||
|
||||
func (c *Client) FindRepo(owner string, name string) (*Repo, error) {
|
||||
func (c *Client) FindRepo(owner, name string) (*Repo, error) {
|
||||
urlString := fmt.Sprintf(pathRepo, c.base, owner, name)
|
||||
response, err := c.doGet(urlString)
|
||||
if response != nil {
|
||||
@ -130,7 +130,7 @@ func (c *Client) FindRepos() ([]*Repo, error) {
|
||||
return c.paginatedRepos(0)
|
||||
}
|
||||
|
||||
func (c *Client) FindRepoPerms(owner string, repo string) (*model.Perm, error) {
|
||||
func (c *Client) FindRepoPerms(owner, repo string) (*model.Perm, error) {
|
||||
perms := new(model.Perm)
|
||||
// If you don't have access return none right away
|
||||
_, err := c.FindRepo(owner, repo)
|
||||
@ -150,7 +150,7 @@ func (c *Client) FindRepoPerms(owner string, repo string) (*model.Perm, error) {
|
||||
return perms, nil
|
||||
}
|
||||
|
||||
func (c *Client) FindFileForRepo(owner string, repo string, fileName string, ref string) ([]byte, error) {
|
||||
func (c *Client) FindFileForRepo(owner, repo, fileName, ref string) ([]byte, error) {
|
||||
response, err := c.doGet(fmt.Sprintf(pathSource, c.base, owner, repo, fileName, ref))
|
||||
if response != nil {
|
||||
defer response.Body.Close()
|
||||
@ -168,7 +168,7 @@ func (c *Client) FindFileForRepo(owner string, repo string, fileName string, ref
|
||||
return responseBytes, nil
|
||||
}
|
||||
|
||||
func (c *Client) CreateHook(owner string, name string, callBackLink string) error {
|
||||
func (c *Client) CreateHook(owner, name, callBackLink string) error {
|
||||
hookDetails, err := c.GetHookDetails(owner, name)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -198,7 +198,7 @@ func (c *Client) CreateStatus(revision string, status *BuildStatus) error {
|
||||
return c.doPost(uri, status)
|
||||
}
|
||||
|
||||
func (c *Client) DeleteHook(owner string, name string, link string) error {
|
||||
func (c *Client) DeleteHook(owner, name, link string) error {
|
||||
hookSettings, err := c.GetHooks(owner, name)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -214,7 +214,7 @@ func (c *Client) DeleteHook(owner string, name string, link string) error {
|
||||
return c.doPut(fmt.Sprintf(pathHookEnabled, c.base, owner, name, hookName), hookBytes)
|
||||
}
|
||||
|
||||
func (c *Client) GetHookDetails(owner string, name string) (*HookPluginDetails, error) {
|
||||
func (c *Client) GetHookDetails(owner, name string) (*HookPluginDetails, error) {
|
||||
urlString := fmt.Sprintf(pathHookDetails, c.base, owner, name, hookName)
|
||||
response, err := c.doGet(urlString)
|
||||
if response != nil {
|
||||
@ -229,7 +229,7 @@ func (c *Client) GetHookDetails(owner string, name string) (*HookPluginDetails,
|
||||
return &hookDetails, err
|
||||
}
|
||||
|
||||
func (c *Client) GetHooks(owner string, name string) (*HookSettings, error) {
|
||||
func (c *Client) GetHooks(owner, name string) (*HookSettings, error) {
|
||||
urlString := fmt.Sprintf(pathHookSettings, c.base, owner, name, hookName)
|
||||
response, err := c.doGet(urlString)
|
||||
if response != nil {
|
||||
@ -244,9 +244,9 @@ func (c *Client) GetHooks(owner string, name string) (*HookSettings, error) {
|
||||
return &hookSettings, err
|
||||
}
|
||||
|
||||
//TODO: make these as as general do with the action
|
||||
// TODO: make these as as general do with the action
|
||||
|
||||
//Helper function to help create get
|
||||
// Helper function to help create get
|
||||
func (c *Client) doGet(url string) (*http.Response, error) {
|
||||
request, err := http.NewRequestWithContext(c.ctx, "GET", url, nil)
|
||||
if err != nil {
|
||||
@ -256,7 +256,7 @@ func (c *Client) doGet(url string) (*http.Response, error) {
|
||||
return c.client.Do(request)
|
||||
}
|
||||
|
||||
//Helper function to help create the hook
|
||||
// Helper function to help create the hook
|
||||
func (c *Client) doPut(url string, body []byte) error {
|
||||
request, err := http.NewRequestWithContext(c.ctx, "PUT", url, bytes.NewBuffer(body))
|
||||
if err != nil {
|
||||
@ -273,7 +273,7 @@ func (c *Client) doPut(url string, body []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//Helper function to help create the hook
|
||||
// Helper function to help create the hook
|
||||
func (c *Client) doPost(url string, status *BuildStatus) error {
|
||||
// write it to the body of the request.
|
||||
var buf io.ReadWriter
|
||||
@ -296,7 +296,7 @@ func (c *Client) doPost(url string, status *BuildStatus) error {
|
||||
return err
|
||||
}
|
||||
|
||||
//Helper function to get repos paginated
|
||||
// Helper function to get repos paginated
|
||||
func (c *Client) paginatedRepos(start int) ([]*Repo, error) {
|
||||
limit := 1000
|
||||
requestURL := fmt.Sprintf(pathRepos, c.base, strconv.Itoa(start), strconv.Itoa(limit))
|
||||
@ -332,7 +332,7 @@ func filter(vs []string, f func(string) bool) []string {
|
||||
return vsf
|
||||
}
|
||||
|
||||
//TODO: find a clean way of doing these next two methods- bitbucket server hooks only support 20 cb hooks
|
||||
// TODO: find a clean way of doing these next two methods- bitbucket server hooks only support 20 cb hooks
|
||||
func arrayToHookSettings(hooks []string) HookSettings {
|
||||
hookSettings := HookSettings{}
|
||||
for loc, value := range hooks {
|
||||
@ -378,7 +378,7 @@ func arrayToHookSettings(hooks []string) HookSettings {
|
||||
case 19:
|
||||
hookSettings.HookURL19 = value
|
||||
|
||||
//Since there's only 19 hooks it will add to the latest if it doesn't exist :/
|
||||
// Since there's only 19 hooks it will add to the latest if it doesn't exist :/
|
||||
default:
|
||||
hookSettings.HookURL19 = value
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ func (c *Gitea) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error)
|
||||
}
|
||||
|
||||
// Gitea SDK forces us to read repo list paginated.
|
||||
var page = 1
|
||||
page := 1
|
||||
for {
|
||||
all, _, err := client.ListMyRepos(
|
||||
gitea.ListReposOptions{
|
||||
|
@ -216,7 +216,7 @@ func Test_parse(t *testing.T) {
|
||||
})
|
||||
|
||||
g.It("Should correct a malformed avatar url", func() {
|
||||
var urls = []struct {
|
||||
urls := []struct {
|
||||
Before string
|
||||
After string
|
||||
}{
|
||||
@ -245,7 +245,7 @@ func Test_parse(t *testing.T) {
|
||||
})
|
||||
|
||||
g.It("Should expand the avatar url", func() {
|
||||
var urls = []struct {
|
||||
urls := []struct {
|
||||
Before string
|
||||
After string
|
||||
}{
|
||||
@ -263,7 +263,7 @@ func Test_parse(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
var repo = "http://gitea.io/foo/bar"
|
||||
repo := "http://gitea.io/foo/bar"
|
||||
for _, url := range urls {
|
||||
got := expandAvatar(repo, url.Before)
|
||||
g.Assert(got).Equal(url.After)
|
||||
|
@ -29,8 +29,8 @@ import (
|
||||
func (g *Gitlab) convertGitlabRepo(_repo *gitlab.Project) (*model.Repo, error) {
|
||||
parts := strings.Split(_repo.PathWithNamespace, "/")
|
||||
// TODO(648) save repo id (support nested repos)
|
||||
var owner = strings.Join(parts[:len(parts)-1], "/")
|
||||
var name = parts[len(parts)-1]
|
||||
owner := strings.Join(parts[:len(parts)-1], "/")
|
||||
name := parts[len(parts)-1]
|
||||
repo := &model.Repo{
|
||||
Owner: owner,
|
||||
Name: name,
|
||||
|
@ -90,7 +90,7 @@ func New(opts Opts) (remote.Remote, error) {
|
||||
// Login authenticates the session and returns the
|
||||
// remote user details.
|
||||
func (g *Gitlab) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
||||
var config = &oauth2.Config{
|
||||
config := &oauth2.Config{
|
||||
ClientID: g.ClientID,
|
||||
ClientSecret: g.ClientSecret,
|
||||
Scope: defaultScope,
|
||||
@ -109,17 +109,17 @@ func (g *Gitlab) Login(ctx context.Context, res http.ResponseWriter, req *http.R
|
||||
}
|
||||
|
||||
// get the OAuth code
|
||||
var code = req.FormValue("code")
|
||||
code := req.FormValue("code")
|
||||
if len(code) == 0 {
|
||||
http.Redirect(res, req, config.AuthCodeURL("drone"), http.StatusSeeOther)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var trans = &oauth2.Transport{Config: config, Transport: &http.Transport{
|
||||
trans := &oauth2.Transport{Config: config, Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: g.SkipVerify},
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
}}
|
||||
var token, err = trans.Exchange(code)
|
||||
token, err := trans.Exchange(code)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error exchanging token. %s", err)
|
||||
}
|
||||
@ -395,7 +395,7 @@ func (g *Gitlab) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (g *Gitlab) getTokenAndWebURL(link string) (token string, webURL string, err error) {
|
||||
func (g *Gitlab) getTokenAndWebURL(link string) (token, webURL string, err error) {
|
||||
uri, err := url.Parse(link)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
|
@ -52,19 +52,19 @@ func load(config string) *Gitlab {
|
||||
|
||||
func Test_Gitlab(t *testing.T) {
|
||||
// setup a dummy github server
|
||||
var server = testdata.NewServer(t)
|
||||
server := testdata.NewServer(t)
|
||||
defer server.Close()
|
||||
|
||||
env := server.URL + "?client_id=test&client_secret=test"
|
||||
|
||||
client := load(env)
|
||||
|
||||
var user = model.User{
|
||||
user := model.User{
|
||||
Login: "test_user",
|
||||
Token: "e3b0c44298fc1c149afbf4c8996fb",
|
||||
}
|
||||
|
||||
var repo = model.Repo{
|
||||
repo := model.Repo{
|
||||
Name: "diaspora-client",
|
||||
Owner: "diaspora",
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ func newClient(url, accessToken string, skipVerify bool) (*gitlab.Client, error)
|
||||
// isRead is a helper function that returns true if the
|
||||
// user has Read-only access to the repository.
|
||||
func isRead(proj *gitlab.Project) bool {
|
||||
var user = proj.Permissions.ProjectAccess
|
||||
var group = proj.Permissions.GroupAccess
|
||||
user := proj.Permissions.ProjectAccess
|
||||
group := proj.Permissions.GroupAccess
|
||||
|
||||
switch {
|
||||
case proj.Public:
|
||||
@ -57,8 +57,8 @@ func isRead(proj *gitlab.Project) bool {
|
||||
// isWrite is a helper function that returns true if the
|
||||
// user has Read-Write access to the repository.
|
||||
func isWrite(proj *gitlab.Project) bool {
|
||||
var user = proj.Permissions.ProjectAccess
|
||||
var group = proj.Permissions.GroupAccess
|
||||
user := proj.Permissions.ProjectAccess
|
||||
group := proj.Permissions.GroupAccess
|
||||
|
||||
switch {
|
||||
case user != nil && user.AccessLevel >= 30:
|
||||
@ -73,8 +73,8 @@ func isWrite(proj *gitlab.Project) bool {
|
||||
// isAdmin is a helper function that returns true if the
|
||||
// user has Admin access to the repository.
|
||||
func isAdmin(proj *gitlab.Project) bool {
|
||||
var user = proj.Permissions.ProjectAccess
|
||||
var group = proj.Permissions.GroupAccess
|
||||
user := proj.Permissions.ProjectAccess
|
||||
group := proj.Permissions.GroupAccess
|
||||
|
||||
switch {
|
||||
case user != nil && user.AccessLevel >= 40:
|
||||
|
@ -188,7 +188,7 @@ func Test_parse(t *testing.T) {
|
||||
})
|
||||
|
||||
g.It("Should correct a malformed avatar url", func() {
|
||||
var urls = []struct {
|
||||
urls := []struct {
|
||||
Before string
|
||||
After string
|
||||
}{
|
||||
@ -217,7 +217,7 @@ func Test_parse(t *testing.T) {
|
||||
})
|
||||
|
||||
g.It("Should expand the avatar url", func() {
|
||||
var urls = []struct {
|
||||
urls := []struct {
|
||||
Before string
|
||||
After string
|
||||
}{
|
||||
@ -235,7 +235,7 @@ func Test_parse(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
var repo = "http://gogs.io/foo/bar"
|
||||
repo := "http://gogs.io/foo/bar"
|
||||
for _, url := range urls {
|
||||
got := expandAvatar(repo, url.Before)
|
||||
g.Assert(got).Equal(url.After)
|
||||
|
@ -19,5 +19,4 @@ import (
|
||||
)
|
||||
|
||||
func TestSetPerm(t *testing.T) {
|
||||
|
||||
}
|
||||
|
@ -22,8 +22,7 @@ import (
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
)
|
||||
|
||||
type mockUpdateBuildStore struct {
|
||||
}
|
||||
type mockUpdateBuildStore struct{}
|
||||
|
||||
func (m *mockUpdateBuildStore) UpdateBuild(build *model.Build) error {
|
||||
return nil
|
||||
|
@ -49,7 +49,8 @@ pipeline:
|
||||
image: scratch
|
||||
yyy: ${CI_COMMIT_MESSAGE}
|
||||
`)},
|
||||
}}
|
||||
},
|
||||
}
|
||||
|
||||
if buildItems, err := b.Build(); err != nil {
|
||||
t.Fatal(err)
|
||||
@ -404,7 +405,8 @@ func TestTree(t *testing.T) {
|
||||
Secs: []*model.Secret{},
|
||||
Regs: []*model.Registry{},
|
||||
Link: "",
|
||||
Yamls: []*remote.FileMeta{{Data: []byte(`
|
||||
Yamls: []*remote.FileMeta{
|
||||
{Data: []byte(`
|
||||
pipeline:
|
||||
build:
|
||||
image: scratch
|
||||
|
@ -22,8 +22,7 @@ import (
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
)
|
||||
|
||||
type mockUpdateProcStore struct {
|
||||
}
|
||||
type mockUpdateProcStore struct{}
|
||||
|
||||
func (m *mockUpdateProcStore) ProcUpdate(build *model.Proc) error {
|
||||
return nil
|
||||
|
@ -212,8 +212,10 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
|
||||
return nil
|
||||
}
|
||||
|
||||
var whitespaces = regexp.MustCompile(`\s+`)
|
||||
var columnSeparator = regexp.MustCompile(`\s?,\s?`)
|
||||
var (
|
||||
whitespaces = regexp.MustCompile(`\s+`)
|
||||
columnSeparator = regexp.MustCompile(`\s?,\s?`)
|
||||
)
|
||||
|
||||
func removeColumnFromSQLITETableSchema(schema string, names ...string) string {
|
||||
if len(names) == 0 {
|
||||
|
@ -36,7 +36,7 @@ func createSQLiteDB(t *testing.T) string {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if !assert.NoError(t, ioutil.WriteFile(tmpF.Name(), dbF, 0644)) {
|
||||
if !assert.NoError(t, ioutil.WriteFile(tmpF.Name(), dbF, 0o644)) {
|
||||
t.FailNow()
|
||||
}
|
||||
return tmpF.Name()
|
||||
|
@ -54,7 +54,7 @@ func Config(c *gin.Context) {
|
||||
}
|
||||
|
||||
// default func map with json parser.
|
||||
var funcMap = template.FuncMap{
|
||||
funcMap := template.FuncMap{
|
||||
"json": func(v interface{}) string {
|
||||
a, _ := json.Marshal(v)
|
||||
return string(a)
|
||||
|
@ -88,7 +88,7 @@ func (f CacheFile) Token() (*Token, error) {
|
||||
}
|
||||
|
||||
func (f CacheFile) PutToken(tok *Token) error {
|
||||
file, err := os.OpenFile(string(f), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
||||
file, err := os.OpenFile(string(f), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600)
|
||||
if err != nil {
|
||||
return OAuthError{"CacheFile.PutToken", err.Error()}
|
||||
}
|
||||
|
@ -14,10 +14,8 @@
|
||||
|
||||
package version
|
||||
|
||||
var (
|
||||
// Version of Woodpecker, set with ldflags, from Git tag
|
||||
Version string
|
||||
)
|
||||
// Version of Woodpecker, set with ldflags, from Git tag
|
||||
var Version string
|
||||
|
||||
// String returns the Version set at build time or "dev"
|
||||
func String() string {
|
||||
|
@ -114,7 +114,7 @@ func (c *client) UserDel(login string) error {
|
||||
}
|
||||
|
||||
// Repo returns a repository by name.
|
||||
func (c *client) Repo(owner string, name string) (*Repo, error) {
|
||||
func (c *client) Repo(owner, name string) (*Repo, error) {
|
||||
out := new(Repo)
|
||||
uri := fmt.Sprintf(pathRepo, c.addr, owner, name)
|
||||
err := c.get(uri, out)
|
||||
@ -140,7 +140,7 @@ func (c *client) RepoListOpts(sync, all bool) ([]*Repo, error) {
|
||||
}
|
||||
|
||||
// RepoPost activates a repository.
|
||||
func (c *client) RepoPost(owner string, name string) (*Repo, error) {
|
||||
func (c *client) RepoPost(owner, name string) (*Repo, error) {
|
||||
out := new(Repo)
|
||||
uri := fmt.Sprintf(pathRepo, c.addr, owner, name)
|
||||
err := c.post(uri, nil, out)
|
||||
@ -148,7 +148,7 @@ func (c *client) RepoPost(owner string, name string) (*Repo, error) {
|
||||
}
|
||||
|
||||
// RepoChown updates a repository owner.
|
||||
func (c *client) RepoChown(owner string, name string) (*Repo, error) {
|
||||
func (c *client) RepoChown(owner, name string) (*Repo, error) {
|
||||
out := new(Repo)
|
||||
uri := fmt.Sprintf(pathChown, c.addr, owner, name)
|
||||
err := c.post(uri, nil, out)
|
||||
@ -156,7 +156,7 @@ func (c *client) RepoChown(owner string, name string) (*Repo, error) {
|
||||
}
|
||||
|
||||
// RepoRepair repairs the repository hooks.
|
||||
func (c *client) RepoRepair(owner string, name string) error {
|
||||
func (c *client) RepoRepair(owner, name string) error {
|
||||
uri := fmt.Sprintf(pathRepair, c.addr, owner, name)
|
||||
return c.post(uri, nil, nil)
|
||||
}
|
||||
@ -290,7 +290,7 @@ func (c *client) Registry(owner, name, hostname string) (*Registry, error) {
|
||||
}
|
||||
|
||||
// RegistryList returns a list of all repository registries.
|
||||
func (c *client) RegistryList(owner string, name string) ([]*Registry, error) {
|
||||
func (c *client) RegistryList(owner, name string) ([]*Registry, error) {
|
||||
var out []*Registry
|
||||
uri := fmt.Sprintf(pathRepoRegistries, c.addr, owner, name)
|
||||
err := c.get(uri, &out)
|
||||
@ -328,7 +328,7 @@ func (c *client) Secret(owner, name, secret string) (*Secret, error) {
|
||||
}
|
||||
|
||||
// SecretList returns a list of all repository secrets.
|
||||
func (c *client) SecretList(owner string, name string) ([]*Secret, error) {
|
||||
func (c *client) SecretList(owner, name string) ([]*Secret, error) {
|
||||
var out []*Secret
|
||||
uri := fmt.Sprintf(pathRepoSecrets, c.addr, owner, name)
|
||||
err := c.get(uri, &out)
|
||||
|
Loading…
Reference in New Issue
Block a user