[#638] Update to Go 1.16

Changes:

  * replace `iotuil` elements with the ones from `os` package;
  * replace `os.Filemode` with `fs.FileMode`;
  * use `signal.NotifyContext` instead of `NewGracefulContext` (removed).

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-28 17:01:31 +03:00 committed by Leonard Lyubich
parent 61f48a2736
commit 56d4410913
30 changed files with 74 additions and 105 deletions

View file

@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
go: [ '1.14.x', '1.15.x', '1.16.x' ] go: [ '1.16.x' ]
steps: steps:
- name: Setup go - name: Setup go
uses: actions/setup-go@v2 uses: actions/setup-go@v2

View file

@ -1,4 +1,4 @@
FROM golang:1.14-alpine as basebuilder FROM golang:1.16-alpine as basebuilder
RUN apk add --update make bash RUN apk add --update make bash
FROM basebuilder as builder FROM basebuilder as builder

View file

@ -1,4 +1,4 @@
FROM golang:1.14-alpine as basebuilder FROM golang:1.16-alpine as basebuilder
RUN apk add --update make bash RUN apk add --update make bash
FROM basebuilder as builder FROM basebuilder as builder

View file

@ -1,4 +1,4 @@
FROM golang:1.14-alpine as basebuilder FROM golang:1.16-alpine as basebuilder
RUN apk add --update make bash RUN apk add --update make bash
FROM basebuilder as builder FROM basebuilder as builder

View file

@ -1,4 +1,4 @@
FROM golang:1.14-alpine as basebuilder FROM golang:1.16-alpine as basebuilder
RUN apk add --update make bash RUN apk add --update make bash
FROM basebuilder as builder FROM basebuilder as builder

View file

@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"math" "math"
"os" "os"
"strconv" "strconv"
@ -339,7 +338,7 @@ var getContainerInfoCmd = &cobra.Command{
) )
if containerPathFrom != "" { if containerPathFrom != "" {
data, err := ioutil.ReadFile(containerPathFrom) data, err := os.ReadFile(containerPathFrom)
if err != nil { if err != nil {
cmd.PrintErrln(fmt.Errorf("can't read file: %w", err)) cmd.PrintErrln(fmt.Errorf("can't read file: %w", err))
return return
@ -398,7 +397,7 @@ var getContainerInfoCmd = &cobra.Command{
} }
} }
err = ioutil.WriteFile(containerPathTo, data, 0644) err = os.WriteFile(containerPathTo, data, 0644)
if err != nil { if err != nil {
cmd.PrintErrln(fmt.Errorf("can't write container to file: %w", err)) cmd.PrintErrln(fmt.Errorf("can't write container to file: %w", err))
return return
@ -472,7 +471,7 @@ var getExtendedACLCmd = &cobra.Command{
cmd.Println("Signature:") cmd.Println("Signature:")
printJSONMarshaler(cmd, sig, "signature") printJSONMarshaler(cmd, sig, "signature")
if err = ioutil.WriteFile(containerPathTo, data, 0644); err != nil { if err = os.WriteFile(containerPathTo, data, 0644); err != nil {
cmd.PrintErrln(err) cmd.PrintErrln(err)
} }
}, },
@ -636,7 +635,7 @@ func getSessionToken(path string) (*session.Token, error) {
var tok *session.Token var tok *session.Token
if path != "" { if path != "" {
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -661,7 +660,7 @@ func parseContainerPolicy(policyString string) (*netmap.PlacementPolicy, error)
if err == nil { if err == nil {
printVerbose("Reading placement policy from file: %s", policyString) printVerbose("Reading placement policy from file: %s", policyString)
data, err := ioutil.ReadFile(policyString) data, err := os.ReadFile(policyString)
if err != nil { if err != nil {
return nil, fmt.Errorf("can't read file with placement policy: %w", err) return nil, fmt.Errorf("can't read file with placement policy: %w", err)
} }
@ -839,7 +838,7 @@ func parseEACL(eaclPath string) (*eacl.Table, error) {
printVerbose("Reading EACL from file: %s", eaclPath) printVerbose("Reading EACL from file: %s", eaclPath)
data, err := ioutil.ReadFile(eaclPath) data, err := os.ReadFile(eaclPath)
if err != nil { if err != nil {
return nil, fmt.Errorf("can't read file with EACL: %w", err) return nil, fmt.Errorf("can't read file with EACL: %w", err)
} }

View file

@ -7,7 +7,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math" "math"
"os" "os"
"path/filepath" "path/filepath"
@ -638,7 +637,7 @@ func parseSearchFilters(cmd *cobra.Command) (object.SearchFilters, error) {
default: default:
return nil, fmt.Errorf("invalid field number: %d", len(words)) return nil, fmt.Errorf("invalid field number: %d", len(words))
case 1: case 1:
data, err := ioutil.ReadFile(words[0]) data, err := os.ReadFile(words[0])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -808,7 +807,7 @@ func saveAndPrintHeader(cmd *cobra.Command, obj *object.Object, filename string)
cmd.Println(string(bs)) cmd.Println(string(bs))
return nil return nil
} }
err := ioutil.WriteFile(filename, bs, os.ModePerm) err := os.WriteFile(filename, bs, os.ModePerm)
if err != nil { if err != nil {
return err return err
} }
@ -906,7 +905,7 @@ func getBearerToken(cmd *cobra.Command, flagname string) (*token.BearerToken, er
return nil, nil return nil, nil
} }
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return nil, fmt.Errorf("can't read bearer token file: %w", err) return nil, fmt.Errorf("can't read bearer token file: %w", err)
} }

View file

@ -5,7 +5,6 @@ import (
"crypto/tls" "crypto/tls"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -195,7 +194,7 @@ func getKey() (*ecdsa.PrivateKey, error) {
} }
func getKeyFromFile(keyPath string) (*ecdsa.PrivateKey, error) { func getKeyFromFile(keyPath string) (*ecdsa.PrivateKey, error) {
data, err := ioutil.ReadFile(keyPath) data, err := os.ReadFile(keyPath)
if err != nil { if err != nil {
return nil, fmt.Errorf("%w: %v", errInvalidKey, err) return nil, fmt.Errorf("%w: %v", errInvalidKey, err)
} }

View file

@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"strconv" "strconv"
"time" "time"
@ -303,7 +302,7 @@ func signBearerToken(cmd *cobra.Command, _ []string) {
return return
} }
err = ioutil.WriteFile(to, data, 0644) err = os.WriteFile(to, data, 0644)
if err != nil { if err != nil {
cmd.PrintErrln(fmt.Errorf("can't write signed bearer token to file: %w", err)) cmd.PrintErrln(fmt.Errorf("can't write signed bearer token to file: %w", err))
return return
@ -349,7 +348,7 @@ func signSessionToken(cmd *cobra.Command, _ []string) {
return return
} }
err = ioutil.WriteFile(to, data, 0644) err = os.WriteFile(to, data, 0644)
if err != nil { if err != nil {
cmd.PrintErrln(fmt.Errorf("can't write signed session token to %s: %w", to, err)) cmd.PrintErrln(fmt.Errorf("can't write signed session token to %s: %w", to, err))
return return
@ -389,7 +388,7 @@ func convertEACLTable(cmd *cobra.Command, _ []string) {
return return
} }
err = ioutil.WriteFile(to, data, 0644) err = os.WriteFile(to, data, 0644)
if err != nil { if err != nil {
cmd.PrintErrln(fmt.Errorf("can't write exteded ACL table to file: %w", err)) cmd.PrintErrln(fmt.Errorf("can't write exteded ACL table to file: %w", err))
return return
@ -486,7 +485,7 @@ func keyerGenerate(filename string, d *keyer.Dashboard) error {
} }
if filename != "" { if filename != "" {
return ioutil.WriteFile(filename, key, 0600) return os.WriteFile(filename, key, 0600)
} }
return nil return nil
@ -502,7 +501,7 @@ func fileExists(filename string) bool {
} }
func keyerParseFile(filename string, d *keyer.Dashboard) error { func keyerParseFile(filename string, d *keyer.Dashboard) error {
data, err := ioutil.ReadFile(filename) data, err := os.ReadFile(filename)
if err != nil { if err != nil {
return fmt.Errorf("can't open %v file: %w", filename, err) return fmt.Errorf("can't open %v file: %w", filename, err)
} }

View file

@ -1,16 +1,18 @@
package main package main
import ( import (
"context"
"flag" "flag"
"fmt" "fmt"
"net/http" "net/http"
"os" "os"
"os/signal"
"strings" "strings"
"syscall"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neofs-node/misc" "github.com/nspcc-dev/neofs-node/misc"
"github.com/nspcc-dev/neofs-node/pkg/innerring" "github.com/nspcc-dev/neofs-node/pkg/innerring"
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
httputil "github.com/nspcc-dev/neofs-node/pkg/util/http" httputil "github.com/nspcc-dev/neofs-node/pkg/util/http"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
@ -58,7 +60,9 @@ func main() {
log, err := logger.NewLogger(logPrm) log, err := logger.NewLogger(logPrm)
exitErr(err) exitErr(err)
ctx := grace.NewGracefulContext(log) ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
defer cancel()
intErr := make(chan error) // internal inner ring errors intErr := make(chan error) // internal inner ring errors
httpServers := initHTTPServers(cfg) httpServers := initHTTPServers(cfg)

View file

@ -1,7 +1,7 @@
package engineconfig_test package engineconfig_test
import ( import (
"os" "io/fs"
"testing" "testing"
"time" "time"
@ -47,7 +47,7 @@ func TestEngineSection(t *testing.T) {
require.EqualValues(t, 555, wc.WorkersNumber()) require.EqualValues(t, 555, wc.WorkersNumber())
require.Equal(t, "tmp/0/meta", meta.Path()) require.Equal(t, "tmp/0/meta", meta.Path())
require.Equal(t, os.FileMode(0700), meta.Perm()) require.Equal(t, fs.FileMode(0700), meta.Perm())
require.Equal(t, "tmp/0/blob", blob.Path()) require.Equal(t, "tmp/0/blob", blob.Path())
require.EqualValues(t, 0666, blob.Perm()) require.EqualValues(t, 0666, blob.Perm())
@ -73,7 +73,7 @@ func TestEngineSection(t *testing.T) {
require.EqualValues(t, 556, wc.WorkersNumber()) require.EqualValues(t, 556, wc.WorkersNumber())
require.Equal(t, "tmp/1/meta", meta.Path()) require.Equal(t, "tmp/1/meta", meta.Path())
require.Equal(t, os.FileMode(0701), meta.Perm()) require.Equal(t, fs.FileMode(0701), meta.Perm())
require.Equal(t, "tmp/1/blob", blob.Path()) require.Equal(t, "tmp/1/blob", blob.Path())
require.EqualValues(t, 0667, blob.Perm()) require.EqualValues(t, 0667, blob.Perm())

View file

@ -1,7 +1,7 @@
package blobstorconfig package blobstorconfig
import ( import (
"os" "io/fs"
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
blobovniczaconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/blobstor/blobovnicza" blobovniczaconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/blobstor/blobovnicza"
@ -45,10 +45,10 @@ func (x *Config) Path() string {
return p return p
} }
// Perm returns value of "perm" config parameter as a os.FileMode. // Perm returns value of "perm" config parameter as a fs.FileMode.
// //
// Returns PermDefault if value is not a non-zero number. // Returns PermDefault if value is not a non-zero number.
func (x *Config) Perm() os.FileMode { func (x *Config) Perm() fs.FileMode {
p := config.UintSafe( p := config.UintSafe(
(*config.Config)(x), (*config.Config)(x),
"perm", "perm",
@ -58,7 +58,7 @@ func (x *Config) Perm() os.FileMode {
p = PermDefault p = PermDefault
} }
return os.FileMode(p) return fs.FileMode(p)
} }
// ShallowDepth returns value of "shallow_depth" config parameter. // ShallowDepth returns value of "shallow_depth" config parameter.

View file

@ -1,7 +1,7 @@
package metabaseconfig package metabaseconfig
import ( import (
"os" "io/fs"
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
) )
@ -37,10 +37,10 @@ func (x *Config) Path() string {
return p return p
} }
// Perm returns value of "perm" config parameter as a os.FileMode. // Perm returns value of "perm" config parameter as a fs.FileMode.
// //
// Returns PermDefault if value is not a positive number. // Returns PermDefault if value is not a positive number.
func (x *Config) Perm() os.FileMode { func (x *Config) Perm() fs.FileMode {
p := config.UintSafe( p := config.UintSafe(
(*config.Config)(x), (*config.Config)(x),
"perm", "perm",
@ -50,5 +50,5 @@ func (x *Config) Perm() os.FileMode {
p = PermDefault p = PermDefault
} }
return os.FileMode(p) return fs.FileMode(p)
} }

View file

@ -3,7 +3,7 @@ package nodeconfig
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "os"
"strconv" "strconv"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
@ -35,7 +35,7 @@ func Key(c *config.Config) *keys.PrivateKey {
err error err error
data []byte data []byte
) )
if data, err = ioutil.ReadFile(v); err == nil { if data, err = os.ReadFile(v); err == nil {
key, err = keys.NewPrivateKeyFromBytes(data) key, err = keys.NewPrivateKeyFromBytes(data)
} }

View file

@ -5,10 +5,11 @@ import (
"flag" "flag"
"fmt" "fmt"
"log" "log"
"os/signal"
"syscall"
"github.com/nspcc-dev/neofs-node/misc" "github.com/nspcc-dev/neofs-node/misc"
"github.com/nspcc-dev/neofs-node/pkg/services/control" "github.com/nspcc-dev/neofs-node/pkg/services/control"
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -48,7 +49,7 @@ func main() {
} }
func initApp(c *cfg) { func initApp(c *cfg) {
c.ctx, c.ctxCancel = context.WithCancel(grace.NewGracefulContext(nil)) c.ctx, c.ctxCancel = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
initGRPC(c) initGRPC(c)

2
go.mod
View file

@ -1,6 +1,6 @@
module github.com/nspcc-dev/neofs-node module github.com/nspcc-dev/neofs-node
go 1.14 go 1.16
require ( require (
github.com/golang/protobuf v1.5.2 github.com/golang/protobuf v1.5.2

3
go.sum
View file

@ -226,7 +226,6 @@ github.com/klauspost/compress v1.13.1/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
@ -335,7 +334,6 @@ github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@ -538,7 +536,6 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q=

View file

@ -1,6 +1,7 @@
package blobovnicza package blobovnicza
import ( import (
"io/fs"
"os" "os"
"time" "time"
@ -33,7 +34,7 @@ type cfg struct {
} }
type boltDBCfg struct { type boltDBCfg struct {
perm os.FileMode perm fs.FileMode
path string path string
@ -77,7 +78,7 @@ func WithPath(path string) Option {
// WithPermissions returns option to specify permission bits // WithPermissions returns option to specify permission bits
// of Blobovnicza's system path. // of Blobovnicza's system path.
func WithPermissions(perm os.FileMode) Option { func WithPermissions(perm fs.FileMode) Option {
return func(c *cfg) { return func(c *cfg) {
c.perm = perm c.perm = perm
} }

View file

@ -2,7 +2,7 @@ package blobstor
import ( import (
"encoding/hex" "encoding/hex"
"os" "io/fs"
"path" "path"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
@ -145,7 +145,7 @@ func WithRootPath(rootDir string) Option {
// WithRootPerm returns option to set permission // WithRootPerm returns option to set permission
// bits of the fs tree. // bits of the fs tree.
func WithRootPerm(perm os.FileMode) Option { func WithRootPerm(perm fs.FileMode) Option {
return func(c *cfg) { return func(c *cfg) {
c.fsTree.Permissions = perm c.fsTree.Permissions = perm
c.blzOpts = append(c.blzOpts, blobovnicza.WithPermissions(perm)) c.blzOpts = append(c.blzOpts, blobovnicza.WithPermissions(perm))

View file

@ -3,7 +3,7 @@ package fstree
import ( import (
"crypto/sha256" "crypto/sha256"
"errors" "errors"
"io/ioutil" "io/fs"
"os" "os"
"path" "path"
"strings" "strings"
@ -23,7 +23,7 @@ type FSTree struct {
// Info groups the information about file storage. // Info groups the information about file storage.
type Info struct { type Info struct {
// Permission bits of the root directory. // Permission bits of the root directory.
Permissions os.FileMode Permissions fs.FileMode
// Full path to the root directory. // Full path to the root directory.
RootPath string RootPath string
@ -73,7 +73,7 @@ func (t *FSTree) Iterate(f func(addr *objectSDK.Address, data []byte) error) err
func (t *FSTree) iterate(depth int, curPath []string, f func(*objectSDK.Address, []byte) error) error { func (t *FSTree) iterate(depth int, curPath []string, f func(*objectSDK.Address, []byte) error) error {
curName := strings.Join(curPath[1:], "") curName := strings.Join(curPath[1:], "")
des, err := ioutil.ReadDir(path.Join(curPath...)) des, err := os.ReadDir(path.Join(curPath...))
if err != nil { if err != nil {
return err return err
} }
@ -101,7 +101,7 @@ func (t *FSTree) iterate(depth int, curPath []string, f func(*objectSDK.Address,
continue continue
} }
data, err := ioutil.ReadFile(path.Join(curPath...)) data, err := os.ReadFile(path.Join(curPath...))
if err != nil { if err != nil {
return err return err
} }
@ -161,7 +161,7 @@ func (t *FSTree) Put(addr *objectSDK.Address, data []byte) error {
return err return err
} }
return ioutil.WriteFile(p, data, t.Permissions) return os.WriteFile(p, data, t.Permissions)
} }
// Get returns object from storage by address. // Get returns object from storage by address.
@ -172,5 +172,5 @@ func (t *FSTree) Get(addr *objectSDK.Address) ([]byte, error) {
return nil, ErrFileNotFound return nil, ErrFileNotFound
} }
return ioutil.ReadFile(p) return os.ReadFile(p)
} }

View file

@ -3,6 +3,7 @@ package meta
import ( import (
"encoding/binary" "encoding/binary"
"encoding/hex" "encoding/hex"
"io/fs"
"os" "os"
"strconv" "strconv"
@ -132,7 +133,7 @@ func WithPath(path string) Option {
// WithPermissions returns option to specify permission bits // WithPermissions returns option to specify permission bits
// of Metabase system path. // of Metabase system path.
func WithPermissions(perm os.FileMode) Option { func WithPermissions(perm fs.FileMode) Option {
return func(c *cfg) { return func(c *cfg) {
c.info.Permission = perm c.info.Permission = perm
} }

View file

@ -1,7 +1,7 @@
package meta package meta
import ( import (
"os" "io/fs"
) )
// Info groups the information about DB. // Info groups the information about DB.
@ -10,7 +10,7 @@ type Info struct {
Path string Path string
// Permission of database file. // Permission of database file.
Permission os.FileMode Permission fs.FileMode
} }
// DumpInfo returns information about the DB. // DumpInfo returns information about the DB.

View file

@ -1,32 +0,0 @@
package grace
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"go.uber.org/zap"
)
// NewGracefulContext returns grace context that cancelled by sigint,
// sigterm and sighup.
func NewGracefulContext(l *zap.Logger) context.Context {
ctx, cancel := context.WithCancel(context.Background())
go func() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
sig := <-ch
if l != nil {
l.Info("received signal",
zap.String("signal", sig.String()))
} else {
fmt.Printf("received signal %s\n", sig)
}
cancel()
}()
return ctx
}

View file

@ -2,7 +2,7 @@ package airportsdb
import ( import (
"fmt" "fmt"
"os" "io/fs"
"sync" "sync"
) )
@ -41,7 +41,7 @@ type DB struct {
type pathMode struct { type pathMode struct {
path string path string
mode os.FileMode mode fs.FileMode
} }
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"

View file

@ -1,19 +1,19 @@
package airportsdb package airportsdb
import ( import (
"os" "io/fs"
) )
// Option sets an optional parameter of DB. // Option sets an optional parameter of DB.
type Option func(*options) type Option func(*options)
type options struct { type options struct {
airportMode, countryMode os.FileMode airportMode, countryMode fs.FileMode
} }
func defaultOpts() *options { func defaultOpts() *options {
return &options{ return &options{
airportMode: os.ModePerm, // 0777 airportMode: fs.ModePerm, // 0777
countryMode: os.ModePerm, // 0777 countryMode: fs.ModePerm, // 0777
} }
} }

View file

@ -2,7 +2,7 @@ package locodebolt
import ( import (
"fmt" "fmt"
"os" "io/fs"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )
@ -34,7 +34,7 @@ type Prm struct {
type DB struct { type DB struct {
path string path string
mode os.FileMode mode fs.FileMode
boltOpts *bbolt.Options boltOpts *bbolt.Options

View file

@ -1,6 +1,7 @@
package locodebolt package locodebolt
import ( import (
"io/fs"
"os" "os"
"time" "time"
@ -11,7 +12,7 @@ import (
type Option func(*options) type Option func(*options)
type options struct { type options struct {
mode os.FileMode mode fs.FileMode
boltOpts *bbolt.Options boltOpts *bbolt.Options
} }

View file

@ -2,7 +2,7 @@ package continentsdb
import ( import (
"fmt" "fmt"
"io/ioutil" "os"
locodedb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db" locodedb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db"
"github.com/paulmach/orb" "github.com/paulmach/orb"
@ -53,7 +53,7 @@ func (db *DB) PointContinent(point *locodedb.Point) (*locodedb.Continent, error)
} }
func (db *DB) init() error { func (db *DB) init() error {
data, err := ioutil.ReadFile(db.path) data, err := os.ReadFile(db.path)
if err != nil { if err != nil {
return fmt.Errorf("could not read data file: %w", err) return fmt.Errorf("could not read data file: %w", err)
} }

View file

@ -1,14 +1,14 @@
package csvlocode package csvlocode
import ( import (
"os" "io/fs"
) )
// Option sets an optional parameter of Table. // Option sets an optional parameter of Table.
type Option func(*options) type Option func(*options)
type options struct { type options struct {
mode os.FileMode mode fs.FileMode
extraPaths []string extraPaths []string
} }

View file

@ -2,7 +2,7 @@ package csvlocode
import ( import (
"fmt" "fmt"
"os" "io/fs"
"sync" "sync"
) )
@ -32,7 +32,7 @@ type Prm struct {
type Table struct { type Table struct {
paths []string paths []string
mode os.FileMode mode fs.FileMode
subDivPath string subDivPath string