Commit Graph

413 Commits

Author SHA1 Message Date
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
f35a03ff6d Windows: Fix 'isolation'
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: d4b0732499feac87cf7c433b9490a4e21e94fb45
Component: engine
2016-02-10 13:19:19 -08:00
def405f4e4 Merge pull request #20165 from vdemeester/move-validatecontextdirectory-to-builder
Move validateContextDirectory to builder package.
Upstream-commit: e18eb6ef394522fa44bce7a3b9bb244d45ce9b56
Component: engine
2016-02-10 08:35:25 -08:00
566c96f73b Move validateContextDirectory to builder package.
This feels like it's where it belongs and it makes it exported
again (which is needed for libcompose that was using it before 1.10).

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: fc6122a947f9eb9fc2f54fb8ba3b9da4531a6b99
Component: engine
2016-02-09 22:19:09 +01:00
26a1a8c70f cleanup attach api calls
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: a77b7dd2278106b9081d0ef2260fbeea790a91ef
Component: engine
2016-02-09 14:26:51 -05:00
48fc690295 Fix ReadAll to run on Windows.
filepath.Clean converts filenames to filenames with native path
separators. Use ToSlash to normalize.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 691555fc8b070a40d3e35922fda681394bdfa173
Component: engine
2016-02-04 14:01:17 -08:00
fe296e65a0 Remove package daemonbuilder.
Currently, daemonbuilder package (part of daemon) implemented the
builder backend. However, it was a very thin wrapper around daemon
methods and caused an implementation dependency for api/server build
endpoint. api/server buildrouter should only know about the backend
implementing the /build API endpoint.

Removing daemonbuilder involved moving build specific methods to
respective files in the daemon, where they fit naturally.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 9c332b164f1aefa2407706adf59d50495d6e02cb
Component: engine
2016-02-01 09:57:38 -08:00
76f6e45741 Merge pull request #19837 from cpuguy83/carry_19085
Carry 19085 -- Improve & cleanup documentation comments 
Upstream-commit: 46018c3cee3a6fb76373289306f81ede881c9ca6
Component: engine
2016-01-29 14:30:25 -08:00
b5c499b982 update doc string
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 9c09a79ba54080873b435842fb2a4aaa3b701a9c
Component: engine
2016-01-29 15:25:25 -05:00
bd1120dfd8 Make daemonbuilder.Docker leaner.
Currently builder.Backend is implemented by daemonbuilder.Docker{} for
the daemon. This registration happens in the API/server code. However,
this is too implementation specific. Ideally we should be able to specify
that docker daemon (or any other) is implementing the Backend and abstract
the implementation details. So we should remove package daemonbuilder
dependency in build_routes.go

With this change, daemonbuilder.Docker is nothing more than the daemon.
A follow on change will remove the daemonbuilder package and move relevant
methods under daemon, so that API only knows about the backend.

Also cleanup code in api/client/build.go. docker cli always performs build
context tar download for remoteURLs and sends an empty remoteContext. So
remove relevant dead code.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 14215ed5a1900a88a3b17dd7cd566def50bfcbc9
Component: engine
2016-01-18 09:16:11 -08:00
caddcbad3d Improve docs for Daemon.TagImage and dockerfile.BuildFromConfig.
Signed-off-by: Lukas Waslowski <cr7pt0gr4ph7@gmail.com>
Upstream-commit: a4ce361ac8dc8c1a8d83b51c787986de256e2f69
Component: engine
2016-01-08 14:51:09 +01:00
4ec2693c9e Modify import paths to point to the new engine-api package.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 907407d0b2e5863f0e1b40b93a356bbf03c7b9fb
Component: engine
2016-01-06 19:48:59 -05:00
69f0af2128 Add default PATH to 'scratch' images
Closes #19012

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: d3ea7e80e879b506bddffd51c3ab65b8078a34f4
Component: engine
2016-01-06 09:50:35 -08:00
93f70516e8 Windows: Fix build not to sigsegv
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 1094542c4ca23096b8d3b10f9f86792769c075e5
Component: engine
2016-01-05 16:08:04 -08:00
d1e813dc31 Merge pull request #19092 from anusha-ragunathan/builder-rm-merge
Remove runconfig.Merge
Upstream-commit: df9a3d100574a7f6176b8ca544dad352493686b2
Component: engine
2016-01-05 15:21:24 -05:00
510a74def2 Remove runconfig.Merge
Merge was used by builder and daemon. With this commit, the builder
call has been inlined and the function moved to the daemon package,
which is the only other caller.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: eb4ae8e28aa0baf28d6cde1079a5f9c618d475b2
Component: engine
2016-01-05 11:28:55 -08:00
f688b73835 Use ImageBuildOptions in builder.
dockerfile.Config is almost redundant with ImageBuildOptions.
Unify the two so that the latter can be removed. This also
helps build's API endpoint code to be less dependent on package
dockerfile.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 5190794f1d85d5406611eb69c270df62ac1cdc7f
Component: engine
2016-01-05 10:09:34 -08:00
c43ba74b61 Move the runconfig.Parse() function into the runconfig/opts package.
The parse.go file is used almost exclusively in the client. The few small
functions that are used outside of the client could easily be copied out
when the client is extracted, allowing this runconfig/opts package to
move to the client.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 2b7ad47bd2649c3f164e8b57b31fae313045c8f4
Component: engine
2016-01-04 12:06:29 -05:00
b58ec08634 Use constant instead of "scratch"
Move NoBaseImageSpecifier to a common spot and then use it instead of
"scratch" in a couple of places.

Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: e6806223e81c916c9b24580b19207271f1a36965
Component: engine
2015-12-31 06:21:56 -08:00
753d6942df Remove the need for runconfig.Parse() in the builder.
By using a container.Config directly.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 6dba0b5d89bfa262757493679788b171f23b891c
Component: engine
2015-12-27 19:58:51 -05:00
1cfbdcfe91 Remove package pkg/ulimit, use go-units instead.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: 83237aab2b9430a88790467867505cc9a5147f3e
Component: engine
2015-12-23 13:27:58 -05:00
027f002cb3 Move Config and HostConfig from runconfig to types/container.
- Make the API client library completely standalone.
- Move windows partition isolation detection to the client, so the
  driver doesn't use external types.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 7ac4232e70fe7cf7318333cd0890db7f95663079
Component: engine
2015-12-22 13:34:30 -05:00
b006691148 Replace usage of pkg/nat with go-connections/nat.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 056e7449039af522fa0a1567ef67916eaa0de93e
Component: engine
2015-12-22 13:31:46 -05:00
7e8fcbf740 Move StrSlice to types.
This is a very docker concept that nobody elses need.
We only maintain it to keep the API backwards compatible.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: f9b857a200696b07b67e6a7f94ede32487f5649d
Component: engine
2015-12-22 13:31:43 -05:00
1c5df6581b Change the quiet flag behavior in the build command
Right now, the quiet (-q, --quiet) flag ignores the output
generated from within the container.

However, it ought to be quiet in a way that all kind
of diagnostic output should be ignored, unless the build
process fails.

This patch makes the quiet flag behave in the following way:
 1. If the build process succeeds, stdout contains the image ID
    and stderr is empty.
 2. If the build process fails, stdout is empty and stderr
    has the error message and the diagnostic output of that process.

If the quiet flag is not set, then everything goes to stdout
and error messages, if there are any, go to stderr.

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
Upstream-commit: 60b4db7eb17f4eb509be4a4968364ada2075d60c
Component: engine
2015-12-21 16:38:50 +02:00
cc50cf65a0 Merge pull request #18761 from anusha-ragunathan/add-build-routes
Create build router separate from image router.
Upstream-commit: 92605b823d4facbe9076b58dd0b0d77101529ad9
Component: engine
2015-12-18 21:09:43 +01:00
3a6aede7f5 Merge pull request #18721 from tiborvass/remove-dependencies-from-builder
Remove image and daemon dependencies from builder
Upstream-commit: 64d70de0a2aa29f565336e896b76c23c879a9a98
Component: engine
2015-12-18 17:19:55 +01:00
71b76682f6 Create build router separate from image router.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: f8dc044aecd6fa00c33dc6a72321a3e249a0b40d
Component: engine
2015-12-17 16:56:11 -08:00
1f6b8ad3e8 builder: remove daemon dependency in ContainerAttach
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: b0d947615335fe115b5b93c0c09912a4888e5b29
Component: engine
2015-12-17 16:57:08 +01:00
49f762b669 builder: remove daemon dependency in ContainerCreate()
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 03a170c48d660be72c387f1821ca48a713dd1cea
Component: engine
2015-12-17 16:57:08 +01:00
2723fcf0b2 builder: remove dependency on image
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 9be1ec60d4d4fe63d5ef6e1ec36c585b548a00d0
Component: engine
2015-12-16 19:25:03 +01:00
aed633bad5 Remove Mount/Unmount from Builder interface.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 89ab39b050e0b6bbb7766a4662132b1b7bc8545f
Component: engine
2015-12-16 09:11:57 -08:00
0bf29d425d builder: remove unused Retain/Release and put Mount/Unmount back
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 93c0de2af4f88f68b793a282cb654a14bd32eb3f
Component: engine
2015-12-15 17:24:07 +01:00
bf2423fe8a builder: remove container package dependency
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: c70f8b3c9c7a6dc6a219354acaa2e650d1403ecf
Component: engine
2015-12-15 17:24:07 +01:00
637e991bae dockerfile: get rid of Commit and CommitConfig
Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit 400e4922cbd004b93774fc55005f74bd8a995242)
Upstream-commit: 2a2d1f57b586632a5304f1093add28ef64661902
Component: engine
2015-12-15 17:23:40 +01:00
1caa5bd099 utils: move dockerignore function to builder/dockerignore
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 63e3816c1dd449de63500a2b5fec9c2a33a0894c
Component: engine
2015-12-14 14:59:52 +01:00
86409751de utils: move git functions to pkg/gitutils
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 135cca6f52c7862f13f50c30ccf5925038ba40a9
Component: engine
2015-12-14 14:59:52 +01:00