Commit Graph

449 Commits

Author SHA1 Message Date
e9a370108d Fix directory walker error checking
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: 81d24e754d48ac8e9f0e4fe02befbf628179da43
Component: engine
2016-05-26 14:59:38 -07:00
5bcb28804b Merge pull request #22268 from Microsoft/jjh/continuationescape
Support platform semantic file paths through ESCAPE
Upstream-commit: 8e924153e219d040e3aa672df4e0c7baff9f8d8b
Component: engine
2016-05-26 10:00:56 -07:00
dd19106ac3 Typo fix wiildcard -> wildcard
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
Upstream-commit: 86d48aa111384539b0d2bd50353c4d4c40a5750a
Component: engine
2016-05-22 18:39:35 +01:00
4197623885 Reimplementing more builder integration tests as unit tests
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: cf2611f3239d18919e437e82554cec178028612e
Component: engine
2016-05-22 01:00:57 +02:00
886f3ce26b Support platform file paths through escape
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: e8e3dd32c5bad727010ec787f484b98942977531
Component: engine
2016-05-20 20:29:59 -07:00
084ac6917b builder: fixed workdir comment
Signed-off-by: Wendel Fleming <wfleming@usc.edu>
Upstream-commit: 131161bbc7a153eac0eccf02fcfb0fc2f5d368b5
Component: engine
2016-05-19 15:40:46 -05:00
e033d6beca Merge pull request #22462 from Microsoft/jjh/22181unittests
Windows: Reduce CLI time, move some to unit tests
Upstream-commit: 9de21de4531e01169d903751ab48a29457769610
Component: engine
2016-05-13 00:27:29 +02:00
af05fef951 Reimplementing builder integration tests as unit tests
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: 18eeb399852b7efe9459a1d77b0a5032a6b88bba
Component: engine
2016-05-11 22:13:39 +02:00
16a036804f Merge pull request #22485 from tkopczynski/test-utils
Builder unit tests refactoring
Upstream-commit: 16d0a8959381f7bc7c0fb9afbb9dd2f75431d48a
Component: engine
2016-05-06 22:05:02 +02:00
d1aa34c3d1 Windows: Reduce CLI time, move some to unit tests
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: faab71701f710a8862e71d4ecd6a86cef49f67b9
Component: engine
2016-05-06 12:26:08 -07:00
b06eb99229 Windows: Support ARG in builder
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 6b5c83bf18fe406e397c001acb0a1d9d7e147fd9
Component: engine
2016-05-04 14:32:23 -07:00
dfa93d10b9 Builder unit tests refactoring
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: ab2baf08f03b4a1ccede84b1e902dd16d1ad946f
Component: engine
2016-05-03 19:00:35 +02:00
263f748b31 Unit test for builder/remote.go
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: e00ad7227ea1ea09506145901213640964e7bdfb
Component: engine
2016-05-03 10:20:10 +02:00
7cba2b7aed Merge pull request #22181 from Microsoft/jjh/workdir
Windows: Consistent build workdir handling
Upstream-commit: 2b97201e0cd8301484fde379d2bf7f0ad3f36f10
Component: engine
2016-04-26 16:51:09 -07:00
51ef85c587 Windows: Consistent build workdir handling
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 0433801093f1988db0e210e28352f4af71a0ac81
Component: engine
2016-04-26 15:32:52 -07:00
70a36f55d4 Labels set on the command line always override labels in Dockerfile
This fix tries to address the inconsistency in #22036 where labels
set on the command line will not override labels specified in
Dockerfile, but will override labels inherited from `FROM` images.

The fix add a LABEL with command line options at the end of the
processed Dockerfile so that command line options labels always
override the LABEL in Dockerfiles (or through `FROM`).

An integration test has been added for test cases specified in #22036.

This fix fixes #22036.

