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 'build' to types.go #481

Merged
merged 1 commit into from
Sep 13, 2017

Conversation

cdrage
Copy link
Contributor

@cdrage cdrage commented Aug 29, 2017

This adds 'build' to types.go in order for projects that use docker/cli
to parse Docker Compose files to correctly retrieve build keys.

@cdrage
Copy link
Contributor Author

cdrage commented Aug 29, 2017

ping @vdemeester @dnephin

This unblocks us on kubernetes/kompose#636

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.

Once the other fields are added please add them to the full-example.yml as well.

type BuildConfig struct {
Context string
Dockerfile string
Args map[string]*string
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks incomplete. It should have all the fields from here:

"context": {"type": "string"},
"dockerfile": {"type": "string"},
"args": {"$ref": "#/definitions/list_or_dict"},
"labels": {"$ref": "#/definitions/list_or_dict"},
"cache_from": {"$ref": "#/definitions/list_of_strings"},
"network": {"type": "string"},
"target": {"type": "string"}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dnephin I'm following @vdemeester 's implementation, but sure, I'll add the other options.

@@ -6,7 +6,6 @@ import (

// UnsupportedProperties not yet supported by this implementation of the compose file
var UnsupportedProperties = []string{
"build",
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to keep build in the list of unsupported properties because it's still not used by the cli right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dnephin Okay 👍

@cdrage
Copy link
Contributor Author

cdrage commented Aug 29, 2017

Man you're fast, I'm just fixing the tests failing now @dnephin

I've already added the build keys from types.go to the full-example.

Other than that, it's adding the rest of the types from the schema document.

@cdrage cdrage force-pushed the add-build-to-service-config branch 3 times, most recently from be81f80 to e0255ba Compare August 29, 2017 21:18
@cdrage
Copy link
Contributor Author

cdrage commented Aug 29, 2017

Problem I have @dnephin in regards to adding build to unsupported is that it fails to build / be used... How is it possible to add build to the supported types but still have it "unsupported"? When we parse the YAML it still exits ( see the failing test in circleci)

@dnephin
Copy link
Contributor

dnephin commented Aug 29, 2017

The test failure is because the example config in that test is using a string for build. If you update the test to be something like this, it should work:

build:
  context: ./web

Unsupported properties are only used as a warning, and that warning comes from the cli, not from the loader package, so it shouldn't affect you. We could probably move that list out of types.go into a different package, but I don't think its necessary right now.

@vdemeester
Copy link
Collaborator

Design LGTM 🐸

@cdrage
Copy link
Contributor Author

cdrage commented Aug 30, 2017

Perfect, thank you @dnephin for the explanation. I wasn't too sure about removing build from the failing test case.

I've gone ahead and removed it, hopefully tests pass this time now!

Also greetings fellow Canadian 🇨🇦

@cdrage cdrage force-pushed the add-build-to-service-config branch from e0255ba to a8c0201 Compare August 30, 2017 13:43
@cdrage cdrage changed the title Add 'build' to types.go [WIP] Add 'build' to types.go Aug 31, 2017
@cdrage
Copy link
Contributor Author

cdrage commented Aug 31, 2017

Adding WIP tag so I make sure to do two things:

  • Have tests pass
  • Add rest of the schema

@cdrage cdrage force-pushed the add-build-to-service-config branch from a8c0201 to 26b406c Compare September 7, 2017 22:47
@cdrage cdrage changed the title [WIP] Add 'build' to types.go Add 'build' to types.go Sep 7, 2017
@cdrage
Copy link
Contributor Author

cdrage commented Sep 7, 2017

Hey @vdemeester @dnephin is it possible to help out with the failing test? Not too sure what's happening TBH.

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.

Yes, the test failures are related to changes in this PR.

One problem I notice is that there are tabs in your yaml examples, which are invalid. It must be spaces.

@cdrage cdrage force-pushed the add-build-to-service-config branch from 26b406c to 0645adf Compare September 8, 2017 12:30
@cdrage
Copy link
Contributor Author

cdrage commented Sep 8, 2017

@dnephin Finally passes! But looks like the tests flaked / need rebuilding on circleci. I'm going to update my commit message and see if it fixes it.

@cdrage cdrage force-pushed the add-build-to-service-config branch from 0645adf to 7dbd194 Compare September 8, 2017 12:52
@codecov-io
Copy link

codecov-io commented Sep 8, 2017

Codecov Report

Merging #481 into master will decrease coverage by 0.44%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #481      +/-   ##
==========================================
- Coverage   49.06%   48.62%   -0.45%     
==========================================
  Files         200      199       -1     
  Lines       16407    16396      -11     
==========================================
- Hits         8050     7972      -78     
- Misses       7938     8008      +70     
+ Partials      419      416       -3

@cdrage
Copy link
Contributor Author

cdrage commented Sep 8, 2017

Ayyy, tests pass 👍

CapAdd []string `mapstructure:"cap_add"`
CapDrop []string `mapstructure:"cap_drop"`
CgroupParent string `mapstructure:"cgroup_parent"`
Build BuildConfig `mapstructure:"build"`
Copy link
Contributor

Choose a reason for hiding this comment

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

not a problem, but technically you don't need the mapstructure annotation here, since it defaults to build

Dockerfile string
Args MappingWithEquals
Labels Labels
CacheFrom StringList
Copy link
Contributor

Choose a reason for hiding this comment

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

This one will need a mapstructure: annotation because it defaults to using a dash instead of an underscore to separate the words.

context: ./dir
dockerfile: Dockerfile
args:
foo: bar
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add the other fields (target, network, cache_from, labels) to this as well.

@thaJeztah
Copy link
Member

@cdrage can you address the review comments?

@cdrage cdrage force-pushed the add-build-to-service-config branch 2 times, most recently from c38a892 to 452cd21 Compare September 13, 2017 14:47
This adds 'build' to types.go in order for projects that use docker/cli
to parse Docker Compose files to correctly retrieve `build` keys

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
@cdrage cdrage force-pushed the add-build-to-service-config branch from 452cd21 to 9bdb076 Compare September 13, 2017 14:47
@cdrage
Copy link
Contributor Author

cdrage commented Sep 13, 2017

@thaJeztah @dnephin

Done! Updated the full-example.yml as well as the loader_test.go file with the aforementioned updates.

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.

LGTM

Copy link
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🦁

@vdemeester vdemeester merged commit 2eb31e6 into docker:master Sep 13, 2017
surajnarwade added a commit to surajnarwade/kompose that referenced this pull request Sep 26, 2017
Updated vendoring for getting changes from docker/cli
for build key in v3
(since docker/cli#481 is merged now)
surajnarwade added a commit to surajnarwade/kompose that referenced this pull request Oct 12, 2017
Resolves kubernetes#636

This PR will add support for `build` in docker compose v3.
As docker/cli#481 got merged now
surajnarwade added a commit to surajnarwade/kompose that referenced this pull request Oct 25, 2017
Resolves kubernetes#636

This PR will add support for `build` in docker compose v3.
As docker/cli#481 got merged now
procrypt pushed a commit to procrypt/kompose that referenced this pull request Feb 4, 2018
Resolves kubernetes#636

This PR will add support for `build` in docker compose v3.
As docker/cli#481 got merged now
@thaJeztah thaJeztah added this to the 17.10.0 milestone Feb 19, 2020
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