Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add composefile v1 / v2 parsing and validation support #573

Closed
wants to merge 2 commits into from

Conversation

vdemeester
Copy link
Collaborator

@vdemeester vdemeester commented Sep 29, 2017

This adds validation and parsing support to v1 and v2 in docker/cli/compose package. There is still a lot to decide on that one

  • Should it be supported or not by the cli (i.e. should docker stack deploy support other version than >= 3.0 or not)
  • What to do about cpu_share, cpu_quota and other removed field (either ignore them or update the struct)
  • support depends_on
  • support extends
  • edge cases ?

As of now, it allows to parse and validate v1, v2 and v3 composefile version in the same struct when using docker/cli/compose as a library.

/cc @shin-

boom

Allows validation of any composefile version from v1 to v3.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -11,6 +11,7 @@ import (
"github.com/docker/cli/cli/compose/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"path/filepath"
Copy link
Contributor

Choose a reason for hiding this comment

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

You should move this import up with other standard imports.

require.Error(t, err)
require.Contains(t, err.Error(), "version")

_, err = loadYAML(`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why testing the same error again?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right, I'll remove 😛

@dnephin
Copy link
Contributor

dnephin commented Oct 2, 2017

Should it be supported or not by the cli (i.e. should docker stack deploy support other version than >= 3.0 or not)

It should not be supported. The config does not match what is supported by services, and it doesn't make sense to once again create client-side logic for services.

Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Design LGTM

image: busybox
volume:
image: busybox
volumes:
Copy link
Contributor

Choose a reason for hiding this comment

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

if this is a "full" test it should probably include all the fields supported by v1 and one service with build, one with image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dnephin yeah I just copied the file from `docker/compose so far 😛

services:
web:
build: .
networks:
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, should include all the fields

mgoltzsche added a commit to mgoltzsche/ctnr that referenced this pull request Feb 25, 2018
Supports Docker Compose 3 format only. Older formats will be supported when docker/cli#573 is merged and containers/image updated their docker/docker dependency
mgoltzsche added a commit to mgoltzsche/ctnr that referenced this pull request Feb 25, 2018
Supports Docker Compose 3 format only. Older formats will be supported when
docker/cli#573 is merged and containers/image updated their docker/docker dependency
mgoltzsche added a commit to mgoltzsche/ctnr that referenced this pull request Feb 25, 2018
Supports Docker Compose 3 format only. Older formats will be supported when
docker/cli#573 is merged and containers/image updated their docker/docker dependency
mgoltzsche added a commit to mgoltzsche/ctnr that referenced this pull request Feb 25, 2018
Supports Docker Compose 3 format only. Older formats will be supported when
docker/cli#573 is merged and containers/image updated their docker/docker dependency
@vdemeester
Copy link
Collaborator Author

I'm gonna close this one as it is stale.
cc @chris-crone @silvin-lubecki @simonferquel fyi 👼

@vdemeester vdemeester closed this Mar 30, 2018
@vdemeester vdemeester deleted the parsing-v1-v2 branch March 30, 2018 16:53
@mgoltzsche
Copy link

mgoltzsche commented Mar 31, 2018

@vdemeester Why didn't you finish the implementation? The idea to provide a single code base that supports all compose versions was great. Now we still have to deal with various different parser implementations that could in theory differ from each other concerning the same compose version (besides the fact that the runtime implementations differ anyway). It creates more effort in other projects to support all compose versions. For local development it would also be very helpful if you could run Compose 2 projects with Docker CLI.

@olljanat
Copy link
Contributor

@vdemeester ping. Look @mgoltzsche question above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants