瀏覽代碼

Merge pull request #32409 from dnephin/support-consistency-params-in-compose

Add support for volume consistency in compose format
Victor Vieux 8 年之前
父節點
當前提交
fc6d8fb94d

+ 5 - 4
cli/compose/convert/volume.go

@@ -28,10 +28,11 @@ func convertVolumeToMount(
 	namespace Namespace,
 ) (mount.Mount, error) {
 	result := mount.Mount{
-		Type:     mount.Type(volume.Type),
-		Source:   volume.Source,
-		Target:   volume.Target,
-		ReadOnly: volume.ReadOnly,
+		Type:        mount.Type(volume.Type),
+		Source:      volume.Source,
+		Target:      volume.Target,
+		ReadOnly:    volume.ReadOnly,
+		Consistency: mount.Consistency(volume.Consistency),
 	}
 
 	// Anonymous volumes

+ 4 - 0
cli/compose/loader/full-example.yml

@@ -220,6 +220,10 @@ services:
       - ~/configs:/etc/configs/:ro
       # Named volume
       - datavolume:/var/lib/mysql
+      - type: bind
+        source: ./opt
+        target: /opt
+        consistency: cached
 
     working_dir: /code
 

+ 1 - 0
cli/compose/loader/loader_test.go

@@ -910,6 +910,7 @@ func TestFullExample(t *testing.T) {
 			{Source: workingDir + "/static", Target: "/var/www/html", Type: "bind"},
 			{Source: homeDir + "/configs", Target: "/etc/configs/", Type: "bind", ReadOnly: true},
 			{Source: "datavolume", Target: "/var/lib/mysql", Type: "volume"},
+			{Source: workingDir + "/opt", Target: "/opt", Consistency: "cached", Type: "bind"},
 		},
 		WorkingDir: "/code",
 	}

文件差異過大導致無法顯示
+ 0 - 0
cli/compose/schema/bindata.go


+ 1 - 0
cli/compose/schema/data/config_schema_v3.2.json

@@ -249,6 +249,7 @@
                   "source": {"type": "string"},
                   "target": {"type": "string"},
                   "read_only": {"type": "boolean"},
+                  "consistency": {"type": "string"},
                   "bind": {
                     "type": "object",
                     "properties": {

+ 7 - 6
cli/compose/types/types.go

@@ -229,12 +229,13 @@ type ServicePortConfig struct {
 
 // ServiceVolumeConfig are references to a volume used by a service
 type ServiceVolumeConfig struct {
-	Type     string
-	Source   string
-	Target   string
-	ReadOnly bool `mapstructure:"read_only"`
-	Bind     *ServiceVolumeBind
-	Volume   *ServiceVolumeVolume
+	Type        string
+	Source      string
+	Target      string
+	ReadOnly    bool `mapstructure:"read_only"`
+	Consistency string
+	Bind        *ServiceVolumeBind
+	Volume      *ServiceVolumeVolume
 }
 
 // ServiceVolumeBind are options for a service volume of type bind

部分文件因文件數量過多而無法顯示