forked from TrueCloudLab/frostfs-node
[#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:
parent
61f48a2736
commit
56d4410913
30 changed files with 74 additions and 105 deletions
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
|
@ -17,7 +17,7 @@ jobs:
|
|||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
matrix:
|
||||
go: [ '1.14.x', '1.15.x', '1.16.x' ]
|
||||
go: [ '1.16.x' ]
|
||||
steps:
|
||||
- name: Setup go
|
||||
uses: actions/setup-go@v2
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.14-alpine as basebuilder
|
||||
FROM golang:1.16-alpine as basebuilder
|
||||
RUN apk add --update make bash
|
||||
|
||||
FROM basebuilder as builder
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.14-alpine as basebuilder
|
||||
FROM golang:1.16-alpine as basebuilder
|
||||
RUN apk add --update make bash
|
||||
|
||||
FROM basebuilder as builder
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.14-alpine as basebuilder
|
||||
FROM golang:1.16-alpine as basebuilder
|
||||
RUN apk add --update make bash
|
||||
|
||||
FROM basebuilder as builder
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.14-alpine as basebuilder
|
||||
FROM golang:1.16-alpine as basebuilder
|
||||
RUN apk add --update make bash
|
||||
|
||||
FROM basebuilder as builder
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
|
@ -339,7 +338,7 @@ var getContainerInfoCmd = &cobra.Command{
|
|||
)
|
||||
|
||||
if containerPathFrom != "" {
|
||||
data, err := ioutil.ReadFile(containerPathFrom)
|
||||
data, err := os.ReadFile(containerPathFrom)
|
||||
if err != nil {
|
||||
cmd.PrintErrln(fmt.Errorf("can't read file: %w", err))
|
||||
return
|
||||
|
@ -398,7 +397,7 @@ var getContainerInfoCmd = &cobra.Command{
|
|||
}
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(containerPathTo, data, 0644)
|
||||
err = os.WriteFile(containerPathTo, data, 0644)
|
||||
if err != nil {
|
||||
cmd.PrintErrln(fmt.Errorf("can't write container to file: %w", err))
|
||||
return
|
||||
|
@ -472,7 +471,7 @@ var getExtendedACLCmd = &cobra.Command{
|
|||
cmd.Println("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)
|
||||
}
|
||||
},
|
||||
|
@ -636,7 +635,7 @@ func getSessionToken(path string) (*session.Token, error) {
|
|||
var tok *session.Token
|
||||
|
||||
if path != "" {
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -661,7 +660,7 @@ func parseContainerPolicy(policyString string) (*netmap.PlacementPolicy, error)
|
|||
if err == nil {
|
||||
printVerbose("Reading placement policy from file: %s", policyString)
|
||||
|
||||
data, err := ioutil.ReadFile(policyString)
|
||||
data, err := os.ReadFile(policyString)
|
||||
if err != nil {
|
||||
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)
|
||||
|
||||
data, err := ioutil.ReadFile(eaclPath)
|
||||
data, err := os.ReadFile(eaclPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't read file with EACL: %w", err)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -638,7 +637,7 @@ func parseSearchFilters(cmd *cobra.Command) (object.SearchFilters, error) {
|
|||
default:
|
||||
return nil, fmt.Errorf("invalid field number: %d", len(words))
|
||||
case 1:
|
||||
data, err := ioutil.ReadFile(words[0])
|
||||
data, err := os.ReadFile(words[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -808,7 +807,7 @@ func saveAndPrintHeader(cmd *cobra.Command, obj *object.Object, filename string)
|
|||
cmd.Println(string(bs))
|
||||
return nil
|
||||
}
|
||||
err := ioutil.WriteFile(filename, bs, os.ModePerm)
|
||||
err := os.WriteFile(filename, bs, os.ModePerm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -906,7 +905,7 @@ func getBearerToken(cmd *cobra.Command, flagname string) (*token.BearerToken, er
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't read bearer token file: %w", err)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -195,7 +194,7 @@ func getKey() (*ecdsa.PrivateKey, error) {
|
|||
}
|
||||
|
||||
func getKeyFromFile(keyPath string) (*ecdsa.PrivateKey, error) {
|
||||
data, err := ioutil.ReadFile(keyPath)
|
||||
data, err := os.ReadFile(keyPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: %v", errInvalidKey, err)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -303,7 +302,7 @@ func signBearerToken(cmd *cobra.Command, _ []string) {
|
|||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(to, data, 0644)
|
||||
err = os.WriteFile(to, data, 0644)
|
||||
if err != nil {
|
||||
cmd.PrintErrln(fmt.Errorf("can't write signed bearer token to file: %w", err))
|
||||
return
|
||||
|
@ -349,7 +348,7 @@ func signSessionToken(cmd *cobra.Command, _ []string) {
|
|||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(to, data, 0644)
|
||||
err = os.WriteFile(to, data, 0644)
|
||||
if err != nil {
|
||||
cmd.PrintErrln(fmt.Errorf("can't write signed session token to %s: %w", to, err))
|
||||
return
|
||||
|
@ -389,7 +388,7 @@ func convertEACLTable(cmd *cobra.Command, _ []string) {
|
|||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(to, data, 0644)
|
||||
err = os.WriteFile(to, data, 0644)
|
||||
if err != nil {
|
||||
cmd.PrintErrln(fmt.Errorf("can't write exteded ACL table to file: %w", err))
|
||||
return
|
||||
|
@ -486,7 +485,7 @@ func keyerGenerate(filename string, d *keyer.Dashboard) error {
|
|||
}
|
||||
|
||||
if filename != "" {
|
||||
return ioutil.WriteFile(filename, key, 0600)
|
||||
return os.WriteFile(filename, key, 0600)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -502,7 +501,7 @@ func fileExists(filename string) bool {
|
|||
}
|
||||
|
||||
func keyerParseFile(filename string, d *keyer.Dashboard) error {
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
data, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't open %v file: %w", filename, err)
|
||||
}
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neofs-node/misc"
|
||||
"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"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
@ -58,7 +60,9 @@ func main() {
|
|||
log, err := logger.NewLogger(logPrm)
|
||||
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
|
||||
|
||||
httpServers := initHTTPServers(cfg)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package engineconfig_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io/fs"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -47,7 +47,7 @@ func TestEngineSection(t *testing.T) {
|
|||
require.EqualValues(t, 555, wc.WorkersNumber())
|
||||
|
||||
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.EqualValues(t, 0666, blob.Perm())
|
||||
|
@ -73,7 +73,7 @@ func TestEngineSection(t *testing.T) {
|
|||
require.EqualValues(t, 556, wc.WorkersNumber())
|
||||
|
||||
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.EqualValues(t, 0667, blob.Perm())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package blobstorconfig
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io/fs"
|
||||
|
||||
"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"
|
||||
|
@ -45,10 +45,10 @@ func (x *Config) Path() string {
|
|||
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.
|
||||
func (x *Config) Perm() os.FileMode {
|
||||
func (x *Config) Perm() fs.FileMode {
|
||||
p := config.UintSafe(
|
||||
(*config.Config)(x),
|
||||
"perm",
|
||||
|
@ -58,7 +58,7 @@ func (x *Config) Perm() os.FileMode {
|
|||
p = PermDefault
|
||||
}
|
||||
|
||||
return os.FileMode(p)
|
||||
return fs.FileMode(p)
|
||||
}
|
||||
|
||||
// ShallowDepth returns value of "shallow_depth" config parameter.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package metabaseconfig
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io/fs"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||
)
|
||||
|
@ -37,10 +37,10 @@ func (x *Config) Path() string {
|
|||
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.
|
||||
func (x *Config) Perm() os.FileMode {
|
||||
func (x *Config) Perm() fs.FileMode {
|
||||
p := config.UintSafe(
|
||||
(*config.Config)(x),
|
||||
"perm",
|
||||
|
@ -50,5 +50,5 @@ func (x *Config) Perm() os.FileMode {
|
|||
p = PermDefault
|
||||
}
|
||||
|
||||
return os.FileMode(p)
|
||||
return fs.FileMode(p)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package nodeconfig
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
|
@ -35,7 +35,7 @@ func Key(c *config.Config) *keys.PrivateKey {
|
|||
err error
|
||||
data []byte
|
||||
)
|
||||
if data, err = ioutil.ReadFile(v); err == nil {
|
||||
if data, err = os.ReadFile(v); err == nil {
|
||||
key, err = keys.NewPrivateKeyFromBytes(data)
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/misc"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/grace"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -48,7 +49,7 @@ func main() {
|
|||
}
|
||||
|
||||
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)
|
||||
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/nspcc-dev/neofs-node
|
||||
|
||||
go 1.14
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.5.2
|
||||
|
|
3
go.sum
3
go.sum
|
@ -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.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/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.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
|
||||
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/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.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
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/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-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-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
||||
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-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q=
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package blobovnicza
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
|
@ -33,7 +34,7 @@ type cfg struct {
|
|||
}
|
||||
|
||||
type boltDBCfg struct {
|
||||
perm os.FileMode
|
||||
perm fs.FileMode
|
||||
|
||||
path string
|
||||
|
||||
|
@ -77,7 +78,7 @@ func WithPath(path string) Option {
|
|||
|
||||
// WithPermissions returns option to specify permission bits
|
||||
// of Blobovnicza's system path.
|
||||
func WithPermissions(perm os.FileMode) Option {
|
||||
func WithPermissions(perm fs.FileMode) Option {
|
||||
return func(c *cfg) {
|
||||
c.perm = perm
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package blobstor
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"os"
|
||||
"io/fs"
|
||||
"path"
|
||||
|
||||
"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
|
||||
// bits of the fs tree.
|
||||
func WithRootPerm(perm os.FileMode) Option {
|
||||
func WithRootPerm(perm fs.FileMode) Option {
|
||||
return func(c *cfg) {
|
||||
c.fsTree.Permissions = perm
|
||||
c.blzOpts = append(c.blzOpts, blobovnicza.WithPermissions(perm))
|
||||
|
|
|
@ -3,7 +3,7 @@ package fstree
|
|||
import (
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
@ -23,7 +23,7 @@ type FSTree struct {
|
|||
// Info groups the information about file storage.
|
||||
type Info struct {
|
||||
// Permission bits of the root directory.
|
||||
Permissions os.FileMode
|
||||
Permissions fs.FileMode
|
||||
|
||||
// Full path to the root directory.
|
||||
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 {
|
||||
curName := strings.Join(curPath[1:], "")
|
||||
des, err := ioutil.ReadDir(path.Join(curPath...))
|
||||
des, err := os.ReadDir(path.Join(curPath...))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ func (t *FSTree) iterate(depth int, curPath []string, f func(*objectSDK.Address,
|
|||
continue
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadFile(path.Join(curPath...))
|
||||
data, err := os.ReadFile(path.Join(curPath...))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ func (t *FSTree) Put(addr *objectSDK.Address, data []byte) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(p, data, t.Permissions)
|
||||
return os.WriteFile(p, data, t.Permissions)
|
||||
}
|
||||
|
||||
// Get returns object from storage by address.
|
||||
|
@ -172,5 +172,5 @@ func (t *FSTree) Get(addr *objectSDK.Address) ([]byte, error) {
|
|||
return nil, ErrFileNotFound
|
||||
}
|
||||
|
||||
return ioutil.ReadFile(p)
|
||||
return os.ReadFile(p)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package meta
|
|||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"io/fs"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
|
@ -132,7 +133,7 @@ func WithPath(path string) Option {
|
|||
|
||||
// WithPermissions returns option to specify permission bits
|
||||
// of Metabase system path.
|
||||
func WithPermissions(perm os.FileMode) Option {
|
||||
func WithPermissions(perm fs.FileMode) Option {
|
||||
return func(c *cfg) {
|
||||
c.info.Permission = perm
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package meta
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// Info groups the information about DB.
|
||||
|
@ -10,7 +10,7 @@ type Info struct {
|
|||
Path string
|
||||
|
||||
// Permission of database file.
|
||||
Permission os.FileMode
|
||||
Permission fs.FileMode
|
||||
}
|
||||
|
||||
// DumpInfo returns information about the DB.
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -2,7 +2,7 @@ package airportsdb
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"io/fs"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
@ -41,7 +41,7 @@ type DB struct {
|
|||
|
||||
type pathMode struct {
|
||||
path string
|
||||
mode os.FileMode
|
||||
mode fs.FileMode
|
||||
}
|
||||
|
||||
const invalidPrmValFmt = "invalid parameter %s (%T):%v"
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package airportsdb
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// Option sets an optional parameter of DB.
|
||||
type Option func(*options)
|
||||
|
||||
type options struct {
|
||||
airportMode, countryMode os.FileMode
|
||||
airportMode, countryMode fs.FileMode
|
||||
}
|
||||
|
||||
func defaultOpts() *options {
|
||||
return &options{
|
||||
airportMode: os.ModePerm, // 0777
|
||||
countryMode: os.ModePerm, // 0777
|
||||
airportMode: fs.ModePerm, // 0777
|
||||
countryMode: fs.ModePerm, // 0777
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package locodebolt
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"io/fs"
|
||||
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
@ -34,7 +34,7 @@ type Prm struct {
|
|||
type DB struct {
|
||||
path string
|
||||
|
||||
mode os.FileMode
|
||||
mode fs.FileMode
|
||||
|
||||
boltOpts *bbolt.Options
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package locodebolt
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
|
@ -11,7 +12,7 @@ import (
|
|||
type Option func(*options)
|
||||
|
||||
type options struct {
|
||||
mode os.FileMode
|
||||
mode fs.FileMode
|
||||
|
||||
boltOpts *bbolt.Options
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package continentsdb
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
locodedb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db"
|
||||
"github.com/paulmach/orb"
|
||||
|
@ -53,7 +53,7 @@ func (db *DB) PointContinent(point *locodedb.Point) (*locodedb.Continent, error)
|
|||
}
|
||||
|
||||
func (db *DB) init() error {
|
||||
data, err := ioutil.ReadFile(db.path)
|
||||
data, err := os.ReadFile(db.path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not read data file: %w", err)
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package csvlocode
|
||||
|
||||
import (
|
||||
"os"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
// Option sets an optional parameter of Table.
|
||||
type Option func(*options)
|
||||
|
||||
type options struct {
|
||||
mode os.FileMode
|
||||
mode fs.FileMode
|
||||
|
||||
extraPaths []string
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package csvlocode
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"io/fs"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
@ -32,7 +32,7 @@ type Prm struct {
|
|||
type Table struct {
|
||||
paths []string
|
||||
|
||||
mode os.FileMode
|
||||
mode fs.FileMode
|
||||
|
||||
subDivPath string
|
||||
|
||||
|
|
Loading…
Reference in a new issue