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
3e1cd71b
Commit
3e1cd71b
authored
Dec 13, 2018
by
Overbool
Committed by
Steven Allen
Jan 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmds/pin: use coreapi/pin
License: MIT Signed-off-by:
Overbool
<
overbool.xu@gmail.com
>
parent
3cc65786
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
options/pin.go
options/pin.go
+35
-1
pin.go
pin.go
+1
-1
No files found.
options/pin.go
View file @
3e1cd71b
...
@@ -8,12 +8,23 @@ type PinLsSettings struct {
...
@@ -8,12 +8,23 @@ type PinLsSettings struct {
Type
string
Type
string
}
}
// PinRmSettings represents the settings of pin rm command
type
PinRmSettings
struct
{
Recursive
bool
Force
bool
}
type
PinUpdateSettings
struct
{
type
PinUpdateSettings
struct
{
Unpin
bool
Unpin
bool
}
}
type
PinAddOption
func
(
*
PinAddSettings
)
error
type
PinAddOption
func
(
*
PinAddSettings
)
error
type
PinLsOption
func
(
settings
*
PinLsSettings
)
error
// PinRmOption pin rm option func
type
PinRmOption
func
(
*
PinRmSettings
)
error
// PinLsOption pin ls option func
type
PinLsOption
func
(
*
PinLsSettings
)
error
type
PinUpdateOption
func
(
*
PinUpdateSettings
)
error
type
PinUpdateOption
func
(
*
PinUpdateSettings
)
error
func
PinAddOptions
(
opts
...
PinAddOption
)
(
*
PinAddSettings
,
error
)
{
func
PinAddOptions
(
opts
...
PinAddOption
)
(
*
PinAddSettings
,
error
)
{
...
@@ -31,6 +42,21 @@ func PinAddOptions(opts ...PinAddOption) (*PinAddSettings, error) {
...
@@ -31,6 +42,21 @@ func PinAddOptions(opts ...PinAddOption) (*PinAddSettings, error) {
return
options
,
nil
return
options
,
nil
}
}
// PinRmOptions pin rm options
func
PinRmOptions
(
opts
...
PinRmOption
)
(
*
PinRmSettings
,
error
)
{
options
:=
&
PinRmSettings
{
Recursive
:
true
,
}
for
_
,
opt
:=
range
opts
{
if
err
:=
opt
(
options
);
err
!=
nil
{
return
nil
,
err
}
}
return
options
,
nil
}
func
PinLsOptions
(
opts
...
PinLsOption
)
(
*
PinLsSettings
,
error
)
{
func
PinLsOptions
(
opts
...
PinLsOption
)
(
*
PinLsSettings
,
error
)
{
options
:=
&
PinLsSettings
{
options
:=
&
PinLsSettings
{
Type
:
"all"
,
Type
:
"all"
,
...
@@ -102,6 +128,14 @@ func (pinOpts) Recursive(recursive bool) PinAddOption {
...
@@ -102,6 +128,14 @@ func (pinOpts) Recursive(recursive bool) PinAddOption {
}
}
}
}
// RmRecursive is an option for Pin.Rm
func
(
pinOpts
)
RmRecursive
(
recursive
bool
)
PinRmOption
{
return
func
(
settings
*
PinRmSettings
)
error
{
settings
.
Recursive
=
recursive
return
nil
}
}
// Type is an option for Pin.Ls which allows to specify which pin types should
// Type is an option for Pin.Ls which allows to specify which pin types should
// be returned
// be returned
//
//
...
...
pin.go
View file @
3e1cd71b
...
@@ -43,7 +43,7 @@ type PinAPI interface {
...
@@ -43,7 +43,7 @@ type PinAPI interface {
Ls
(
context
.
Context
,
...
options
.
PinLsOption
)
([]
Pin
,
error
)
Ls
(
context
.
Context
,
...
options
.
PinLsOption
)
([]
Pin
,
error
)
// Rm removes pin for object specified by the path
// Rm removes pin for object specified by the path
Rm
(
context
.
Context
,
Path
)
error
Rm
(
context
.
Context
,
Path
,
...
options
.
PinRmOption
)
error
// Update changes one pin to another, skipping checks for matching paths in
// Update changes one pin to another, skipping checks for matching paths in
// the old tree
// the old tree
...
...
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