From 53d15d329e43608e24ef297d074c60bf598935b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Thu, 8 Dec 2022 14:44:53 +0100 Subject: [PATCH] remove deprecated use of ioutil (#5205) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer Signed-off-by: Jörn Friedrich Dreyer --- docs/helpers/adoc-generator.go.tmpl | 3 +-- docs/helpers/configenvextractor.go | 3 +-- .../environment-variable-docs-generator.go.tmpl | 3 +-- ocis-pkg/ldap/ldap.go | 3 +-- ocis-pkg/log/logrus_wrapper.go | 6 +++--- ocis-pkg/service/grpc/client.go | 4 ++-- ocis/pkg/init/init.go | 3 +-- services/gateway/pkg/revaconfig/config.go | 4 ++-- services/graph/pkg/service/v0/driveitems_test.go | 4 ++-- services/graph/pkg/service/v0/graph_test.go | 7 +++---- services/graph/pkg/service/v0/groups_test.go | 14 +++++++------- services/graph/pkg/service/v0/service.go | 4 ++-- services/graph/pkg/service/v0/users_test.go | 14 +++++++------- services/idp/pkg/service/v0/service.go | 6 +++--- services/proxy/pkg/middleware/authentication.go | 3 +-- services/proxy/pkg/middleware/oidc_auth.go | 4 ++-- services/proxy/pkg/proxy/proxy.go | 4 ++-- services/proxy/pkg/proxy/proxy_integration_test.go | 5 ++--- .../settings/pkg/store/filesystem/assignments.go | 3 +-- services/settings/pkg/store/filesystem/bundles.go | 4 ++-- services/settings/pkg/store/filesystem/io.go | 4 ++-- services/settings/pkg/store/filesystem/values.go | 6 +++--- services/store/pkg/service/v0/service.go | 9 ++++----- services/web/pkg/command/server.go | 4 ++-- 24 files changed, 57 insertions(+), 67 deletions(-) diff --git a/docs/helpers/adoc-generator.go.tmpl b/docs/helpers/adoc-generator.go.tmpl index 7ab267dd2..0ed23f86e 100644 --- a/docs/helpers/adoc-generator.go.tmpl +++ b/docs/helpers/adoc-generator.go.tmpl @@ -2,7 +2,6 @@ package main import ( "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -40,7 +39,7 @@ type templateData struct { func main() { fmt.Println("Generating adoc documentation for environment variables:") -content, err := ioutil.ReadFile("../../docs/templates/ADOC.tmpl") +content, err := os.ReadFile("../../docs/templates/ADOC.tmpl") if err != nil { log.Fatal(err) } diff --git a/docs/helpers/configenvextractor.go b/docs/helpers/configenvextractor.go index b3fcbffd6..0e9f2e4b7 100644 --- a/docs/helpers/configenvextractor.go +++ b/docs/helpers/configenvextractor.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "io/ioutil" "log" "os" "os/exec" @@ -41,7 +40,7 @@ func main() { } func GenerateIntermediateCode(templatePath string, intermediateCodePath string, paths []string) { - content, err := ioutil.ReadFile(templatePath) + content, err := os.ReadFile(templatePath) if err != nil { log.Fatal(err) } diff --git a/docs/helpers/environment-variable-docs-generator.go.tmpl b/docs/helpers/environment-variable-docs-generator.go.tmpl index af31091ab..475a6d760 100644 --- a/docs/helpers/environment-variable-docs-generator.go.tmpl +++ b/docs/helpers/environment-variable-docs-generator.go.tmpl @@ -3,7 +3,6 @@ package main import ( "fmt" "html" - "io/ioutil" "log" "os" "path/filepath" @@ -24,7 +23,7 @@ type ConfigField struct { func main() { fmt.Println("Generating documentation for environment variables:") -content, err := ioutil.ReadFile("../../docs/templates/CONFIGURATION.tmpl") +content, err := os.ReadFile("../../docs/templates/CONFIGURATION.tmpl") if err != nil { log.Fatal(err) } diff --git a/ocis-pkg/ldap/ldap.go b/ocis-pkg/ldap/ldap.go index cfa452f1a..194ddb42e 100644 --- a/ocis-pkg/ldap/ldap.go +++ b/ocis-pkg/ldap/ldap.go @@ -3,7 +3,6 @@ package ldap import ( "crypto/x509" "errors" - "io/ioutil" "os" "strings" "time" @@ -39,7 +38,7 @@ func WaitForCA(log log.Logger, insecure bool, caCert string) error { // Check if this actually is a CA cert. We need to retry here as well // as the file might exist already, but have no contents yet. certs := x509.NewCertPool() - pemData, err := ioutil.ReadFile(caCert) + pemData, err := os.ReadFile(caCert) if err != nil { log.Debug().Err(err).Str("LDAP CACert", caCert).Msg("Error reading CA") } else if !certs.AppendCertsFromPEM(pemData) { diff --git a/ocis-pkg/log/logrus_wrapper.go b/ocis-pkg/log/logrus_wrapper.go index e4c29240d..3a4a9d68a 100644 --- a/ocis-pkg/log/logrus_wrapper.go +++ b/ocis-pkg/log/logrus_wrapper.go @@ -1,7 +1,7 @@ package log import ( - "io/ioutil" + "io" "github.com/rs/zerolog" "github.com/sirupsen/logrus" @@ -28,7 +28,7 @@ type LogrusWrapper struct { // underlying zerolog via hooks. func LogrusWrap(zr zerolog.Logger) *logrus.Logger { lr := logrus.New() - lr.SetOutput(ioutil.Discard) + lr.SetOutput(io.Discard) lr.SetLevel(logrusLevel(zr.GetLevel())) lr.AddHook(&LogrusWrapper{ zeroLog: &zr, @@ -52,7 +52,7 @@ func (h *LogrusWrapper) Fire(entry *logrus.Entry) error { return nil } -//Convert logrus fields to zerolog +// Convert logrus fields to zerolog func zeroLogFields(fields logrus.Fields) map[string]interface{} { fm := make(map[string]interface{}) for k, v := range fields { diff --git a/ocis-pkg/service/grpc/client.go b/ocis-pkg/service/grpc/client.go index cee6a1fb2..8309e80cd 100644 --- a/ocis-pkg/service/grpc/client.go +++ b/ocis-pkg/service/grpc/client.go @@ -4,7 +4,7 @@ import ( "crypto/tls" "crypto/x509" "errors" - "io/ioutil" + "os" "sync" mgrpcc "github.com/go-micro/plugins/v4/client/grpc" @@ -68,7 +68,7 @@ func Configure(opts ...ClientOption) error { // Note: If caCert is empty we use the system's default set of trusted CAs if options.caCert != "" { certs := x509.NewCertPool() - pemData, err := ioutil.ReadFile(options.caCert) + pemData, err := os.ReadFile(options.caCert) if err != nil { outerr = err return diff --git a/ocis/pkg/init/init.go b/ocis/pkg/init/init.go index e039e5c74..3663172a0 100644 --- a/ocis/pkg/init/init.go +++ b/ocis/pkg/init/init.go @@ -3,7 +3,6 @@ package init import ( "fmt" "io" - "io/ioutil" "log" "os" "path" @@ -359,7 +358,7 @@ func CreateConfig(insecure, forceOverwrite bool, configPath, adminPassword strin return fmt.Errorf("could not marshall config into yaml: %s", err) } targetPath := path.Join(configPath, configFilename) - err = ioutil.WriteFile(targetPath, yamlOutput, 0600) + err = os.WriteFile(targetPath, yamlOutput, 0600) if err != nil { return err } diff --git a/services/gateway/pkg/revaconfig/config.go b/services/gateway/pkg/revaconfig/config.go index 6278dbbb5..bf0deaa7b 100644 --- a/services/gateway/pkg/revaconfig/config.go +++ b/services/gateway/pkg/revaconfig/config.go @@ -2,7 +2,7 @@ package revaconfig import ( "encoding/json" - "io/ioutil" + "os" "strings" "github.com/owncloud/ocis/v2/ocis-pkg/log" @@ -111,7 +111,7 @@ func spacesProviders(cfg *config.Config, logger log.Logger) map[string]map[strin // check if the rules have to be read from a json file if cfg.StorageRegistry.JSON != "" { - data, err := ioutil.ReadFile(cfg.StorageRegistry.JSON) + data, err := os.ReadFile(cfg.StorageRegistry.JSON) if err != nil { logger.Error().Err(err).Msg("Failed to read storage registry rules from JSON file: " + cfg.StorageRegistry.JSON) return nil diff --git a/services/graph/pkg/service/v0/driveitems_test.go b/services/graph/pkg/service/v0/driveitems_test.go index 5198477b7..c29952ee0 100644 --- a/services/graph/pkg/service/v0/driveitems_test.go +++ b/services/graph/pkg/service/v0/driveitems_test.go @@ -3,7 +3,7 @@ package svc_test import ( "context" "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" "time" @@ -113,7 +113,7 @@ var _ = Describe("Driveitems", func() { r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/me/drive/root/children", nil) svc.GetRootDriveChildren(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) res := itemsList{} diff --git a/services/graph/pkg/service/v0/graph_test.go b/services/graph/pkg/service/v0/graph_test.go index a1987607d..ea4802da9 100644 --- a/services/graph/pkg/service/v0/graph_test.go +++ b/services/graph/pkg/service/v0/graph_test.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" "time" @@ -825,7 +824,7 @@ var _ = Describe("Graph", func() { svc.GetSingleDrive(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) drive := libregraph.Drive{} @@ -864,7 +863,7 @@ var _ = Describe("Graph", func() { svc.GetSingleDrive(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) drive := libregraph.Drive{} @@ -925,7 +924,7 @@ var _ = Describe("Graph", func() { svc.GetSingleDrive(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) drive := libregraph.Drive{} diff --git a/services/graph/pkg/service/v0/groups_test.go b/services/graph/pkg/service/v0/groups_test.go index 6c91074af..0b8f59c9a 100644 --- a/services/graph/pkg/service/v0/groups_test.go +++ b/services/graph/pkg/service/v0/groups_test.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "errors" - "io/ioutil" + "io" "net/http" "net/http/httptest" @@ -92,7 +92,7 @@ var _ = Describe("Groups", func() { svc.GetGroups(rr, r) Expect(rr.Code).To(Equal(http.StatusBadRequest)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) odataerr := libregraph.OdataError{} @@ -107,7 +107,7 @@ var _ = Describe("Groups", func() { r := httptest.NewRequest(http.MethodGet, "/graph/v1.0/me/groups", nil) svc.GetGroups(rr, r) Expect(rr.Code).To(Equal(http.StatusInternalServerError)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) odataerr := libregraph.OdataError{} @@ -123,7 +123,7 @@ var _ = Describe("Groups", func() { svc.GetGroups(rr, r) Expect(rr.Code).To(Equal(http.StatusInternalServerError)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) odataerr := libregraph.OdataError{} @@ -139,7 +139,7 @@ var _ = Describe("Groups", func() { svc.GetGroups(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) res := service.ListResponse{} @@ -155,7 +155,7 @@ var _ = Describe("Groups", func() { svc.GetGroups(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) res := groupList{} @@ -385,7 +385,7 @@ var _ = Describe("Groups", func() { svc.GetGroupMembers(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) var members []*libregraph.User diff --git a/services/graph/pkg/service/v0/service.go b/services/graph/pkg/service/v0/service.go index ac8f37b27..6e3f67a18 100644 --- a/services/graph/pkg/service/v0/service.go +++ b/services/graph/pkg/service/v0/service.go @@ -3,8 +3,8 @@ package svc import ( "crypto/tls" "crypto/x509" - "io/ioutil" "net/http" + "os" "strconv" "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" @@ -113,7 +113,7 @@ func NewService(opts ...Option) Service { } } certs := x509.NewCertPool() - pemData, err := ioutil.ReadFile(options.Config.Identity.LDAP.CACert) + pemData, err := os.ReadFile(options.Config.Identity.LDAP.CACert) if err != nil { options.Logger.Error().Err(err).Msgf("Error initializing LDAP Backend") return nil diff --git a/services/graph/pkg/service/v0/users_test.go b/services/graph/pkg/service/v0/users_test.go index c09f8e4d7..62ad61455 100644 --- a/services/graph/pkg/service/v0/users_test.go +++ b/services/graph/pkg/service/v0/users_test.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "encoding/json" - "io/ioutil" + "io" "net/http" "net/http/httptest" @@ -125,7 +125,7 @@ var _ = Describe("Users", func() { svc.GetUsers(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) res := userList{} @@ -157,7 +157,7 @@ var _ = Describe("Users", func() { svc.GetUsers(rec, r) Expect(rec.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rec.Body) + data, err := io.ReadAll(rec.Body) Expect(err).ToNot(HaveOccurred()) res := userList{} @@ -238,7 +238,7 @@ var _ = Describe("Users", func() { svc.GetUser(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) responseUser := &libregraph.User{} err = json.Unmarshal(data, &responseUser) @@ -279,7 +279,7 @@ var _ = Describe("Users", func() { svc.GetUser(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) responseUser := &libregraph.User{} err = json.Unmarshal(data, &responseUser) @@ -314,7 +314,7 @@ var _ = Describe("Users", func() { svc.GetUser(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err := ioutil.ReadAll(rr.Body) + data, err := io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) responseUser := &libregraph.User{} err = json.Unmarshal(data, &responseUser) @@ -517,7 +517,7 @@ var _ = Describe("Users", func() { svc.PatchUser(rr, r) Expect(rr.Code).To(Equal(http.StatusOK)) - data, err = ioutil.ReadAll(rr.Body) + data, err = io.ReadAll(rr.Body) Expect(err).ToNot(HaveOccurred()) updatedUser := libregraph.User{} diff --git a/services/idp/pkg/service/v0/service.go b/services/idp/pkg/service/v0/service.go index ce47018cc..82b8d4127 100644 --- a/services/idp/pkg/service/v0/service.go +++ b/services/idp/pkg/service/v0/service.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "net/http" "os" "path" @@ -143,7 +143,7 @@ func createTemporaryClientsConfig(filePath, ocisURL string, clients []config.Cli defer confOnDisk.Close() - err = ioutil.WriteFile(filePath, conf, 0600) + err = os.WriteFile(filePath, conf, 0600) if err != nil { return err } @@ -253,7 +253,7 @@ func (idp IDP) Index() http.HandlerFunc { idp.logger.Fatal().Err(err).Msg("Could not open index template") } - template, err := ioutil.ReadAll(f) + template, err := io.ReadAll(f) if err != nil { idp.logger.Fatal().Err(err).Msg("Could not read index template") } diff --git a/services/proxy/pkg/middleware/authentication.go b/services/proxy/pkg/middleware/authentication.go index 4a436cb3a..a8746b33f 100644 --- a/services/proxy/pkg/middleware/authentication.go +++ b/services/proxy/pkg/middleware/authentication.go @@ -3,7 +3,6 @@ package middleware import ( "fmt" "io" - "io/ioutil" "net/http" "regexp" "strings" @@ -113,7 +112,7 @@ func Authentication(auths []Authenticator, opts ...Option) func(next http.Handle // https://github.com/golang/go/issues/15527 defer r.Body.Close() - _, _ = io.Copy(ioutil.Discard, r.Body) + _, _ = io.Copy(io.Discard, r.Body) } }) } diff --git a/services/proxy/pkg/middleware/oidc_auth.go b/services/proxy/pkg/middleware/oidc_auth.go index f0dabbd75..32f757113 100644 --- a/services/proxy/pkg/middleware/oidc_auth.go +++ b/services/proxy/pkg/middleware/oidc_auth.go @@ -3,7 +3,7 @@ package middleware import ( "context" "encoding/json" - "io/ioutil" + "io" "net/http" "strings" "sync" @@ -181,7 +181,7 @@ func (m *OIDCAuthenticator) getKeyfunc() *keyfunc.JWKS { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { m.Logger.Error().Err(err).Msg("unable to read discovery response body") return nil diff --git a/services/proxy/pkg/proxy/proxy.go b/services/proxy/pkg/proxy/proxy.go index 8b06707b0..4e773ca1f 100644 --- a/services/proxy/pkg/proxy/proxy.go +++ b/services/proxy/pkg/proxy/proxy.go @@ -5,10 +5,10 @@ import ( "crypto/x509" "errors" "fmt" - "io/ioutil" "net" "net/http" "net/http/httputil" + "os" "time" chimiddleware "github.com/go-chi/chi/v5/middleware" @@ -56,7 +56,7 @@ func NewMultiHostReverseProxy(opts ...Option) (*MultiHostReverseProxy, error) { } if options.Config.BackendHTTPSCACert != "" { certs := x509.NewCertPool() - pemData, err := ioutil.ReadFile(options.Config.BackendHTTPSCACert) + pemData, err := os.ReadFile(options.Config.BackendHTTPSCACert) if err != nil { return nil, err } diff --git a/services/proxy/pkg/proxy/proxy_integration_test.go b/services/proxy/pkg/proxy/proxy_integration_test.go index 0f19c3a4a..e26dee243 100644 --- a/services/proxy/pkg/proxy/proxy_integration_test.go +++ b/services/proxy/pkg/proxy/proxy_integration_test.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" "net/url" @@ -133,7 +132,7 @@ func TestProxyIntegration(t *testing.T) { return &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewBufferString(`OK`)), + Body: io.NopCloser(bytes.NewBufferString(`OK`)), Header: make(http.Header), } }) @@ -146,7 +145,7 @@ func TestProxyIntegration(t *testing.T) { t.Errorf("Expected status 200 from proxy-response got %v", rsp.StatusCode) } - resultBody, err := ioutil.ReadAll(rsp.Body) + resultBody, err := io.ReadAll(rsp.Body) if err != nil { t.Fatal("Error reading result body") } diff --git a/services/settings/pkg/store/filesystem/assignments.go b/services/settings/pkg/store/filesystem/assignments.go index 5144d6662..350a04cb1 100644 --- a/services/settings/pkg/store/filesystem/assignments.go +++ b/services/settings/pkg/store/filesystem/assignments.go @@ -2,7 +2,6 @@ package store import ( - "io/ioutil" "os" "path/filepath" @@ -14,7 +13,7 @@ import ( func (s Store) ListRoleAssignments(accountUUID string) ([]*settingsmsg.UserRoleAssignment, error) { var records []*settingsmsg.UserRoleAssignment assignmentsFolder := s.buildFolderPathForRoleAssignments(false) - assignmentFiles, err := ioutil.ReadDir(assignmentsFolder) + assignmentFiles, err := os.ReadDir(assignmentsFolder) if err != nil { return records, nil } diff --git a/services/settings/pkg/store/filesystem/bundles.go b/services/settings/pkg/store/filesystem/bundles.go index 50746fe1d..17bce7bc9 100644 --- a/services/settings/pkg/store/filesystem/bundles.go +++ b/services/settings/pkg/store/filesystem/bundles.go @@ -3,7 +3,7 @@ package store import ( "fmt" - "io/ioutil" + "os" "path/filepath" "sync" @@ -21,7 +21,7 @@ func (s Store) ListBundles(bundleType settingsmsg.Bundle_Type, bundleIDs []strin defer m.RUnlock() bundlesFolder := s.buildFolderPathForBundles(false) - bundleFiles, err := ioutil.ReadDir(bundlesFolder) + bundleFiles, err := os.ReadDir(bundlesFolder) if err != nil { return []*settingsmsg.Bundle{}, nil } diff --git a/services/settings/pkg/store/filesystem/io.go b/services/settings/pkg/store/filesystem/io.go index 38b5f5a6d..5a5cccdaa 100644 --- a/services/settings/pkg/store/filesystem/io.go +++ b/services/settings/pkg/store/filesystem/io.go @@ -1,7 +1,7 @@ package store import ( - "io/ioutil" + "io" "os" "github.com/owncloud/ocis/v2/services/settings/pkg/store/errortypes" @@ -22,7 +22,7 @@ func (s Store) parseRecordFromFile(record proto.Message, filePath string) error } defer file.Close() - b, err := ioutil.ReadAll(file) + b, err := io.ReadAll(file) if err != nil { return err } diff --git a/services/settings/pkg/store/filesystem/values.go b/services/settings/pkg/store/filesystem/values.go index 444398e83..b0a26ebff 100644 --- a/services/settings/pkg/store/filesystem/values.go +++ b/services/settings/pkg/store/filesystem/values.go @@ -3,7 +3,7 @@ package store import ( "fmt" - "io/ioutil" + "os" "path/filepath" "github.com/gofrs/uuid" @@ -16,7 +16,7 @@ import ( // If the accountUUID is not empty, values with an empty or with a matching accountUUID are returned. func (s Store) ListValues(bundleID, accountUUID string) ([]*settingsmsg.Value, error) { valuesFolder := s.buildFolderPathForValues(false) - valueFiles, err := ioutil.ReadDir(valuesFolder) + valueFiles, err := os.ReadDir(valuesFolder) if err != nil { return []*settingsmsg.Value{}, nil } @@ -61,7 +61,7 @@ func (s Store) ReadValue(valueID string) (*settingsmsg.Value, error) { // ReadValueByUniqueIdentifiers tries to find a value given a set of unique identifiers func (s Store) ReadValueByUniqueIdentifiers(accountUUID, settingID string) (*settingsmsg.Value, error) { valuesFolder := s.buildFolderPathForValues(false) - files, err := ioutil.ReadDir(valuesFolder) + files, err := os.ReadDir(valuesFolder) if err != nil { return nil, err } diff --git a/services/store/pkg/service/v0/service.go b/services/store/pkg/service/v0/service.go index 57499d89f..2645342a2 100644 --- a/services/store/pkg/service/v0/service.go +++ b/services/store/pkg/service/v0/service.go @@ -3,7 +3,6 @@ package service import ( "context" "fmt" - "io/ioutil" "os" "path/filepath" @@ -85,7 +84,7 @@ func (s *Service) Read(c context.Context, rreq *storesvc.ReadRequest, rres *stor var data []byte rec := &storemsg.Record{} - data, err := ioutil.ReadFile(file) + data, err := os.ReadFile(file) if err != nil { return merrors.NotFound(s.id, "could not read record") } @@ -129,7 +128,7 @@ func (s *Service) Read(c context.Context, rreq *storesvc.ReadRequest, rres *stor dest := filepath.Join(s.Config.Datapath, "databases", hit.ID) var data []byte - data, err := ioutil.ReadFile(dest) + data, err := os.ReadFile(dest) s.log.Info().Str("path", dest).Interface("hit", hit).Msgf("hit info") if err != nil { s.log.Info().Str("path", dest).Interface("hit", hit).Msgf("file not found") @@ -163,7 +162,7 @@ func (s *Service) Write(c context.Context, wreq *storesvc.WriteRequest, wres *st if err != nil { return err } - err = ioutil.WriteFile(file, bytes, 0600) + err = os.WriteFile(file, bytes, 0600) if err != nil { return merrors.InternalServerError(s.id, "could not write record") } @@ -302,7 +301,7 @@ func (s Service) indexRecords(recordsDir string) (err error) { // read record var data []byte rec := &storemsg.Record{} - data, err = ioutil.ReadFile(kp) + data, err = os.ReadFile(kp) if err != nil { s.log.Error().Err(err).Str("id", id).Msg("could not read record") continue diff --git a/services/web/pkg/command/server.go b/services/web/pkg/command/server.go index 3c430369d..9d7d40e31 100644 --- a/services/web/pkg/command/server.go +++ b/services/web/pkg/command/server.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "os" "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" @@ -36,7 +36,7 @@ func Server(cfg *config.Config) *cli.Command { // actually read the contents of the config file and override defaults if cfg.File != "" { - contents, err := ioutil.ReadFile(cfg.File) + contents, err := os.ReadFile(cfg.File) if err != nil { logger.Err(err).Msg("error opening config file") return err