NOTE: Some changes are from #22266 (@tiborvass).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 5844736c14b29860ea03b040e9a052e59ad75bfc
Component: engine
2016-04-23 18:49:17 -07:00
59ebbd5d31 Merge pull request #21817 from tkopczynski/20784-builder-dockerfile-support
Unit tests for builder/dockerfile/support
Upstream-commit: 27dd6a10b8515ed464e11ba409dd8c03b2287d1d
Component: engine
2016-04-16 13:34:35 +02:00
870f41bf45 Unit tests for builder/dockerfile/support
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: d0ebc58b9c82d2baf0c672b514ba9733ff79a3a1
Component: engine
2016-04-16 00:19:58 +02:00
16e418c586 Merge pull request #21633 from tkopczynski/20784-builder-tarsum-tests
Builder/tarsum unit tests
Upstream-commit: c60c3045ddf719a8e486e9f1bf69c634a05724b9
Component: engine
2016-04-15 12:53:07 -04:00
a683195dbd Merge pull request #21726 from aaronlehmann/tarsum-filename-normalization
Fix build cache false positives when build context tar contains unnormalized paths
Upstream-commit: 1a14bbc61e35fd2ca412e07fa6c456095756f892
Component: engine
2016-04-15 09:45:26 -07:00
b1c3afb97e Fix build cache false positives when build context tar contains unnormalized paths
If a build context tar has path names of the form 'x/./y', they will be
stored in this unnormalized form internally by tarsum. When the builder
walks the untarred directory tree and queries hashes for each relative
path, it will query paths of the form 'x/y', and they will not be found.

To correct this, have tarsum normalize path names by calling Clean.

Add a test to detect this caching false positive.

Fixes #21715

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: 8691a77e441996fef96019b94f299a11b7244080
Component: engine
2016-04-14 17:57:45 -07:00
4447d74a76 Move build endpoint handler from daemon (#21972)
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Upstream-commit: 73ac6d199cacbcdba4c062f982b31f8d57e03f3c
Component: engine
2016-04-13 10:21:00 -07:00
30ee59a24a Merge pull request #21867 from calavera/remove_reference_from_api
Remove reference package dependency from the api.
Upstream-commit: 681b5e0ed45f535d123d997884ce4ffb2907932f
Component: engine
2016-04-07 21:56:43 -04:00
fd446e3c8a Merge pull request #21815 from Microsoft/jjh/fixunittest
Windows: Fix failing unit tests
Upstream-commit: 3e14070c880dc1f3d9ca81c55f84ccebe8d89ad2
Component: engine
2016-04-07 21:14:42 -04:00
956e3c675e Remove reference package dependency from the api.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 47afe6bd0a0dc806c36d0978a8d3e23f75ef87fe
Component: engine
2016-04-07 15:01:23 -07:00
69969b53e0 Windows: Fix failing unit tests
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: ccd0da908ac2b0743ca2c8e80c589295fd3b2563
Component: engine
2016-04-06 13:42:15 -07:00
9f10b4351a Windows: Remove TP4 support from main code
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 331c8a86d489e573fcbf1df3c4f813bbc3168624
Component: engine
2016-04-06 12:12:20 -07:00
d2a9e8f78b Merge pull request #21669 from msabansal/expose
Enabling expose support for Windows TP5
Upstream-commit: f3da0c9055ea73dec1d793d4ff524a58ad67f635
Component: engine
2016-04-06 07:52:07 -07:00
3a408aad61 Enabling expose support for Windows TP5
Signed-off-by: msabansal <sabansal@microsoft.com>
Upstream-commit: 4982a732f34640217d05eee255905fcb12a7f939
Component: engine
2016-03-30 17:25:41 -07:00
783220b8bb Apply build labels to images with only a FROM tag.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 1a85c8ebbe1ab508bcd47b883b9732c032509503
Component: engine
2016-03-30 17:28:13 -04:00
055639ebe7 Merge pull request #21574 from tkopczynski/20784-builder-context-tests
Builder/context unit tests
Upstream-commit: 8dabc0c39b868e1c80f85541bbeeac17f05ca88f
Component: engine
2016-03-30 14:04:51 -04:00
7a2a6e9f8c Builder/tarsum unit tests
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: 61ca9cc99e1e7ba18c0d04237ba5fbcf30e3bd74
Component: engine
2016-03-30 06:40:40 +02:00
5a3dd03f44 Dockerignore tests
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: 555d8cb293705bd2ad2d8cac7881616756eca767
Component: engine
2016-03-28 22:31:35 +02:00
da12710ee0 Builder/context unit tests
Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Upstream-commit: 593e29156dcda362e4e4b9a95b4fce22a024ba79
Component: engine
2016-03-28 13:47:19 +02:00
35980664e6 fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 6983f05b42527dec87de9b2ecaf1d948038860fc
Component: engine
2016-03-26 22:06:45 +08:00
43dd16ffb4 builder: replace cancelled channel with net/context
Also stop execution of run immediately if request was cancelled.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: f2401a0f6960734093be307a27bba85a3c2ecfcd
Component: engine
2016-03-25 08:19:29 -07:00
6cee95ae99 Merge pull request #21268 from calavera/remove_dockerfile_from_api
Remove dockerfile dependency from the API.
Upstream-commit: 5ef04b1c6d1ca94c83c7ce52faae908a278ce6ea
Component: engine
2016-03-23 19:34:21 -07:00
02220a45c4 Merge pull request #21270 from ehazlett/resource-labels
Add Label support for Images (build), Networks and Volumes on Creation
Upstream-commit: 53d2e5e9d754ce8fbef733759e9ec450514133e3
Component: engine
2016-03-22 15:12:33 -04:00
fe56b4ef22 add label support for build, networks and volumes
build: implement --label

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

network: allow adding labels on create

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

volume: allow adding labels on create

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

add tests for build, network, volume

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

vendor: libnetwork and engine-api bump

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
Upstream-commit: fc214b4408d915e3510f61c7584ca01c176d1373
Component: engine
2016-03-22 11:49:06 -04:00
87c76eb0d7 Pass upstream client's user agent through to registry on operations beyond pulls
This adds support for the passthrough on build, push, login, and search.

Revamp the integration test to cover these cases and make it more
robust.

Use backticks instead of quoted strings for backslash-heavy string
contstands.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: c44e7a3e632c3ea961cb8c12ba45371f54e6699c
Component: engine
2016-03-21 14:31:47 -07:00
ae0977f1d1 fix variables that werent being called
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Upstream-commit: 0e025b4bb16c0d4cc6b3f0c040713d061b9b051a
Component: engine
2016-03-17 13:19:55 -07:00
8366a6bcc0 remove dead code
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Upstream-commit: 8dd88afb5b5f8ce353c00bfc71edf8238f3a0452
Component: engine
2016-03-16 19:15:14 -07:00
e4b1dba10c Remove dockerfile dependency from the API.
Move context parsing to the backend.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 93e02efa909896548496a5bd6621221aa541dc50
Component: engine
2016-03-16 22:06:29 -04:00
6decd866d9 daemon: update: check len inside public function
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: bb05c188927cdc7a5f86dceace3a4043b0dfeb28
Component: engine
2016-03-15 17:24:25 +01:00
4e53d3095a *: remove unused stuff
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 59648fc1e9d99cae7f4c5f692fe25a73d0651a71
Component: engine
2016-03-14 18:41:30 +01:00
98394b0b6e Vendor engine-api to 70d266e96080e3c3d63c55a4d8659e00ac1f7e6c
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Upstream-commit: 53b0d62683ee798198c553353dc2106623a9259b
Component: engine
2016-02-29 19:28:37 +08:00
b2ac99b3fa Remove static errors from errors package.
Moving all strings to the errors package wasn't a good idea after all.

Our custom implementation of Go errors predates everything that's nice
and good about working with errors in Go. Take as an example what we
have to do to get an error message:

```go
func GetErrorMessage(err error) string {
	switch err.(type) {
	case errcode.Error:
		e, _ := err.(errcode.Error)
		return e.Message

	case errcode.ErrorCode:
		ec, _ := err.(errcode.ErrorCode)
		return ec.Message()

	default:
		return err.Error()
	}
}
```

This goes against every good practice for Go development. The language already provides a simple, intuitive and standard way to get error messages, that is calling the `Error()` method from an error. Reinventing the error interface is a mistake.

Our custom implementation also makes very hard to reason about errors, another nice thing about Go. I found several (>10) error declarations that we don't use anywhere. This is a clear sign about how little we know about the errors we return. I also found several error usages where the number of arguments was different than the parameters declared in the error, another clear example of how difficult is to reason about errors.

Moreover, our custom implementation didn't really make easier for people to return custom HTTP status code depending on the errors. Again, it's hard to reason about when to set custom codes and how. Take an example what we have to do to extract the message and status code from an error before returning a response from the API:

```go
	switch err.(type) {
	case errcode.ErrorCode:
		daError, _ := err.(errcode.ErrorCode)
		statusCode = daError.Descriptor().HTTPStatusCode
		errMsg = daError.Message()

	case errcode.Error:
		// For reference, if you're looking for a particular error
		// then you can do something like :
		//   import ( derr "github.com/docker/docker/errors" )
		//   if daError.ErrorCode() == derr.ErrorCodeNoSuchContainer { ... }

		daError, _ := err.(errcode.Error)
		statusCode = daError.ErrorCode().Descriptor().HTTPStatusCode
		errMsg = daError.Message

	default:
		// This part of will be removed once we've
		// converted everything over to use the errcode package

		// FIXME: this is brittle and should not be necessary.
		// If we need to differentiate between different possible error types,
		// we should create appropriate error types with clearly defined meaning
		errStr := strings.ToLower(err.Error())
		for keyword, status := range map[string]int{
			"not found":             http.StatusNotFound,
			"no such":               http.StatusNotFound,
			"bad parameter":         http.StatusBadRequest,
			"conflict":              http.StatusConflict,
			"impossible":            http.StatusNotAcceptable,
			"wrong login/password":  http.StatusUnauthorized,
			"hasn't been activated": http.StatusForbidden,
		} {
			if strings.Contains(errStr, keyword) {
				statusCode = status
				break
			}
		}
	}
```

You can notice two things in that code:

1. We have to explain how errors work, because our implementation goes against how easy to use Go errors are.
2. At no moment we arrived to remove that `switch` statement that was the original reason to use our custom implementation.

This change removes all our status errors from the errors package and puts them back in their specific contexts.
IT puts the messages back with their contexts. That way, we know right away when errors used and how to generate their messages.
It uses custom interfaces to reason about errors. Errors that need to response with a custom status code MUST implementent this simple interface:

```go
type errorWithStatus interface {
	HTTPErrorStatusCode() int
}
```

This interface is very straightforward to implement. It also preserves Go errors real behavior, getting the message is as simple as using the `Error()` method.

I included helper functions to generate errors that use custom status code in `errors/errors.go`.

By doing this, we remove the hard dependency we have eeverywhere to our custom errors package. Yes, you can use it as a helper to generate error, but it's still very easy to generate errors without it.

Please, read this fantastic blog post about errors in Go: http://dave.cheney.net/2014/12/24/inspecting-errors

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: a793564b2591035aec5412fbcbcccf220c773a4c
Component: engine
2016-02-26 15:49:09 -05:00
f62b97e499 Fix some typos in comments and strings
Most of them were found and fixed by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Upstream-commit: 2eee613326fb59fd168849618d14a9054a40f9f5
Component: engine
2016-02-22 20:27:15 +01:00
bc74abda34 runconfig: opts: parse: lowercase errors
also fix wrong function comment

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: d266142230bd041c8299eef329cf79a17f8f7478
Component: engine
2016-02-18 11:21:44 +01:00
e56e27b666 Move getContext… function to builder package
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 312f5e435bed2ca45477dc9e4713d35aabe37075
Component: engine
2016-02-11 20:59:59 +01:00