Skip to content

Commit b503985

Browse files
authored
Merge pull request #115 from gfanton/feat/bump-ipfs-16
2 parents e9658b4 + 007f41d commit b503985

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+867
-509
lines changed

.github/workflows/go.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ jobs:
1414
strategy:
1515
matrix:
1616
golang:
17-
- 1.17.x
17+
- 1.18.x
1818
steps:
1919
- uses: actions/checkout@v3
2020
- name: Set up Go
2121
uses: actions/setup-go@v2
2222
with:
2323
go-version: ${{ matrix.golang }}
2424
- name: golangci-lint
25-
uses: golangci/golangci-lint-action@v3.1.0
25+
uses: golangci/golangci-lint-action@v3.3.0
2626
with:
2727
go-version: ${{ matrix.golang }}
28-
version: v1.44.2
28+
version: v1.50.1
2929
args: --timeout=10m
3030
# only-new-issues: true
3131

32+
3233
go-tests-on-linux:
3334
runs-on: ubuntu-latest
3435
strategy:
3536
matrix:
3637
golang:
37-
- 1.16.x
38-
- 1.17.x
39-
#- tip
38+
- 1.18.x
39+
- 1.19.x
4040
env:
4141
OS: ubuntu-latest
4242
GOLANG: ${{ matrix.golang }}
@@ -84,9 +84,8 @@ jobs:
8484
strategy:
8585
matrix:
8686
golang:
87-
- 1.16.x
88-
- 1.17.x
89-
#- tip
87+
- 1.18.x
88+
- 1.19.x
9089
env:
9190
OS: macos-latest
9291
GOLANG: ${{ matrix.golang }}

.golangci.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,11 @@ linters:
2121
enable:
2222
- goconst
2323
- misspell
24-
- deadcode
25-
- misspell
26-
- structcheck
2724
- errcheck
2825
- unused
29-
- varcheck
3026
- staticcheck
3127
- unconvert
3228
- gofmt
33-
#- goimports # disabling goimports while we can't configure it to ignore vendors (github.com/whyrusleeping/go-logging seems to be badly formated)
34-
- golint
29+
- goimports
30+
- revive
3531
- ineffassign

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
golang 1.18

accesscontroller/ipfs/accesscontroller_ipfs.go

+14-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
cid "github.com/ipfs/go-cid"
1616
cbornode "github.com/ipfs/go-ipld-cbor"
1717
coreapi "github.com/ipfs/interface-go-ipfs-core"
18-
"github.com/pkg/errors"
1918
"github.com/polydawn/refmt/obj/atlas"
2019
"go.uber.org/zap"
2120
)
@@ -50,7 +49,7 @@ func (i *ipfsAccessController) CanAppend(entry logac.LogEntry, p identityprovide
5049
}
5150
}
5251

53-
return errors.New("not allowed")
52+
return fmt.Errorf("not allowed")
5453
}
5554

5655
func (i *ipfsAccessController) GetAuthorizedByRole(role string) ([]string, error) {
@@ -65,46 +64,46 @@ func (i *ipfsAccessController) GetAuthorizedByRole(role string) ([]string, error
6564
}
6665

6766
func (i *ipfsAccessController) Grant(ctx context.Context, capability string, keyID string) error {
68-
return errors.New("not implemented - does not exist in JS version")
67+
return fmt.Errorf("not implemented - does not exist in JS version")
6968
}
7069

7170
func (i *ipfsAccessController) Revoke(ctx context.Context, capability string, keyID string) error {
72-
return errors.New("not implemented - does not exist in JS version")
71+
return fmt.Errorf("not implemented - does not exist in JS version")
7372
}
7473

7574
func (i *ipfsAccessController) Load(ctx context.Context, address string) error {
7675
i.logger.Debug(fmt.Sprintf("reading IPFS access controller write access on hash %s", address))
7776

7877
c, err := cid.Decode(address)
7978
if err != nil {
80-
return errors.Wrap(err, "unable to parse cid")
79+
return fmt.Errorf("unable to parse cid: %w", err)
8180
}
8281

8382
res, err := io.ReadCBOR(ctx, i.ipfs, c)
8483
if err != nil {
85-
return errors.Wrap(err, "unable to load access controller manifest data")
84+
return fmt.Errorf("unable to load access controller manifest data: %w", err)
8685
}
8786

8887
manifest := &accesscontroller.Manifest{}
8988
err = cbornode.DecodeInto(res.RawData(), manifest)
9089
if err != nil {
91-
return errors.Wrap(err, "unable to unmarshal access controller manifest data")
90+
return fmt.Errorf("unable to unmarshal access controller manifest data: %w", err)
9291
}
9392

9493
res, err = io.ReadCBOR(ctx, i.ipfs, manifest.Params.GetAddress())
9594
if err != nil {
96-
return errors.Wrap(err, "unable to load access controller data")
95+
return fmt.Errorf("unable to load access controller data: %w", err)
9796
}
9897

9998
writeAccessData := &cborWriteAccess{}
10099
err = cbornode.DecodeInto(res.RawData(), writeAccessData)
101100
if err != nil {
102-
return errors.Wrap(err, "unable to unmarshal access controller data")
101+
return fmt.Errorf("unable to unmarshal access controller data: %w", err)
103102
}
104103

105104
var writeAccess []string
106105
if err := json.Unmarshal([]byte(writeAccessData.Write), &writeAccess); err != nil {
107-
return errors.Wrap(err, "unable to unmarshal json write access")
106+
return fmt.Errorf("unable to unmarshal json write access: %w", err)
108107
}
109108

110109
i.muWriteAccess.Lock()
@@ -120,12 +119,12 @@ func (i *ipfsAccessController) Save(ctx context.Context) (accesscontroller.Manif
120119
i.muWriteAccess.RUnlock()
121120

122121
if err != nil {
123-
return nil, errors.Wrap(err, "unable to serialize write access")
122+
return nil, fmt.Errorf("unable to serialize write access: %w", err)
124123
}
125124

126125
c, err := io.WriteCBOR(ctx, i.ipfs, &cborWriteAccess{Write: string(writeAccess)}, nil)
127126
if err != nil {
128-
return nil, errors.Wrap(err, "unable to save access controller")
127+
return nil, fmt.Errorf("unable to save access controller: %w", err)
129128
}
130129

131130
i.logger.Debug(fmt.Sprintf("saved IPFS access controller write access on hash %s", c.String()))
@@ -134,17 +133,17 @@ func (i *ipfsAccessController) Save(ctx context.Context) (accesscontroller.Manif
134133
}
135134

136135
func (i *ipfsAccessController) Close() error {
137-
return errors.New("not implemented - does not exist in JS version")
136+
return fmt.Errorf("not implemented - does not exist in JS version")
138137
}
139138

140139
// NewIPFSAccessController Returns an access controller for IPFS
141140
func NewIPFSAccessController(_ context.Context, db iface.BaseOrbitDB, params accesscontroller.ManifestParams, options ...accesscontroller.Option) (accesscontroller.Interface, error) {
142141
if params == nil {
143-
return &ipfsAccessController{}, errors.New("an options object must be passed")
142+
return &ipfsAccessController{}, fmt.Errorf("an options object must be passed")
144143
}
145144

146145
if db == nil {
147-
return &ipfsAccessController{}, errors.New("an OrbitDB instance is required")
146+
return &ipfsAccessController{}, fmt.Errorf("an OrbitDB instance is required")
148147
}
149148

150149
if len(params.GetAccess("write")) == 0 {

accesscontroller/manifest.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package accesscontroller
22

33
import (
44
"context"
5+
"fmt"
56
"strings"
67
"sync"
78

89
"berty.tech/go-ipfs-log/io"
910
cid "github.com/ipfs/go-cid"
1011
cbornode "github.com/ipfs/go-ipld-cbor"
1112
coreapi "github.com/ipfs/interface-go-ipfs-core"
12-
"github.com/pkg/errors"
1313
"github.com/polydawn/refmt/obj/atlas"
1414
"go.uber.org/zap"
1515
)
@@ -160,7 +160,7 @@ func CreateManifest(ctx context.Context, ipfs coreapi.CoreAPI, controllerType st
160160
func ResolveManifest(ctx context.Context, ipfs coreapi.CoreAPI, manifestAddress string, params ManifestParams) (*Manifest, error) {
161161
if params.GetSkipManifest() {
162162
if params.GetType() == "" {
163-
return nil, errors.New("no manifest, access-controller type required")
163+
return nil, fmt.Errorf("no manifest, access-controller type required")
164164
}
165165

166166
manifest := &Manifest{
@@ -177,18 +177,18 @@ func ResolveManifest(ctx context.Context, ipfs coreapi.CoreAPI, manifestAddress
177177

178178
c, err := cid.Decode(manifestAddress)
179179
if err != nil {
180-
return nil, errors.Wrap(err, "unable to parse CID")
180+
return nil, fmt.Errorf("unable to parse CID: %w", err)
181181
}
182182

183183
node, err := io.ReadCBOR(ctx, ipfs, c)
184184
if err != nil {
185-
return nil, errors.Wrap(err, "unable to fetch manifest data")
185+
return nil, fmt.Errorf("unable to fetch manifest data: %w", err)
186186
}
187187

188188
manifest := &Manifest{}
189189
err = cbornode.DecodeInto(node.RawData(), &manifest)
190190
if err != nil {
191-
return nil, errors.Wrap(err, "unable to unmarshal")
191+
return nil, fmt.Errorf("unable to unmarshal: %w", err)
192192
}
193193

194194
return manifest, nil

0 commit comments

Comments
 (0)