git.frostfs.info/TrueCloudLab/frostfs-sdk-go@v0.0.0-20241022124111-5361f0ecebd3/client/container.go (about)

     1  package client
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
     8  )
     9  
    10  // SyncContainerWithNetwork requests network configuration using passed client
    11  // and applies it to the container. Container MUST not be nil.
    12  //
    13  // Note: if container does not match network configuration, SyncContainerWithNetwork
    14  // changes it.
    15  //
    16  // Returns any network/parsing config errors.
    17  //
    18  // See also NetworkInfo, container.ApplyNetworkConfig.
    19  func SyncContainerWithNetwork(ctx context.Context, cnr *container.Container, c *Client) error {
    20  	res, err := c.NetworkInfo(ctx, PrmNetworkInfo{})
    21  	if err != nil {
    22  		return fmt.Errorf("network info call: %w", err)
    23  	}
    24  
    25  	container.ApplyNetworkConfig(cnr, res.Info())
    26  
    27  	return nil
    28  }