fix: return err not logrus + new lines
This commit is contained in:
parent
262009701e
commit
c66695d55e
@ -5,11 +5,9 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetVolumes(ctx context.Context, server string, appName string) ([]*types.Volume, error) {
|
func GetVolumes(ctx context.Context, server string, appName string) ([]*types.Volume, error) {
|
||||||
|
|
||||||
cl, err := New(server)
|
cl, err := New(server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -21,7 +19,7 @@ func GetVolumes(ctx context.Context, server string, appName string) ([]*types.Vo
|
|||||||
volumeListOKBody, err := cl.VolumeList(ctx, fs)
|
volumeListOKBody, err := cl.VolumeList(ctx, fs)
|
||||||
volumeList := volumeListOKBody.Volumes
|
volumeList := volumeListOKBody.Volumes
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
return volumeList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return volumeList, nil
|
return volumeList, nil
|
||||||
@ -29,9 +27,11 @@ func GetVolumes(ctx context.Context, server string, appName string) ([]*types.Vo
|
|||||||
|
|
||||||
func GetVolumeNames(volumes []*types.Volume) []string {
|
func GetVolumeNames(volumes []*types.Volume) []string {
|
||||||
var volumeNames []string
|
var volumeNames []string
|
||||||
|
|
||||||
for _, vol := range volumes {
|
for _, vol := range volumes {
|
||||||
volumeNames = append(volumeNames, vol.Name)
|
volumeNames = append(volumeNames, vol.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return volumeNames
|
return volumeNames
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,12 +40,13 @@ func RemoveVolumes(ctx context.Context, server string, volumeNames []string, for
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, volName := range volumeNames {
|
for _, volName := range volumeNames {
|
||||||
err := cl.VolumeRemove(ctx, volName, force)
|
err := cl.VolumeRemove(ctx, volName, force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user