Skip to content

Commit

Permalink
Change to enable volume name can be customized.
Browse files Browse the repository at this point in the history
Signed-off-by: Liping Xue <lipingxue@gmail.com>
  • Loading branch information
lipingxue authored and dnephin committed Jul 14, 2017
1 parent 722e75d commit 9ada891
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cli/compose/convert/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func convertVolumeToMount(
return result, nil
}

if stackVolume.Name != "" {
result.Source = stackVolume.Name
}

result.VolumeOptions.Labels = AddStackLabel(namespace, stackVolume.Labels)
if stackVolume.Driver != "" || stackVolume.DriverOpts != nil {
result.VolumeOptions.DriverConfig = &mount.Driver{
Expand Down
7 changes: 7 additions & 0 deletions cli/compose/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,14 @@ func LoadVolumes(source map[string]interface{}) (map[string]types.VolumeConfig,
if volume.External.Name == "" {
volume.External.Name = name
volumes[name] = volume
} else {
logrus.Warnf("Volume %s: volume.external.name is deprecated, use volume.name", name)
if volume.Name != "" {
return nil, errors.Errorf("volume %s: both volume.external.name "+
"and volume.name can not be set. Use volume.name.", name)
}
}

}
}
return volumes, nil
Expand Down
2 changes: 1 addition & 1 deletion cli/compose/schema/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cli/compose/schema/data/config_schema_v3.4.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "config_schema_v3.3.json",
"id": "config_schema_v3.4.json",
"type": "object",
"required": ["version"],

Expand Down Expand Up @@ -437,6 +437,7 @@
"id": "#/definitions/volume",
"type": ["object", "null"],
"properties": {
"name": {"type": "string"},
"driver": {"type": "string"},
"driver_opts": {
"type": "object",
Expand Down
1 change: 1 addition & 0 deletions cli/compose/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ type IPAMPool struct {

// VolumeConfig for a volume
type VolumeConfig struct {
Name string
Driver string
DriverOpts map[string]string `mapstructure:"driver_opts"`
External External
Expand Down

0 comments on commit 9ada891

Please sign in to comment.