Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Add support to volume v2 🐡 #339

Merged
merged 1 commit into from
Aug 8, 2016
Merged

Conversation

vdemeester
Copy link
Collaborator

@vdemeester vdemeester commented Jul 26, 2016

This PR brings the first and main step to add support for volumes for v2 compose files 🐹. Thanks to @joshwget and @shouze 🐳

  • Introduce new yaml.Volume{,s} struct
  • Introduce new docker/volume package (like network/volume)
  • Make sure tests are a little bit complete (at least)

This closes #277

/cc @joshwget

🐸

Signed-off-by: Vincent Demeester [email protected]

c.Volumes[k] = v
if isVolume(v) {
volumes[v] = struct{}{}
// FIXME(vdemeester) why do we do that ?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should remove that, this is handled here 👼

@@ -75,3 +75,23 @@ func (s *CliSuite) TestNamedVolume(c *C) {
c.Assert(cn.Mounts[0].Name, DeepEquals, "vol")
c.Assert(cn.Mounts[0].Destination, DeepEquals, "/path")
}

func (s *CliSuite) TestV2Volume(c *C) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shoud complete this one to make sure Bind and/or Mounts uses project_test as the name for the volume 👼

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an integration test for external volumes would be pretty useful as well.

for _, serviceName := range p.ServiceConfigs.Keys() {
serviceConfig, _ := p.ServiceConfigs.Get(serviceName)
// Consolidate the name of the volume
// FIXME(vdemeester) probably shouldn't be there, maybe move that to interface/factory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would definitely be useful if this logic could be customized 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, same comment here and for network, this logic will have to be extracted at some point to be easier to customize 😝

@vdemeester vdemeester force-pushed the v2-volumes branch 2 times, most recently from 2ace75c to dae0f46 Compare August 1, 2016 13:49
c.Volumes[k] = v
if isVolume(v) {
volumes[v] = struct{}{}
func volumes(c *config.ServiceConfig, ctx project.Context) []string {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function do not update serviceConfig anymore 👼

@vdemeester
Copy link
Collaborator Author

Unit tests / CI should be fixed 👼

@@ -337,6 +383,16 @@ func (p *Project) Down(ctx context.Context, opts options.Down, services ...strin
return err
}

if opts.RemoveVolume {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an option for Delete as well? I think the rm command also has a -v flag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum yes, rm has the -v flag 😛

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it's already handled for rm (but I'll have to check on docker-compose to see if it's removing the named volume too)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, checked, rm -v does not remove declared/named volumes, so it's working the same :)

@vdemeester vdemeester force-pushed the v2-volumes branch 2 times, most recently from 938eeb6 to f840802 Compare August 1, 2016 17:25
@vdemeester vdemeester force-pushed the v2-volumes branch 2 times, most recently from f0d5359 to 16b5512 Compare August 6, 2016 07:34
- Introduce new yaml.Volume{,s} struct
- Introduce new `docker/volume` package (like `network/volume`)

Signed-off-by: Vincent Demeester <[email protected]>
@vdemeester
Copy link
Collaborator Author

As it's green, let's merge this and push the 0.3.0 milestone. Will work on coverage and refactoring in follow-ups.

@vdemeester vdemeester merged commit 4dc7080 into docker:master Aug 8, 2016
@vdemeester vdemeester deleted the v2-volumes branch August 8, 2016 11:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Composefile v2: support volumes
2 participants