Skip to content

Commit 79c90b7

Browse files
committed
refactor: rename labels to names
1 parent ad47d0c commit 79c90b7

File tree

9 files changed

+22
-23
lines changed

9 files changed

+22
-23
lines changed

core/commands/pin/pin.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type AddPinOutput struct {
4949
}
5050

5151
const (
52-
pinLabelOptionName = "label"
5352
pinRecursiveOptionName = "recursive"
5453
pinProgressOptionName = "progress"
5554
)
@@ -66,7 +65,7 @@ var addPinCmd = &cmds.Command{
6665
Options: []cmds.Option{
6766
cmds.BoolOption(pinRecursiveOptionName, "r", "Recursively pin the object linked to by the specified object(s).").WithDefault(true),
6867
cmds.BoolOption(pinProgressOptionName, "Show progress"),
69-
cmds.StringOption(pinLabelOptionName, "l", "Label to add to the object(s) to be pinned"),
68+
cmds.StringOption(pinNameOptionName, "n", "An optional name for the pin(s)."),
7069
},
7170
Type: AddPinOutput{},
7271
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
@@ -77,7 +76,7 @@ var addPinCmd = &cmds.Command{
7776

7877
// set recursive flag
7978
recursive, _ := req.Options[pinRecursiveOptionName].(bool)
80-
label, _ := req.Options[pinLabelOptionName].(string)
79+
name, _ := req.Options[pinNameOptionName].(string)
8180
showProgress, _ := req.Options[pinProgressOptionName].(bool)
8281

8382
if err := req.ParseBodyArgs(); err != nil {
@@ -90,7 +89,7 @@ var addPinCmd = &cmds.Command{
9089
}
9190

9291
if !showProgress {
93-
added, err := pinAddMany(req.Context, api, enc, req.Arguments, recursive, label)
92+
added, err := pinAddMany(req.Context, api, enc, req.Arguments, recursive, name)
9493
if err != nil {
9594
return err
9695
}
@@ -108,7 +107,7 @@ var addPinCmd = &cmds.Command{
108107

109108
ch := make(chan pinResult, 1)
110109
go func() {
111-
added, err := pinAddMany(ctx, api, enc, req.Arguments, recursive, label)
110+
added, err := pinAddMany(ctx, api, enc, req.Arguments, recursive, name)
112111
ch <- pinResult{pins: added, err: err}
113112
}()
114113

@@ -184,7 +183,7 @@ var addPinCmd = &cmds.Command{
184183
},
185184
}
186185

187-
func pinAddMany(ctx context.Context, api coreiface.CoreAPI, enc cidenc.Encoder, paths []string, recursive bool, label string) ([]string, error) {
186+
func pinAddMany(ctx context.Context, api coreiface.CoreAPI, enc cidenc.Encoder, paths []string, recursive bool, name string) ([]string, error) {
188187
added := make([]string, len(paths))
189188
for i, b := range paths {
190189
p, err := cmdutils.PathOrCidPath(b)
@@ -197,7 +196,7 @@ func pinAddMany(ctx context.Context, api coreiface.CoreAPI, enc cidenc.Encoder,
197196
return nil, err
198197
}
199198

200-
if err := api.Pin().Add(ctx, rp, options.Pin.Recursive(recursive), options.Pin.Label(label)); err != nil {
199+
if err := api.Pin().Add(ctx, rp, options.Pin.Recursive(recursive), options.Pin.Name(name)); err != nil {
201200
return nil, err
202201
}
203202
added[i] = enc.Encode(rp.RootCid())

core/coreapi/pin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (api *PinAPI) Add(ctx context.Context, p path.Path, opts ...caopts.PinAddOp
3838

3939
defer api.blockstore.PinLock(ctx).Unlock(ctx)
4040

41-
err = api.pinning.Pin(ctx, dagNode, settings.Recursive, settings.Label)
41+
err = api.pinning.Pin(ctx, dagNode, settings.Recursive, settings.Name)
4242
if err != nil {
4343
return fmt.Errorf("pin: %s", err)
4444
}
@@ -307,7 +307,7 @@ func (api *PinAPI) pinLsAll(ctx context.Context, typeStr string) <-chan coreifac
307307
out <- &pinInfo{err: streamedCid.Err}
308308
return
309309
}
310-
if err = AddToResultKeys(streamedCid.Pin.Key, streamedCid.Pin.Label, "recursive"); err != nil {
310+
if err = AddToResultKeys(streamedCid.Pin.Key, streamedCid.Pin.Name, "recursive"); err != nil {
311311
out <- &pinInfo{err: err}
312312
return
313313
}
@@ -320,7 +320,7 @@ func (api *PinAPI) pinLsAll(ctx context.Context, typeStr string) <-chan coreifac
320320
out <- &pinInfo{err: streamedCid.Err}
321321
return
322322
}
323-
if err = AddToResultKeys(streamedCid.Pin.Key, streamedCid.Pin.Label, "direct"); err != nil {
323+
if err = AddToResultKeys(streamedCid.Pin.Key, streamedCid.Pin.Name, "direct"); err != nil {
324324
out <- &pinInfo{err: err}
325325
return
326326
}

core/coreiface/options/pin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "fmt"
55
// PinAddSettings represent the settings for PinAPI.Add
66
type PinAddSettings struct {
77
Recursive bool
8-
Label string
8+
Name string
99
}
1010

1111
// PinLsSettings represent the settings for PinAPI.Ls
@@ -264,10 +264,10 @@ func (pinOpts) Recursive(recursive bool) PinAddOption {
264264
}
265265
}
266266

267-
// Label is an option for Pin.Add which specifies a label to add to the pin.
268-
func (pinOpts) Label(label string) PinAddOption {
267+
// Name is an option for Pin.Add which specifies an optional name to add to the pin.
268+
func (pinOpts) Name(name string) PinAddOption {
269269
return func(settings *PinAddSettings) error {
270-
settings.Label = label
270+
settings.Name = name
271271
return nil
272272
}
273273
}

docs/examples/kubo-as-a-library/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ go 1.20
77
replace github.com/ipfs/kubo => ./../../..
88

99
require (
10-
github.com/ipfs/boxo v0.16.1-0.20231215092939-544358941705
10+
github.com/ipfs/boxo v0.16.1-0.20240102110230-a787fdd18a58
1111
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
1212
github.com/libp2p/go-libp2p v0.32.2
1313
github.com/multiformats/go-multiaddr v0.12.0

docs/examples/kubo-as-a-library/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
303303
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
304304
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
305305
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
306-
github.com/ipfs/boxo v0.16.1-0.20231215092939-544358941705 h1:4DdhReoM3GZV/r1Qj+WkNbJhx06kFo88gxNF82XmJ6o=
307-
github.com/ipfs/boxo v0.16.1-0.20231215092939-544358941705/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
306+
github.com/ipfs/boxo v0.16.1-0.20240102110230-a787fdd18a58 h1:tffEyCiC1mW0wv1CPfynSNudmhDrsA4idEaHZ2HZ1eQ=
307+
github.com/ipfs/boxo v0.16.1-0.20240102110230-a787fdd18a58/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
308308
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
309309
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
310310
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/hashicorp/go-multierror v1.1.1
1818
github.com/ipfs-shipyard/nopfs v0.0.12-0.20231027223058-cde3b5ba964c
1919
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c
20-
github.com/ipfs/boxo v0.16.1-0.20231215092939-544358941705
20+
github.com/ipfs/boxo v0.16.1-0.20240102110230-a787fdd18a58
2121
github.com/ipfs/go-block-format v0.2.0
2222
github.com/ipfs/go-cid v0.4.1
2323
github.com/ipfs/go-cidutil v0.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
337337
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
338338
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
339339
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
340-
github.com/ipfs/boxo v0.16.1-0.20231215092939-544358941705 h1:4DdhReoM3GZV/r1Qj+WkNbJhx06kFo88gxNF82XmJ6o=
341-
github.com/ipfs/boxo v0.16.1-0.20231215092939-544358941705/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
340+
github.com/ipfs/boxo v0.16.1-0.20240102110230-a787fdd18a58 h1:tffEyCiC1mW0wv1CPfynSNudmhDrsA4idEaHZ2HZ1eQ=
341+
github.com/ipfs/boxo v0.16.1-0.20240102110230-a787fdd18a58/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
342342
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
343343
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
344344
github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ=

test/dependencies/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ require (
103103
github.com/hexops/gotextdiff v1.0.3 // indirect
104104
github.com/inconshreveable/mousetrap v1.1.0 // indirect
105105
github.com/ipfs/bbloom v0.0.4 // indirect
106-
github.com/ipfs/boxo v0.16.1-0.20231215092939-544358941705 // indirect
106+
github.com/ipfs/boxo v0.16.1-0.20240102110230-a787fdd18a58 // indirect
107107
github.com/ipfs/go-block-format v0.2.0 // indirect
108108
github.com/ipfs/go-cid v0.4.1 // indirect
109109
github.com/ipfs/go-datastore v0.6.0 // indirect

test/dependencies/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
342342
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
343343
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
344344
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
345-
github.com/ipfs/boxo v0.16.1-0.20231215092939-544358941705 h1:4DdhReoM3GZV/r1Qj+WkNbJhx06kFo88gxNF82XmJ6o=
346-
github.com/ipfs/boxo v0.16.1-0.20231215092939-544358941705/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
345+
github.com/ipfs/boxo v0.16.1-0.20240102110230-a787fdd18a58 h1:tffEyCiC1mW0wv1CPfynSNudmhDrsA4idEaHZ2HZ1eQ=
346+
github.com/ipfs/boxo v0.16.1-0.20240102110230-a787fdd18a58/go.mod h1:jAgpNQn7T7BnibUeReXcKU9Ha1xmYNyOlwVEl193ow0=
347347
github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs=
348348
github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM=
349349
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=

0 commit comments

Comments
 (0)