Skip to content

Commit

Permalink
add support for cluster volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraney committed Jun 27, 2023
1 parent 3f17bdd commit 9ffde85
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion convert/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ func convertVolumeToMount(
return handleTmpfsToMount(volume)
case "npipe":
return handleNpipeToMount(volume)
case "cluster":
return handleClusterToMount(volume)
}
return mount.Mount{}, errors.New("volume type must be volume, bind, tmpfs, or npipe")

return mount.Mount{}, errors.New("volume type must be volume, bind, tmpfs, npipe, or cluster")
}

func handleVolumeToMount(
Expand Down Expand Up @@ -148,6 +151,25 @@ func handleNpipeToMount(volume composego.ServiceVolumeConfig) (mount.Mount, erro
return result, nil
}

func handleClusterToMount(volume composego.ServiceVolumeConfig) (mount.Mount, error) {
result := createMountFromVolume(volume)
if volume.Source == "" {
return mount.Mount{}, errors.New("invalid cluster source, source cannot be empty")
}
if volume.Volume != nil {
return mount.Mount{}, errors.New("volume options are incompatible with type cluster")
}
if volume.Tmpfs != nil {
return mount.Mount{}, errors.New("tmpfs options are incompatible with type cluster")
}
if volume.Bind != nil {
result.BindOptions = &mount.BindOptions{
Propagation: mount.Propagation(volume.Bind.Propagation),
}
}
return result, nil
}

func createMountFromVolume(volume composego.ServiceVolumeConfig) mount.Mount {
return mount.Mount{
Type: mount.Type(volume.Type),
Expand Down

0 comments on commit 9ffde85

Please sign in to comment.