2018-07-11 10:39:20 +02:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
2019-03-21 14:20:14 +13:00
|
|
|
"github.com/portainer/portainer/api"
|
2018-07-11 10:39:20 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Snapshotter represents a service used to create endpoint snapshots
|
|
|
|
type Snapshotter struct {
|
|
|
|
clientFactory *ClientFactory
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewSnapshotter returns a new Snapshotter instance
|
|
|
|
func NewSnapshotter(clientFactory *ClientFactory) *Snapshotter {
|
|
|
|
return &Snapshotter{
|
|
|
|
clientFactory: clientFactory,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateSnapshot creates a snapshot of a specific endpoint
|
|
|
|
func (snapshotter *Snapshotter) CreateSnapshot(endpoint *portainer.Endpoint) (*portainer.Snapshot, error) {
|
2018-10-28 07:06:50 +01:00
|
|
|
cli, err := snapshotter.clientFactory.CreateClient(endpoint, "")
|
2018-07-11 10:39:20 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2018-09-05 08:44:04 +02:00
|
|
|
defer cli.Close()
|
2018-07-11 10:39:20 +02:00
|
|
|
|
2019-09-20 16:13:44 +12:00
|
|
|
return snapshot(cli, endpoint)
|
2018-07-11 10:39:20 +02:00
|
|
|
}
|