Begin volume listing
This commit is contained in:
parent
c06b72f8e8
commit
5043bad469
4
go.mod
4
go.mod
|
@ -1,3 +1,7 @@
|
|||
module git.rdelaage.ovh/rdelaage/VolumesAndDatabasesBackup
|
||||
|
||||
require (
|
||||
github.com/docker/docker v20.10.11
|
||||
)
|
||||
|
||||
go 1.17
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package volumes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"context"
|
||||
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
)
|
||||
|
||||
func listVolumesToBeBackedUp() ([]string, error) {
|
||||
var (
|
||||
cli client.Client
|
||||
err error
|
||||
volumeListOKBody volume.VolumeListOKBody
|
||||
ctx context.Context
|
||||
)
|
||||
|
||||
volumesList := make([]string)
|
||||
|
||||
cli, err = client.NewClientWithOpts()
|
||||
if err != nil {
|
||||
return volumesList, fmt.Errorf("Could not create client: %s", err.Error())
|
||||
}
|
||||
|
||||
ctx = context.Background()
|
||||
volumeListOKBody, err = cli.VolumeList(ctx, filters.NewArgs())
|
||||
if err != nil {
|
||||
return volumesList, fmt.Errorf("Could not list volumes: %s", err.Error())
|
||||
}
|
||||
|
||||
for volume, _ := range volumeListOKBody.Volumes {
|
||||
//check no disable label
|
||||
//add hash in volume list
|
||||
}
|
||||
|
||||
return volumesList, nil
|
||||
}
|
Loading…
Reference in New Issue