Massive architectural rework
This commit massively overhauls the project's structure to simplify development. Most parts are now correctly compartmentalized and dependencies are passed in a sane way rather than global variables galore xd.
This commit is contained in:
37
internal/docker/volume.go
Normal file
37
internal/docker/volume.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type DockerVolume struct {
|
||||
VolumeID string
|
||||
Mountpoint string
|
||||
}
|
||||
|
||||
func (d *DockerClient) CreateDockerVolume(ctx context.Context) (vol *DockerVolume, err error) {
|
||||
dockerVolume, err := d.client.VolumeCreate(ctx, volume.CreateOptions{
|
||||
Driver: "local",
|
||||
DriverOpts: map[string]string{},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create volume: %v", err)
|
||||
}
|
||||
|
||||
d.logger.Debugw("Volume created", zap.String("volume_id", dockerVolume.Name), zap.String("mountpoint", dockerVolume.Mountpoint))
|
||||
|
||||
vol = &DockerVolume{
|
||||
VolumeID: dockerVolume.Name,
|
||||
}
|
||||
|
||||
return vol, nil
|
||||
}
|
||||
|
||||
func (d *DockerClient) DeleteDockerVolume(ctx context.Context, volumeID string) error {
|
||||
d.logger.Debugw("Removing volume", zap.String("volume_id", volumeID))
|
||||
return d.client.VolumeRemove(ctx, volumeID, true)
|
||||
}
|
||||
Reference in New Issue
Block a user