@@ -774,18 +774,50 @@ func buildMount(project types.Project, volume types.ServiceVolumeConfig) (mount.
774
774
}
775
775
}
776
776
777
+ bind , vol , tmpfs := buildMountOptions (volume )
778
+
777
779
return mount.Mount {
778
780
Type : mount .Type (volume .Type ),
779
781
Source : source ,
780
782
Target : volume .Target ,
781
783
ReadOnly : volume .ReadOnly ,
782
784
Consistency : mount .Consistency (volume .Consistency ),
783
- BindOptions : buildBindOption ( volume . Bind ) ,
784
- VolumeOptions : buildVolumeOptions ( volume . Volume ) ,
785
- TmpfsOptions : buildTmpfsOptions ( volume . Tmpfs ) ,
785
+ BindOptions : bind ,
786
+ VolumeOptions : vol ,
787
+ TmpfsOptions : tmpfs ,
786
788
}, nil
787
789
}
788
790
791
+ func buildMountOptions (volume types.ServiceVolumeConfig ) (* mount.BindOptions , * mount.VolumeOptions , * mount.TmpfsOptions ) {
792
+ switch volume .Type {
793
+ case "bind" :
794
+ if volume .Volume != nil {
795
+ logrus .Warnf ("mount of type `bind` should not define `volume` option" )
796
+ }
797
+ if volume .Tmpfs != nil {
798
+ logrus .Warnf ("mount of type `tmpfs` should not define `tmpfs` option" )
799
+ }
800
+ return buildBindOption (volume .Bind ), nil , nil
801
+ case "volume" :
802
+ if volume .Bind != nil {
803
+ logrus .Warnf ("mount of type `volume` should not define `bind` option" )
804
+ }
805
+ if volume .Tmpfs != nil {
806
+ logrus .Warnf ("mount of type `volume` should not define `tmpfs` option" )
807
+ }
808
+ return nil , buildVolumeOptions (volume .Volume ), nil
809
+ case "tmpfs" :
810
+ if volume .Bind != nil {
811
+ logrus .Warnf ("mount of type `tmpfs` should not define `bind` option" )
812
+ }
813
+ if volume .Tmpfs != nil {
814
+ logrus .Warnf ("mount of type `tmpfs` should not define `volumeZ` option" )
815
+ }
816
+ return nil , nil , buildTmpfsOptions (volume .Tmpfs )
817
+ }
818
+ return nil , nil , nil
819
+ }
820
+
789
821
func buildBindOption (bind * types.ServiceVolumeBind ) * mount.BindOptions {
790
822
if bind == nil {
791
823
return nil
0 commit comments