2018-07-11 08:39:20 +00:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
2019-03-21 01:20:14 +00:00
|
|
|
"github.com/portainer/portainer/api"
|
2018-07-11 08:39:20 +00: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 06:06:50 +00:00
|
|
|
cli, err := snapshotter.clientFactory.CreateClient(endpoint, "")
|
2018-07-11 08:39:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2018-09-05 06:44:04 +00:00
|
|
|
defer cli.Close()
|
2018-07-11 08:39:20 +00:00
|
|
|
|
2019-09-20 04:13:44 +00:00
|
|
|
return snapshot(cli, endpoint)
|
2018-07-11 08:39:20 +00:00
|
|
|
}
|