forked from TrueCloudLab/frostfs-api-go
[#142] sdk/container: Add converters to and from v2
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
012cea1add
commit
3c7c363002
2 changed files with 22 additions and 10 deletions
|
@ -8,7 +8,7 @@ type Container struct {
|
|||
container.Container
|
||||
}
|
||||
|
||||
func New(opts ...NewOption) (*Container, error) {
|
||||
func New(opts ...NewOption) *Container {
|
||||
cnrOptions := defaultContainerOptions()
|
||||
for i := range opts {
|
||||
opts[i].apply(&cnrOptions)
|
||||
|
@ -18,14 +18,14 @@ func New(opts ...NewOption) (*Container, error) {
|
|||
cnr.SetNonce(cnrOptions.nonce[:])
|
||||
cnr.SetBasicACL(cnrOptions.acl)
|
||||
|
||||
if cnrOptions.policy != "" {
|
||||
// todo: set placement policy
|
||||
}
|
||||
|
||||
if cnrOptions.owner != nil {
|
||||
cnr.SetOwnerID(cnrOptions.owner.ToV2())
|
||||
}
|
||||
|
||||
if cnrOptions.policy != nil {
|
||||
cnr.SetPlacementPolicy(cnrOptions.policy)
|
||||
}
|
||||
|
||||
attributes := make([]*container.Attribute, len(cnrOptions.attributes))
|
||||
for i := range cnrOptions.attributes {
|
||||
attribute := new(container.Attribute)
|
||||
|
@ -37,5 +37,19 @@ func New(opts ...NewOption) (*Container, error) {
|
|||
cnr.SetAttributes(attributes)
|
||||
}
|
||||
|
||||
return cnr, nil
|
||||
return cnr
|
||||
}
|
||||
|
||||
func (c Container) ToV2() *container.Container {
|
||||
return &c.Container
|
||||
}
|
||||
|
||||
func NewContainerFromV2(c *container.Container) *Container {
|
||||
cnr := new(Container)
|
||||
|
||||
if c != nil {
|
||||
cnr.Container = *c
|
||||
}
|
||||
|
||||
return cnr
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue