diff --git a/client/container.go b/client/container.go index 85080b24..d7b06790 100644 --- a/client/container.go +++ b/client/container.go @@ -640,16 +640,17 @@ func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, announcements [ return nil } -// SyncContainerWithNetwork requests network configuration using passed client -// and applies it to the container. Container MUST not be nil. -// -// Note: if container does not match network configuration, SyncContainerWithNetwork -// changes it. +// SyncContainerWithNetwork requests network configuration using passed [NetworkInfoExecutor] +// and applies/rewrites it to the container. // // Returns any network/parsing config errors. // -// See also NetworkInfo, container.ApplyNetworkConfig. -func SyncContainerWithNetwork(ctx context.Context, cnr *container.Container, c *Client) error { +// See also [client.Client.NetworkInfo], [container.Container.ApplyNetworkConfig]. +func SyncContainerWithNetwork(ctx context.Context, cnr *container.Container, c NetworkInfoExecutor) error { + if cnr == nil { + return errors.New("empty container") + } + res, err := c.NetworkInfo(ctx, PrmNetworkInfo{}) if err != nil { return fmt.Errorf("network info call: %w", err) diff --git a/client/netmap.go b/client/netmap.go index 8c822d30..d0f4bae5 100644 --- a/client/netmap.go +++ b/client/netmap.go @@ -19,6 +19,11 @@ var ( rpcAPILocalNodeInfo = rpcapi.LocalNodeInfo ) +// NetworkInfoExecutor describes methods to get network information. +type NetworkInfoExecutor interface { + NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (netmap.NetworkInfo, error) +} + // PrmEndpointInfo groups parameters of EndpointInfo operation. type PrmEndpointInfo struct { prmCommonMeta diff --git a/pool/pool.go b/pool/pool.go index 2ef04786..54c1f98e 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -2193,25 +2193,6 @@ func (p *Pool) Close() { <-p.closedCh } -// SyncContainerWithNetwork applies network configuration received via -// the Pool to the container. Changes the container if it does not satisfy -// network configuration. -// -// Pool and container MUST not be nil. -// -// Returns any error that does not allow reading configuration -// from the network. -func SyncContainerWithNetwork(ctx context.Context, cnr *container.Container, p *Pool) error { - ni, err := p.NetworkInfo(ctx, sdkClient.PrmNetworkInfo{}) - if err != nil { - return fmt.Errorf("network info: %w", err) - } - - cnr.ApplyNetworkConfig(ni) - - return nil -} - func (p *Pool) sdkClient() (*sdkClient.Client, error) { conn, err := p.connection() if err != nil {