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

Commit ca13e9b

Browse files
committed
coreapi: Pin option for Object.Put
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
1 parent ebc2b35 commit ca13e9b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

options/object.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type ObjectNewSettings struct {
77
type ObjectPutSettings struct {
88
InputEnc string
99
DataType string
10+
Pin bool
1011
}
1112

1213
type ObjectAddLinkSettings struct {
@@ -35,6 +36,7 @@ func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) {
3536
options := &ObjectPutSettings{
3637
InputEnc: "json",
3738
DataType: "text",
39+
Pin: false,
3840
}
3941

4042
for _, opt := range opts {
@@ -103,6 +105,15 @@ func (objectOpts) DataType(t string) ObjectPutOption {
103105
}
104106
}
105107

108+
// WithPin is an option for Object.Put which specifies whether to pin the added
109+
// objects, default is false
110+
func (objectOpts) WithPin(pin bool) ObjectPutOption {
111+
return func(settings *ObjectPutSettings) error {
112+
settings.Pin = pin
113+
return nil
114+
}
115+
}
116+
106117
// Create is an option for Object.AddLink which specifies whether create required
107118
// directories for the child
108119
func (objectOpts) Create(create bool) ObjectAddLinkOption {

0 commit comments

Comments
 (0)