2021-11-09 08:07:49 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-04-05 11:13:34 +00:00
|
|
|
"fmt"
|
2021-11-09 08:07:49 +00:00
|
|
|
|
2023-03-07 11:20:03 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
2021-11-09 08:07:49 +00:00
|
|
|
)
|
|
|
|
|
2022-04-26 15:03:14 +00:00
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// Returns any network/parsing config errors.
|
|
|
|
//
|
|
|
|
// See also NetworkInfo, container.ApplyNetworkConfig.
|
|
|
|
func SyncContainerWithNetwork(ctx context.Context, cnr *container.Container, c *Client) error {
|
|
|
|
res, err := c.NetworkInfo(ctx, PrmNetworkInfo{})
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("network info call: %w", err)
|
|
|
|
}
|
|
|
|
|
2022-08-05 07:56:49 +00:00
|
|
|
container.ApplyNetworkConfig(cnr, res.Info())
|
2022-04-26 15:03:14 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|