Skip to content

Commit

Permalink
Upgrade minimum required Go version to 1.20 (#2754)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Mar 1, 2024
2 parents 3b7d09b + 2ff412c commit d7c7aba
Show file tree
Hide file tree
Showing 45 changed files with 239 additions and 665 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile.adm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21 as builder
FROM golang:1.22 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.cli
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21 as builder
FROM golang:1.22 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.ir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21 as builder
FROM golang:1.22 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.storage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21 as builder
FROM golang:1.22 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile.storage-testnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21 as builder
FROM golang:1.22 as builder
ARG BUILD=now
ARG VERSION=dev
ARG REPO=repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.22'
cache: true

- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.19.x', '1.20.x', '1.21' ]
go: [ '1.20.x', '1.21.x', '1.22' ]
steps:
- name: Setup go
uses: actions/setup-go@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
uses: actions/setup-go@v5
with:
cache: true
go-version: '1.20'
go-version: '1.22'
- run: go version

- name: Set up Python
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Changelog for NeoFS Node
- Supporting of `__NEOFS__NETMAP*` X-headers (#2751)

### Updated
- Minimum required version of Go to 1.20

### Updating from v0.40.1
Remove `notification` section from all SN configuration files: it is no longer
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VERSION ?= $(shell set -o pipefail; git describe --tags --dirty --match "v*" --a
HUB_IMAGE ?= nspccdev/neofs
HUB_TAG ?= $(VERSION)

GO_VERSION ?= 1.21
GO_VERSION ?= 1.22
LINT_VERSION ?= 1.55.0
ARCH = amd64

Expand Down
2 changes: 2 additions & 0 deletions cmd/blobovnicza-to-peapod/blobovnicza/blobovnicza_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
func testPutGet(t *testing.T, blz *Blobovnicza, addr oid.Address, sz uint64, assertErrPut, assertErrGet func(error) bool) oid.Address {
// create binary object
data := make([]byte, sz)
//nolint:staticcheck
rand.Read(data)

var pPut PutPrm
Expand Down Expand Up @@ -52,6 +53,7 @@ func testGet(t *testing.T, blz *Blobovnicza, addr oid.Address, expObj []byte, as
}

func TestBlobovnicza(t *testing.T) {
//nolint:staticcheck
rand.Seed(1024)

p := "./test_blz"
Expand Down
4 changes: 2 additions & 2 deletions cmd/blobovnicza-to-peapod/blobovnicza/get.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package blobovnicza

import (
"bytes"
"errors"

"github.com/nspcc-dev/neo-go/pkg/util/slice"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"go.etcd.io/bbolt"
Expand Down Expand Up @@ -52,7 +52,7 @@ func (b *Blobovnicza) Get(prm GetPrm) (GetRes, error) {
return nil
}

data = slice.Copy(data)
data = bytes.Clone(data)

return errInterruptForEach
})
Expand Down
4 changes: 2 additions & 2 deletions cmd/blobovnicza-to-peapod/blobovnicza/iterate_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package blobovnicza

import (
"bytes"
"errors"
"path/filepath"
"testing"

"github.com/nspcc-dev/neo-go/pkg/util/slice"
oidtest "github.com/nspcc-dev/neofs-sdk-go/object/id/test"
"github.com/stretchr/testify/require"
"go.etcd.io/bbolt"
Expand All @@ -29,7 +29,7 @@ func TestBlobovniczaIterate(t *testing.T) {

seen := make([][]byte, 0, 2)
inc := func(e IterationElement) error {
seen = append(seen, slice.Copy(e.data))
seen = append(seen, bytes.Clone(e.data))
return nil
}

Expand Down
5 changes: 0 additions & 5 deletions cmd/blobovnicza-to-peapod/blobovniczatree/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ package blobovniczatree
import (
"errors"

"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
)

func isErrOutOfRange(err error) bool {
return errors.As(err, new(apistatus.ObjectOutOfRange))
}

func isLogical(err error) bool {
return errors.As(err, new(logicerr.Logical))
}
7 changes: 4 additions & 3 deletions cmd/blobovnicza-to-peapod/blobovniczatree/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/nspcc-dev/neofs-node/cmd/blobovnicza-to-peapod/blobovnicza"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr"
"go.etcd.io/bbolt"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -35,7 +36,7 @@ func (b *Blobovniczas) Put(prm common.PutPrm) (common.PutRes, error) {
fn = func(p string) (bool, error) {
active, err := b.getActivated(p)
if err != nil {
if !isLogical(err) {
if !errors.Is(err, logicerr.Error) {
b.reportError("could not get active blobovnicza", err)
} else {
b.log.Debug("could not get active blobovnicza",
Expand All @@ -56,7 +57,7 @@ func (b *Blobovniczas) Put(prm common.PutPrm) (common.PutRes, error) {
}

if err := b.updateActive(p, &active.ind); err != nil {
if !isLogical(err) {
if !errors.Is(err, logicerr.Error) {
b.reportError("could not update active blobovnicza", err)
} else {
b.log.Debug("could not update active blobovnicza",
Expand All @@ -71,7 +72,7 @@ func (b *Blobovniczas) Put(prm common.PutPrm) (common.PutRes, error) {
}

allFull = false
if !isLogical(err) {
if !errors.Is(err, logicerr.Error) {
b.reportError("could not put object to active blobovnicza", err)
} else {
b.log.Debug("could not put object to active blobovnicza",
Expand Down
12 changes: 6 additions & 6 deletions cmd/neofs-adm/internal/modules/morph/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func getContainerContractHash(cmd *cobra.Command, inv *invoker.Invoker, c Client
func getContainersList(inv *invoker.Invoker, ch util.Uint160) ([][]byte, error) {
res, err := inv.Call(ch, "list", "")
if err != nil {
return nil, fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
return nil, fmt.Errorf("%w: %w", errInvalidContainerResponse, err)
}
itm, err := unwrap.Item(res, err)
if _, ok := itm.(stackitem.Null); !ok {
Expand Down Expand Up @@ -71,7 +71,7 @@ func dumpContainers(cmd *cobra.Command, _ []string) error {

cids, err := getContainersList(inv, ch)
if err != nil {
return fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
return fmt.Errorf("%w: %w", errInvalidContainerResponse, err)
}

isOK, err := getCIDFilterFunc(cmd)
Expand Down Expand Up @@ -105,13 +105,13 @@ func dumpContainers(cmd *cobra.Command, _ []string) error {
cnt := new(Container)
err = cnt.FromStackItem(res.Stack[0])
if err != nil {
return fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
return fmt.Errorf("%w: %w", errInvalidContainerResponse, err)
}

ea := new(EACL)
err = ea.FromStackItem(res.Stack[1])
if err != nil {
return fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
return fmt.Errorf("%w: %w", errInvalidContainerResponse, err)
}
if len(ea.Value) != 0 {
cnt.EACL = ea
Expand Down Expand Up @@ -142,7 +142,7 @@ func listContainers(cmd *cobra.Command, _ []string) error {

cids, err := getContainersList(inv, ch)
if err != nil {
return fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
return fmt.Errorf("%w: %w", errInvalidContainerResponse, err)
}

for _, id := range cids {
Expand Down Expand Up @@ -218,7 +218,7 @@ func restoreContainers(cmd *cobra.Command, _ []string) error {

old := new(Container)
if err := old.FromStackItem(res.Stack[0]); err != nil {
return fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
return fmt.Errorf("%w: %w", errInvalidContainerResponse, err)
}
if len(old.Value) != 0 {
var id cid.ID
Expand Down
8 changes: 2 additions & 6 deletions cmd/neofs-cli/internal/client/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func getSDKClientByFlag(ctx context.Context, endpointFlag string) (*client.Clien

err := addr.FromString(viper.GetString(endpointFlag))
if err != nil {
return nil, fmt.Errorf("%v: %w", errInvalidEndpoint, err)
return nil, fmt.Errorf("%w: %w", errInvalidEndpoint, err)
}
return GetSDKClient(ctx, addr)
}
Expand Down Expand Up @@ -74,11 +74,7 @@ func GetSDKClient(ctx context.Context, addr network.Address) (*client.Client, er
// This behavior is going to be fixed on SDK side.
//
// Track https://github.com/nspcc-dev/neofs-node/issues/2477
wErr := err
for e := errors.Unwrap(wErr); e != nil; e = errors.Unwrap(wErr) {
wErr = e
}
if status.Code(wErr) == codes.Unimplemented {
if status.Code(err) == codes.Unimplemented {
return c, nil
}
return nil, fmt.Errorf("can't init SDK client: %w", err)
Expand Down
6 changes: 3 additions & 3 deletions cmd/neofs-cli/internal/key/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func get(cmd *cobra.Command) (*ecdsa.PrivateKey, error) {
if err != nil {
var perr = new(*os.PathError)
if errors.As(err, perr) {
return nil, fmt.Errorf("%w: %v", ErrFs, err)
return nil, fmt.Errorf("%w: %w", ErrFs, err)
}
return nil, fmt.Errorf("%w: %v", ErrInvalidKey, err)
return nil, fmt.Errorf("%w: %w", ErrInvalidKey, err)
}
return FromWallet(cmd, w, viper.GetString(commonflags.Account))
}
Expand Down Expand Up @@ -71,7 +71,7 @@ func getOrGenerate(cmd *cobra.Command) (*ecdsa.PrivateKey, error) {

priv, err := keys.NewPrivateKey()
if err != nil {
return nil, fmt.Errorf("%w: %v", errCantGenerateKey, err)
return nil, fmt.Errorf("%w: %w", errCantGenerateKey, err)
}

common.PrintVerbose(cmd, "Private key generated successfully. Public key: %s", priv.PublicKey())
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ func readContractFromFiles(_fs fs.FS, filePrefix string) (c Contract, err error)
bReader := io.NewBinReaderFromIO(fNEF)
c.NEF.DecodeBinary(bReader)
if bReader.Err != nil {
return c, fmt.Errorf("%w: %v", errInvalidNEF, bReader.Err)
return c, fmt.Errorf("%w: %w", errInvalidNEF, bReader.Err)
}

err = json.NewDecoder(fManifest).Decode(&c.Manifest)
if err != nil {
return c, fmt.Errorf("%w: %v", errInvalidManifest, err)
return c, fmt.Errorf("%w: %w", errInvalidManifest, err)
}

return
Expand Down
Loading

0 comments on commit d7c7aba

Please sign in to comment.