From c5bd09702a7a0136eed588785dee6db074c16379 Mon Sep 17 00:00:00 2001 From: renovate Date: Sat, 1 Oct 2022 15:05:12 +0000 Subject: [PATCH] chore(deps): update dependency golang to v1.19 (#1228) Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/api/pulls/1228 Co-authored-by: renovate Co-committed-by: renovate --- .drone.yml | 7 ++++--- Dockerfile | 2 +- Dockerfile.arm32 | 2 +- magefile.go | 13 ++++++------- pkg/models/list_duplicate.go | 1 + pkg/models/namespace.go | 1 + pkg/models/tasks.go | 5 +++-- pkg/modules/avatar/gravatar/gravatar.go | 4 ++-- pkg/modules/avatar/upload/upload.go | 5 +++-- pkg/modules/migration/create_from_structure.go | 7 +++---- pkg/modules/migration/todoist/todoist_test.go | 4 ++-- pkg/modules/migration/trello/trello_test.go | 4 ++-- .../migration/wunderlist/wunderlist_test.go | 4 ++-- pkg/routes/caldav/handler.go | 14 +++++++------- 14 files changed, 38 insertions(+), 35 deletions(-) diff --git a/.drone.yml b/.drone.yml index d4ac92c4..6680a09f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -132,14 +132,15 @@ steps: event: [ push, tag, pull_request ] - name: lint - image: golang:1.17-alpine + image: golang:1.19-alpine pull: true environment: GOPROXY: 'https://goproxy.kolaente.de' depends_on: [ build ] commands: + - export "GOROOT=$(go env GOROOT)" - apk --no-cache add build-base git - - wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.47.3 + - wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0 - ./mage-static check:all when: event: [ push, tag, pull_request ] @@ -878,6 +879,6 @@ steps: - failure --- kind: signature -hmac: d95e5d4b31e22079ce6360f31ec9257b26cd206b614cb1ec660290c061eced8f +hmac: 9ca8948161dc6ac167aa3f01d2798745f58550b24c6ced4a81bf64b5b129f172 ... diff --git a/Dockerfile b/Dockerfile index 729120ff..3c1bfd10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ############## # Build stage -FROM golang:1.18-alpine AS build-env +FROM golang:1.19-alpine AS build-env RUN apk --no-cache add build-base git && \ go install github.com/magefile/mage@latest && \ diff --git a/Dockerfile.arm32 b/Dockerfile.arm32 index ce51c958..005799aa 100644 --- a/Dockerfile.arm32 +++ b/Dockerfile.arm32 @@ -1,7 +1,7 @@ ############## # Build stage -FROM golang:1.18-buster AS build-env +FROM golang:1.19-buster AS build-env RUN go install github.com/magefile/mage@latest && \ mv /go/bin/mage /usr/local/go/bin diff --git a/magefile.go b/magefile.go index cd2fa82d..a2a14487 100644 --- a/magefile.go +++ b/magefile.go @@ -27,7 +27,6 @@ import ( "fmt" "github.com/iancoleman/strcase" "io" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -701,14 +700,14 @@ func (Release) Packages() error { // Because nfpm does not support templating, we replace the values in the config file and restore it after running nfpmConfigPath := RootPath + "/nfpm.yaml" - nfpmconfig, err := ioutil.ReadFile(nfpmConfigPath) + nfpmconfig, err := os.ReadFile(nfpmConfigPath) if err != nil { return err } fixedConfig := strings.ReplaceAll(string(nfpmconfig), "", VersionNumber) fixedConfig = strings.ReplaceAll(fixedConfig, "", BinLocation) - if err := ioutil.WriteFile(nfpmConfigPath, []byte(fixedConfig), 0); err != nil { + if err := os.WriteFile(nfpmConfigPath, []byte(fixedConfig), 0); err != nil { return err } @@ -721,7 +720,7 @@ func (Release) Packages() error { runAndStreamOutput(binpath, "pkg", "--packager", "rpm", "--target", releasePath) runAndStreamOutput(binpath, "pkg", "--packager", "apk", "--target", releasePath) - return ioutil.WriteFile(nfpmConfigPath, nfpmconfig, 0) + return os.WriteFile(nfpmConfigPath, nfpmconfig, 0) } type Dev mg.Namespace @@ -885,7 +884,7 @@ func (s *` + name + `) Handle(msg *message.Message) (err error) { if _, err := f.Seek(idx, 0); err != nil { return err } - remainder, err := ioutil.ReadAll(f) + remainder, err := io.ReadAll(f) if err != nil { return err } @@ -1074,7 +1073,7 @@ const ( // Generates the config docs from a commented config.yml.sample file in the repo root. func GenerateDocs() error { - config, err := ioutil.ReadFile("config.yml.sample") + config, err := os.ReadFile("config.yml.sample") if err != nil { return err } @@ -1124,7 +1123,7 @@ func GenerateDocs() error { // We write the full file to prevent old content leftovers at the end // I know, there are probably better ways to do this. - if err := ioutil.WriteFile(configDocPath, []byte(fullConfig), 0); err != nil { + if err := os.WriteFile(configDocPath, []byte(fullConfig), 0); err != nil { return err } diff --git a/pkg/models/list_duplicate.go b/pkg/models/list_duplicate.go index 5b1e51ac..d5c75325 100644 --- a/pkg/models/list_duplicate.go +++ b/pkg/models/list_duplicate.go @@ -66,6 +66,7 @@ func (ld *ListDuplicate) CanCreate(s *xorm.Session, a web.Auth) (canCreate bool, // @Failure 403 {object} web.HTTPError "The user does not have access to the list or namespace" // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{listID}/duplicate [put] +// //nolint:gocyclo func (ld *ListDuplicate) Create(s *xorm.Session, doer web.Auth) (err error) { diff --git a/pkg/models/namespace.go b/pkg/models/namespace.go index 14466c65..3da5f703 100644 --- a/pkg/models/namespace.go +++ b/pkg/models/namespace.go @@ -480,6 +480,7 @@ func getSavedFilters(s *xorm.Session, doer *user.User) (savedFiltersNamespace *N // @Success 200 {array} models.NamespaceWithLists "The Namespaces." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces [get] +// //nolint:gocyclo func (n *Namespace) ReadAll(s *xorm.Session, a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) { if _, is := a.(*LinkSharing); is { diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index c73e8bb2..ea24d85e 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -979,6 +979,7 @@ func createTask(s *xorm.Session, t *Task, a web.Auth, updateAssignees bool) (err // @Failure 403 {object} web.HTTPError "The user does not have access to the task (aka its list)" // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{id} [post] +// //nolint:gocyclo func (t *Task) Update(s *xorm.Session, a web.Auth) (err error) { @@ -1331,8 +1332,8 @@ func setTaskDatesFromCurrentDateRepeat(oldTask, newTask *Task) { // This helper function updates the reminders, doneAt, start and end dates of the *old* task // and saves the new values in the newTask object. // We make a few assumtions here: -// 1. Everything in oldTask is the truth - we figure out if we update anything at all if oldTask.RepeatAfter has a value > 0 -// 2. Because of 1., this functions should not be used to update values other than Done in the same go +// 1. Everything in oldTask is the truth - we figure out if we update anything at all if oldTask.RepeatAfter has a value > 0 +// 2. Because of 1., this functions should not be used to update values other than Done in the same go func updateDone(oldTask *Task, newTask *Task) { if !oldTask.Done && newTask.Done { switch oldTask.RepeatMode { diff --git a/pkg/modules/avatar/gravatar/gravatar.go b/pkg/modules/avatar/gravatar/gravatar.go index 35157d48..99faddd1 100644 --- a/pkg/modules/avatar/gravatar/gravatar.go +++ b/pkg/modules/avatar/gravatar/gravatar.go @@ -18,7 +18,7 @@ package gravatar import ( "context" - "io/ioutil" + "io" "net/http" "strconv" "strings" @@ -74,7 +74,7 @@ func (g *Provider) GetAvatar(user *user.User, size int64) ([]byte, string, error return nil, "", err } defer resp.Body.Close() - avatarContent, err := ioutil.ReadAll(resp.Body) + avatarContent, err := io.ReadAll(resp.Body) if err != nil { return nil, "", err } diff --git a/pkg/modules/avatar/upload/upload.go b/pkg/modules/avatar/upload/upload.go index e75f2ba6..311d9697 100644 --- a/pkg/modules/avatar/upload/upload.go +++ b/pkg/modules/avatar/upload/upload.go @@ -20,13 +20,14 @@ import ( "bytes" "image" "image/png" - "io/ioutil" + "io" "strconv" "code.vikunja.io/api/pkg/files" "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/modules/keyvalue" "code.vikunja.io/api/pkg/user" + "github.com/disintegration/imaging" ) @@ -82,7 +83,7 @@ func (p *Provider) GetAvatar(u *user.User, size int64) (avatar []byte, mimeType return nil, "", err } - avatar, err = ioutil.ReadAll(buf) + avatar, err = io.ReadAll(buf) if err != nil { return nil, "", err } diff --git a/pkg/modules/migration/create_from_structure.go b/pkg/modules/migration/create_from_structure.go index e4522461..1f33f53a 100644 --- a/pkg/modules/migration/create_from_structure.go +++ b/pkg/modules/migration/create_from_structure.go @@ -18,15 +18,14 @@ package migration import ( "bytes" - "io/ioutil" - - "code.vikunja.io/api/pkg/modules/background/handler" + "io" "xorm.io/xorm" "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/models" + "code.vikunja.io/api/pkg/modules/background/handler" "code.vikunja.io/api/pkg/user" ) @@ -212,7 +211,7 @@ func insertFromStructure(s *xorm.Session, str []*models.NamespaceWithListsAndTas // Check if we have a file to create if len(a.File.FileContent) > 0 { a.TaskID = t.ID - fr := ioutil.NopCloser(bytes.NewReader(a.File.FileContent)) + fr := io.NopCloser(bytes.NewReader(a.File.FileContent)) err = a.NewAttachment(s, fr, a.File.Name, a.File.Size, user) if err != nil { return diff --git a/pkg/modules/migration/todoist/todoist_test.go b/pkg/modules/migration/todoist/todoist_test.go index 3b815280..1c6b383c 100644 --- a/pkg/modules/migration/todoist/todoist_test.go +++ b/pkg/modules/migration/todoist/todoist_test.go @@ -17,7 +17,7 @@ package todoist import ( - "io/ioutil" + "os" "strconv" "testing" "time" @@ -47,7 +47,7 @@ func TestConvertTodoistToVikunja(t *testing.T) { dueTimeWithTime = dueTimeWithTime.In(config.GetTimeZone()) nilTime, err := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00Z") assert.NoError(t, err) - exampleFile, err := ioutil.ReadFile(config.ServiceRootpath.GetString() + "/pkg/modules/migration/wunderlist/testimage.jpg") + exampleFile, err := os.ReadFile(config.ServiceRootpath.GetString() + "/pkg/modules/migration/wunderlist/testimage.jpg") assert.NoError(t, err) makeTestItem := func(id, projectId int64, hasDueDate, hasLabels, done bool) *item { diff --git a/pkg/modules/migration/trello/trello_test.go b/pkg/modules/migration/trello/trello_test.go index efb02bcf..e34b5de7 100644 --- a/pkg/modules/migration/trello/trello_test.go +++ b/pkg/modules/migration/trello/trello_test.go @@ -18,7 +18,7 @@ package trello import ( "bytes" - "io/ioutil" + "os" "testing" "time" @@ -36,7 +36,7 @@ func TestConvertTrelloToVikunja(t *testing.T) { time1, err := time.Parse(time.RFC3339Nano, "2014-09-26T08:25:05Z") assert.NoError(t, err) - exampleFile, err := ioutil.ReadFile(config.ServiceRootpath.GetString() + "/pkg/modules/migration/wunderlist/testimage.jpg") + exampleFile, err := os.ReadFile(config.ServiceRootpath.GetString() + "/pkg/modules/migration/wunderlist/testimage.jpg") assert.NoError(t, err) trelloData := []*trello.Board{ diff --git a/pkg/modules/migration/wunderlist/wunderlist_test.go b/pkg/modules/migration/wunderlist/wunderlist_test.go index 3385ac79..2b27260d 100644 --- a/pkg/modules/migration/wunderlist/wunderlist_test.go +++ b/pkg/modules/migration/wunderlist/wunderlist_test.go @@ -17,7 +17,7 @@ package wunderlist import ( - "io/ioutil" + "os" "strconv" "testing" "time" @@ -46,7 +46,7 @@ func TestWunderlistParsing(t *testing.T) { assert.NoError(t, err) time4 = time4.In(config.GetTimeZone()) - exampleFile, err := ioutil.ReadFile(config.ServiceRootpath.GetString() + "/pkg/modules/migration/wunderlist/testimage.jpg") + exampleFile, err := os.ReadFile(config.ServiceRootpath.GetString() + "/pkg/modules/migration/wunderlist/testimage.jpg") assert.NoError(t, err) createTestTask := func(id, listID int, done bool) *task { diff --git a/pkg/routes/caldav/handler.go b/pkg/routes/caldav/handler.go index 8d748130..a800343f 100644 --- a/pkg/routes/caldav/handler.go +++ b/pkg/routes/caldav/handler.go @@ -19,7 +19,7 @@ package caldav import ( "bytes" "fmt" - "io/ioutil" + "io" "reflect" "strconv" "strings" @@ -61,9 +61,9 @@ func ListHandler(c echo.Context) error { } // Try to parse a task from the request payload - body, _ := ioutil.ReadAll(c.Request().Body) + body, _ := io.ReadAll(c.Request().Body) // Restore the io.ReadCloser to its original state - c.Request().Body = ioutil.NopCloser(bytes.NewBuffer(body)) + c.Request().Body = io.NopCloser(bytes.NewBuffer(body)) // Parse it vtodo := string(body) if vtodo != "" && strings.HasPrefix(vtodo, `BEGIN:VCALENDAR`) { @@ -127,9 +127,9 @@ func PrincipalHandler(c echo.Context) error { } // Try to parse a task from the request payload - body, _ := ioutil.ReadAll(c.Request().Body) + body, _ := io.ReadAll(c.Request().Body) // Restore the io.ReadCloser to its original state - c.Request().Body = ioutil.NopCloser(bytes.NewBuffer(body)) + c.Request().Body = io.NopCloser(bytes.NewBuffer(body)) log.Debugf("[CALDAV] Request Body: %v\n", string(body)) log.Debugf("[CALDAV] Request Headers: %v\n", c.Request().Header) @@ -157,9 +157,9 @@ func EntryHandler(c echo.Context) error { } // Try to parse a task from the request payload - body, _ := ioutil.ReadAll(c.Request().Body) + body, _ := io.ReadAll(c.Request().Body) // Restore the io.ReadCloser to its original state - c.Request().Body = ioutil.NopCloser(bytes.NewBuffer(body)) + c.Request().Body = io.NopCloser(bytes.NewBuffer(body)) log.Debugf("[CALDAV] Request Body: %v\n", string(body)) log.Debugf("[CALDAV] Request Headers: %v\n", c.Request().Header)