Make PrmContainerSetEACL fields public for client and pool #148
2 changed files with 41 additions and 39 deletions
|
@ -18,20 +18,20 @@ import (
|
||||||
|
|
||||||
// PrmContainerSetEACL groups parameters of ContainerSetEACL operation.
|
// PrmContainerSetEACL groups parameters of ContainerSetEACL operation.
|
||||||
type PrmContainerSetEACL struct {
|
type PrmContainerSetEACL struct {
|
||||||
prmCommonMeta
|
// FrostFS request X-Headers.
|
||||||
|
XHeaders []string
|
||||||
|
|
||||||
tableSet bool
|
Table *eacl.Table
|
||||||
table eacl.Table
|
|
||||||
|
|
||||||
sessionSet bool
|
Session *session.Container
|
||||||
session session.Container
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTable sets eACL table structure to be set for the container.
|
// SetTable sets eACL table structure to be set for the container.
|
||||||
// Required parameter.
|
// Required parameter.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmContainerSetEACL.Table instead.
|
||||||
func (x *PrmContainerSetEACL) SetTable(table eacl.Table) {
|
func (x *PrmContainerSetEACL) SetTable(table eacl.Table) {
|
||||||
x.table = table
|
x.Table = &table
|
||||||
x.tableSet = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithinSession specifies session within which extended ACL of the container
|
// WithinSession specifies session within which extended ACL of the container
|
||||||
|
@ -45,17 +45,22 @@ func (x *PrmContainerSetEACL) SetTable(table eacl.Table) {
|
||||||
// for which extended ACL is going to be set
|
// for which extended ACL is going to be set
|
||||||
// - session operation MUST be session.VerbContainerSetEACL (ForVerb)
|
// - session operation MUST be session.VerbContainerSetEACL (ForVerb)
|
||||||
// - token MUST be signed using private key of the owner of the container to be saved
|
// - token MUST be signed using private key of the owner of the container to be saved
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmContainerSetEACL.Session instead.
|
||||||
func (x *PrmContainerSetEACL) WithinSession(s session.Container) {
|
func (x *PrmContainerSetEACL) WithinSession(s session.Container) {
|
||||||
x.session = s
|
x.Session = &s
|
||||||
x.sessionSet = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PrmContainerSetEACL) buildRequest(c *Client) (*v2container.SetExtendedACLRequest, error) {
|
func (x *PrmContainerSetEACL) buildRequest(c *Client) (*v2container.SetExtendedACLRequest, error) {
|
||||||
if !x.tableSet {
|
if x.Table == nil {
|
||||||
return nil, errorEACLTableNotSet
|
return nil, errorEACLTableNotSet
|
||||||
}
|
}
|
||||||
|
|
||||||
eaclV2 := x.table.ToV2()
|
if len(x.XHeaders)%2 != 0 {
|
||||||
|
return nil, errorInvalidXHeaders
|
||||||
|
}
|
||||||
|
|
||||||
|
eaclV2 := x.Table.ToV2()
|
||||||
|
|
||||||
var sig frostfscrypto.Signature
|
var sig frostfscrypto.Signature
|
||||||
|
|
||||||
|
@ -72,11 +77,11 @@ func (x *PrmContainerSetEACL) buildRequest(c *Client) (*v2container.SetExtendedA
|
||||||
reqBody.SetSignature(&sigv2)
|
reqBody.SetSignature(&sigv2)
|
||||||
|
|
||||||
var meta v2session.RequestMetaHeader
|
var meta v2session.RequestMetaHeader
|
||||||
writeXHeadersToMeta(x.prmCommonMeta.xHeaders, &meta)
|
writeXHeadersToMeta(x.XHeaders, &meta)
|
||||||
|
|
||||||
if x.sessionSet {
|
if x.Session != nil {
|
||||||
var tokv2 v2session.Token
|
var tokv2 v2session.Token
|
||||||
x.session.WriteToV2(&tokv2)
|
x.Session.WriteToV2(&tokv2)
|
||||||
|
|
||||||
meta.SetSessionToken(&tokv2)
|
meta.SetSessionToken(&tokv2)
|
||||||
}
|
}
|
||||||
|
|
47
pool/pool.go
47
pool/pool.go
|
@ -549,11 +549,9 @@ func (c *clientWrapper) containerSetEACL(ctx context.Context, prm PrmContainerSe
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var cliPrm sdkClient.PrmContainerSetEACL
|
cliPrm := sdkClient.PrmContainerSetEACL{
|
||||||
cliPrm.SetTable(prm.table)
|
Table: &prm.Table,
|
||||||
|
Session: prm.Session,
|
||||||
if prm.sessionSet {
|
|
||||||
cliPrm.WithinSession(prm.session)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
@ -567,16 +565,19 @@ func (c *clientWrapper) containerSetEACL(ctx context.Context, prm PrmContainerSe
|
||||||
return fmt.Errorf("set eacl on client: %w", err)
|
return fmt.Errorf("set eacl on client: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !prm.waitParamsSet {
|
if prm.WaitParams == nil {
|
||||||
prm.waitParams.setDefaults()
|
prm.WaitParams = defaultWaitParams()
|
||||||
|
}
|
||||||
|
if err := prm.WaitParams.CheckValidity(); err != nil {
|
||||||
|
return fmt.Errorf("invalid wait parameters: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var cIDp *cid.ID
|
var cIDp *cid.ID
|
||||||
if cID, set := prm.table.CID(); set {
|
if cID, set := prm.Table.CID(); set {
|
||||||
cIDp = &cID
|
cIDp = &cID
|
||||||
}
|
}
|
||||||
|
|
||||||
err = waitForEACLPresence(ctx, c, cIDp, &prm.table, &prm.waitParams)
|
err = waitForEACLPresence(ctx, c, cIDp, &prm.Table, prm.WaitParams)
|
||||||
if err = c.handleError(ctx, nil, err); err != nil {
|
if err = c.handleError(ctx, nil, err); err != nil {
|
||||||
return fmt.Errorf("wait eacl presence on client: %w", err)
|
return fmt.Errorf("wait eacl presence on client: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -1227,12 +1228,6 @@ func (x *WaitParams) SetPollInterval(tick time.Duration) {
|
||||||
x.PollInterval = tick
|
x.PollInterval = tick
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use defaultWaitParams() instead.
|
|
||||||
func (x *WaitParams) setDefaults() {
|
|
||||||
x.Timeout = 120 * time.Second
|
|
||||||
x.PollInterval = 5 * time.Second
|
|
||||||
}
|
|
||||||
|
|
||||||
func defaultWaitParams() *WaitParams {
|
func defaultWaitParams() *WaitParams {
|
||||||
return &WaitParams{
|
return &WaitParams{
|
||||||
Timeout: 120 * time.Second,
|
Timeout: 120 * time.Second,
|
||||||
|
@ -1532,39 +1527,41 @@ func (x *PrmContainerEACL) SetContainerID(cnrID cid.ID) {
|
||||||
|
|
||||||
// PrmContainerSetEACL groups parameters of SetEACL operation.
|
// PrmContainerSetEACL groups parameters of SetEACL operation.
|
||||||
type PrmContainerSetEACL struct {
|
type PrmContainerSetEACL struct {
|
||||||
table eacl.Table
|
Table eacl.Table
|
||||||
|
|
||||||
sessionSet bool
|
Session *session.Container
|
||||||
session session.Container
|
|
||||||
|
|
||||||
waitParams WaitParams
|
WaitParams *WaitParams
|
||||||
waitParamsSet bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTable sets structure of container's extended ACL to be used as a
|
// SetTable sets structure of container's extended ACL to be used as a
|
||||||
// parameter of the base client's operation.
|
// parameter of the base client's operation.
|
||||||
//
|
//
|
||||||
// See git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client.PrmContainerSetEACL.SetTable.
|
// See git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client.PrmContainerSetEACL.SetTable.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmContainerSetEACL.Table instead.
|
||||||
func (x *PrmContainerSetEACL) SetTable(table eacl.Table) {
|
func (x *PrmContainerSetEACL) SetTable(table eacl.Table) {
|
||||||
x.table = table
|
x.Table = table
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithinSession specifies session to be used as a parameter of the base
|
// WithinSession specifies session to be used as a parameter of the base
|
||||||
// client's operation.
|
// client's operation.
|
||||||
//
|
//
|
||||||
// See git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client.PrmContainerSetEACL.WithinSession.
|
// See git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client.PrmContainerSetEACL.WithinSession.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmContainerSetEACL.Session instead.
|
||||||
func (x *PrmContainerSetEACL) WithinSession(s session.Container) {
|
func (x *PrmContainerSetEACL) WithinSession(s session.Container) {
|
||||||
x.session = s
|
x.Session = &s
|
||||||
x.sessionSet = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWaitParams specifies timeout params to complete operation.
|
// SetWaitParams specifies timeout params to complete operation.
|
||||||
// If not provided the default one will be used.
|
// If not provided the default one will be used.
|
||||||
// Panics if any of the wait params isn't positive.
|
// Panics if any of the wait params isn't positive.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmContainerSetEACL.WaitParams instead.
|
||||||
func (x *PrmContainerSetEACL) SetWaitParams(waitParams WaitParams) {
|
func (x *PrmContainerSetEACL) SetWaitParams(waitParams WaitParams) {
|
||||||
waitParams.checkForPositive()
|
waitParams.checkForPositive()
|
||||||
x.waitParams = waitParams
|
x.WaitParams = &waitParams
|
||||||
x.waitParamsSet = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrmBalanceGet groups parameters of Balance operation.
|
// PrmBalanceGet groups parameters of Balance operation.
|
||||||
|
|
Loading…
Reference in a new issue