Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

add Pin.IsPinned(..) #50

Merged
merged 2 commits into from
May 5, 2020
Merged

add Pin.IsPinned(..) #50

merged 2 commits into from
May 5, 2020

Conversation

MichaelMure
Copy link
Contributor

This PR add the following function to the Pin API:

// IsPinned returns whether or not the given cid is pinned
// and an explanation of why its pinned
IsPinned(context.Context, path.Path, ...options.PinIsPinnedOption) (string, bool, error)

This is needed to ultimately implement ipfs pin ls <cid>.

To do so, it was also needed to migrate the PinLsOptions into their own namespace.

Note: to avoid conflicts, this PR is chained with #49 so the diff here will include both until #49 is merged.

@MichaelMure
Copy link
Contributor Author

cc @aschmahmann @Stebalien

@MichaelMure
Copy link
Contributor Author

Rebased on master and fixed go fmt complaining.

Copy link
Contributor

@hsanjuan hsanjuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @MichaelMure, thanks for this. I left some comments. This library has many dozens of golint warnings and it would be nice if the files touched by the PR did not show any more issues. Since this is the core interface, it is specially important to have amazing developer docs here.

options/pin.go Outdated Show resolved Hide resolved
options/pin.go Show resolved Hide resolved
options/pin.go Show resolved Hide resolved
options/pin.go Outdated Show resolved Hide resolved
options/pin.go Outdated Show resolved Hide resolved
options/pin.go Show resolved Hide resolved
tests/pin.go Outdated Show resolved Hide resolved
@MichaelMure
Copy link
Contributor Author

MichaelMure commented Mar 18, 2020

@hsanjuan I'm torn on this one, I suppose mainly due to a question of taste. At the moment in the other namespace (block, object ...), all the options are merged at the root: Object.Type() is an option for Object.New, Object.Datatype is an option for Object.Put ... It works as long as there is no conflict, but get messy as soon as there is one. See Pin.Recursive and Pin.RmRecursive.

Adding IsPinned add 5 more conflicts in there and I suppose more conflict will come up in the future. That's why I created a sub-namespace for Ls and IsPinned.

I know it's a hard change but shouldn't that problem be addressed now rather than later ? Maybe instead of having options exposed as Pin.Ls.XX it should be PinLs.XX to remove a level ?

WDYT ?

Maybe @Stebalien would like to step in here ?

@MichaelMure
Copy link
Contributor Author

Otherwise, I agree about the documentation.

@hsanjuan
Copy link
Contributor

hsanjuan commented Mar 19, 2020

Adding IsPinned add 5 more conflicts in there and I suppose more conflict will come up in the future. That's why I created a sub-namespace for Ls and IsPinned.

I know it's a hard change but shouldn't that problem be addressed now rather than later ? Maybe instead of having options exposed as Pin.Ls.XX it should be PinLs.XX to remove a level ?

I'm a bit lost. I think it's ok having two options (PinLsSettings and PinIsPinnedSettings) but they could use the the same embedded type (until there is a reason to separate them or customize behaviour).

type PinLsSettings struct {
  typeSettings
}

etc. in the case of object, Type and Datatype are different things (one is for empty,unixfs-dir etc, the other is for base64,text). But here Type and WithType represent the same thing (recursive, or direct)...

@MichaelMure
Copy link
Contributor Author

@hsanjuan Sorry to ask you this but could you take over this one? I'll probably be unavailable for a week+.

@hsanjuan
Copy link
Contributor

@hsanjuan Sorry to ask you this but could you take over this one? I'll probably be unavailable for a week+.

I don't mind taking over, but my availability is not much better than yours :/

@MichaelMure
Copy link
Contributor Author

@hsanjuan I mean if you could shuffle the code around the way you want it, I can deal with the ground work around (doc and updating ipfs/kubo#6774)

@hsanjuan
Copy link
Contributor

ok, I have come to a better understanding here. Duplicating code is the only way I see of not making the core API option parsing even more convoluted than it already is.

@Stebalien LGTM.

@hsanjuan
Copy link
Contributor

@MichaelMure but do fix the docstrings please...

@MichaelMure MichaelMure requested a review from hsanjuan March 30, 2020 14:22
@MichaelMure
Copy link
Contributor Author

@hsanjuan thanks for the help :)

@Stebalien Stebalien merged commit ee0d435 into ipfs:master May 5, 2020
@Stebalien Stebalien mentioned this pull request May 26, 2020
77 tasks
guseggert pushed a commit to ipfs/boxo that referenced this pull request Dec 6, 2022
guseggert pushed a commit to ipfs/boxo that referenced this pull request Mar 15, 2023
Jorropo pushed a commit to ipfs/go-libipfs-rapide that referenced this pull request Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants