Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
478caf05
Unverified
Commit
478caf05
authored
Mar 30, 2020
by
Michael Muré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pin: better doc, small cleaning
parent
c82db2ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
12 deletions
+22
-12
options/pin.go
options/pin.go
+21
-11
tests/pin.go
tests/pin.go
+1
-1
No files found.
options/pin.go
View file @
478caf05
...
...
@@ -2,46 +2,48 @@ package options
import
"fmt"
// PinAddSettings represent the settings for PinAPI.Add
type
PinAddSettings
struct
{
Recursive
bool
}
type
TypeSettings
struct
{
Type
string
}
// PinLsSettings represent the settings for PinAPI.Ls
type
PinLsSettings
struct
{
Type
string
}
// PinIsPinnedSettings represent the settings for PinAPI.IsPinned
type
PinIsPinnedSettings
struct
{
WithType
string
}
// PinRmSettings represents the settings
of pin rm command
// PinRmSettings represents the settings
for PinAPI.Rm
type
PinRmSettings
struct
{
Recursive
bool
}
// PinUpdateSettings represent the settings for PinAPI.Update
type
PinUpdateSettings
struct
{
Unpin
bool
}
// PinAddOption
pin add option func
// PinAddOption
is the signature of an option for PinAPI.Add
type
PinAddOption
func
(
*
PinAddSettings
)
error
// PinLsOption
pin ls option func
// PinLsOption
is the signature of an option for PinAPI.Ls
type
PinLsOption
func
(
*
PinLsSettings
)
error
// PinIsPinnedOption
pin isPinned option func
// PinIsPinnedOption
is the signature of an option for PinAPI.IsPinned
type
PinIsPinnedOption
func
(
*
PinIsPinnedSettings
)
error
// PinRmOption
pin rm option func
// PinRmOption
is the signature of an option for PinAPI.Rm
type
PinRmOption
func
(
*
PinRmSettings
)
error
// PinUpdateOption
pin update option func
// PinUpdateOption
is the signature of an option for PinAPI.Update
type
PinUpdateOption
func
(
*
PinUpdateSettings
)
error
// PinAddOptions compile a series of PinAddOption into a ready to use
// PinAddSettings and set the default values.
func
PinAddOptions
(
opts
...
PinAddOption
)
(
*
PinAddSettings
,
error
)
{
options
:=
&
PinAddSettings
{
Recursive
:
true
,
...
...
@@ -57,6 +59,8 @@ func PinAddOptions(opts ...PinAddOption) (*PinAddSettings, error) {
return
options
,
nil
}
// PinLsOptions compile a series of PinLsOption into a ready to use
// PinLsSettings and set the default values.
func
PinLsOptions
(
opts
...
PinLsOption
)
(
*
PinLsSettings
,
error
)
{
options
:=
&
PinLsSettings
{
Type
:
"all"
,
...
...
@@ -72,6 +76,8 @@ func PinLsOptions(opts ...PinLsOption) (*PinLsSettings, error) {
return
options
,
nil
}
// PinIsPinnedOptions compile a series of PinIsPinnedOption into a ready to use
// PinIsPinnedSettings and set the default values.
func
PinIsPinnedOptions
(
opts
...
PinIsPinnedOption
)
(
*
PinIsPinnedSettings
,
error
)
{
options
:=
&
PinIsPinnedSettings
{
WithType
:
"all"
,
...
...
@@ -87,7 +93,8 @@ func PinIsPinnedOptions(opts ...PinIsPinnedOption) (*PinIsPinnedSettings, error)
return
options
,
nil
}
// PinRmOptions pin rm options
// PinRmOptions compile a series of PinRmOption into a ready to use
// PinRmSettings and set the default values.
func
PinRmOptions
(
opts
...
PinRmOption
)
(
*
PinRmSettings
,
error
)
{
options
:=
&
PinRmSettings
{
Recursive
:
true
,
...
...
@@ -102,6 +109,8 @@ func PinRmOptions(opts ...PinRmOption) (*PinRmSettings, error) {
return
options
,
nil
}
// PinUpdateOptions compile a series of PinUpdateOption into a ready to use
// PinUpdateSettings and set the default values.
func
PinUpdateOptions
(
opts
...
PinUpdateOption
)
(
*
PinUpdateSettings
,
error
)
{
options
:=
&
PinUpdateSettings
{
Unpin
:
true
,
...
...
@@ -122,6 +131,7 @@ type pinOpts struct {
IsPinned
pinIsPinnedOpts
}
// Pin provide an access to all the options for the Pin API.
var
Pin
pinOpts
type
pinLsOpts
struct
{}
...
...
tests/pin.go
View file @
478caf05
...
...
@@ -546,7 +546,7 @@ func assertIsPinned(t *testing.T, ctx context.Context, api iface.CoreAPI, p path
t
.
Helper
()
withType
,
err
:=
opt
.
Pin
.
IsPinned
.
Type
(
typeStr
)
if
err
!=
nil
{
panic
(
"unhandled pin type"
)
t
.
Fatal
(
"unhandled pin type"
)
}
whyPinned
,
pinned
,
err
:=
api
.
Pin
()
.
IsPinned
(
ctx
,
p
,
withType
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment