Commit 2e3f9758 authored by Łukasz Magiera's avatar Łukasz Magiera

coreapi: use defined functions for pin type option

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent 38ccf055
......@@ -61,10 +61,38 @@ func PinUpdateOptions(opts ...PinUpdateOption) (*PinUpdateSettings, error) {
return options, nil
}
type pinOpts struct{}
type pinType struct{}
type pinOpts struct {
Type pinType
}
var Pin pinOpts
// All is an option for Pin.Ls which will make it return all pins. It is
// the default
func (_ pinType) All() PinLsOption {
return Pin.pinType("all")
}
// Recursive is an option for Pin.Ls which will make it only return recursive
// pins
func (_ pinType) Recursive() PinLsOption {
return Pin.pinType("recursive")
}
// Direct is an option for Pin.Ls which will make it only return direct (non
// recursive) pins
func (_ pinType) Direct() PinLsOption {
return Pin.pinType("direct")
}
// Indirect is an option for Pin.Ls which will make it only return indirect pins
// (objects referenced by other recursively pinned objects)
func (_ pinType) Indirect() PinLsOption {
return Pin.pinType("indirect")
}
// Recursive is an option for Pin.Add which specifies whether to pin an entire
// object tree or just one object. Default: true
func (_ pinOpts) Recursive(recucsive bool) PinAddOption {
......@@ -83,7 +111,7 @@ func (_ pinOpts) Recursive(recucsive bool) PinAddOption {
// * "indirect" - indirectly pinned objects (referenced by recursively pinned
// objects)
// * "all" - all pinned objects (default)
func (_ pinOpts) Type(t string) PinLsOption {
func (_ pinOpts) pinType(t string) PinLsOption {
return func(settings *PinLsSettings) error {
settings.Type = t
return nil
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment