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 102 deletions
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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())
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
2
go.mod
|
@ -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
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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 (
|
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"
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue