<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/docker.git/builder, branch docs</title>
<subtitle>github.com: dotcloud/docker.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/'/>
<entry>
<title>Apply build labels to images with only a FROM tag.</title>
<updated>2016-03-31T22:35:38+00:00</updated>
<author>
<name>David Calavera</name>
<email>david.calavera@gmail.com</email>
</author>
<published>2016-03-30T21:26:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=2936442f9d5f159a7df190f2a40075d6b06eb50a'/>
<id>2936442f9d5f159a7df190f2a40075d6b06eb50a</id>
<content type='text'>
Signed-off-by: David Calavera &lt;david.calavera@gmail.com&gt;
(cherry picked from commit 1a85c8ebbe1ab508bcd47b883b9732c032509503)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: David Calavera &lt;david.calavera@gmail.com&gt;
(cherry picked from commit 1a85c8ebbe1ab508bcd47b883b9732c032509503)
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #21270 from ehazlett/resource-labels</title>
<updated>2016-03-22T19:12:33+00:00</updated>
<author>
<name>Tibor Vass</name>
<email>tiborvass@users.noreply.github.com</email>
</author>
<published>2016-03-22T19:12:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=53d2e5e9d754ce8fbef733759e9ec450514133e3'/>
<id>53d2e5e9d754ce8fbef733759e9ec450514133e3</id>
<content type='text'>
Add Label support for Images (build), Networks and Volumes on Creation</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add Label support for Images (build), Networks and Volumes on Creation</pre>
</div>
</content>
</entry>
<entry>
<title>add label support for build, networks and volumes</title>
<updated>2016-03-22T15:49:06+00:00</updated>
<author>
<name>Evan Hazlett</name>
<email>ejhazlett@gmail.com</email>
</author>
<published>2016-03-16T21:52:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=fc214b4408d915e3510f61c7584ca01c176d1373'/>
<id>fc214b4408d915e3510f61c7584ca01c176d1373</id>
<content type='text'>
build: implement --label

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;

network: allow adding labels on create

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;

volume: allow adding labels on create

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;

add tests for build, network, volume

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;

vendor: libnetwork and engine-api bump

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
build: implement --label

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;

network: allow adding labels on create

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;

volume: allow adding labels on create

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;

add tests for build, network, volume

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;

vendor: libnetwork and engine-api bump

Signed-off-by: Evan Hazlett &lt;ejhazlett@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Pass upstream client's user agent through to registry on operations beyond pulls</title>
<updated>2016-03-21T21:31:47+00:00</updated>
<author>
<name>Aaron Lehmann</name>
<email>aaron.lehmann@docker.com</email>
</author>
<published>2016-03-18T21:42:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=c44e7a3e632c3ea961cb8c12ba45371f54e6699c'/>
<id>c44e7a3e632c3ea961cb8c12ba45371f54e6699c</id>
<content type='text'>
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 &lt;aaron.lehmann@docker.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;aaron.lehmann@docker.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fix variables that werent being called</title>
<updated>2016-03-17T20:19:55+00:00</updated>
<author>
<name>Jessica Frazelle</name>
<email>acidburn@docker.com</email>
</author>
<published>2016-03-17T02:43:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=0e025b4bb16c0d4cc6b3f0c040713d061b9b051a'/>
<id>0e025b4bb16c0d4cc6b3f0c040713d061b9b051a</id>
<content type='text'>
Signed-off-by: Jessica Frazelle &lt;acidburn@docker.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Jessica Frazelle &lt;acidburn@docker.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>remove dead code</title>
<updated>2016-03-17T02:15:14+00:00</updated>
<author>
<name>Jessica Frazelle</name>
<email>acidburn@docker.com</email>
</author>
<published>2016-03-17T02:15:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=8dd88afb5b5f8ce353c00bfc71edf8238f3a0452'/>
<id>8dd88afb5b5f8ce353c00bfc71edf8238f3a0452</id>
<content type='text'>
Signed-off-by: Jessica Frazelle &lt;acidburn@docker.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Jessica Frazelle &lt;acidburn@docker.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>daemon: update: check len inside public function</title>
<updated>2016-03-15T16:24:25+00:00</updated>
<author>
<name>Antonio Murdaca</name>
<email>runcom@redhat.com</email>
</author>
<published>2016-03-15T16:12:20+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=bb05c188927cdc7a5f86dceace3a4043b0dfeb28'/>
<id>bb05c188927cdc7a5f86dceace3a4043b0dfeb28</id>
<content type='text'>
Signed-off-by: Antonio Murdaca &lt;runcom@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Antonio Murdaca &lt;runcom@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>*: remove unused stuff</title>
<updated>2016-03-14T17:41:30+00:00</updated>
<author>
<name>Antonio Murdaca</name>
<email>runcom@redhat.com</email>
</author>
<published>2016-03-14T17:41:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=59648fc1e9d99cae7f4c5f692fe25a73d0651a71'/>
<id>59648fc1e9d99cae7f4c5f692fe25a73d0651a71</id>
<content type='text'>
Signed-off-by: Antonio Murdaca &lt;runcom@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Antonio Murdaca &lt;runcom@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Vendor engine-api to 70d266e96080e3c3d63c55a4d8659e00ac1f7e6c</title>
<updated>2016-02-29T11:28:37+00:00</updated>
<author>
<name>Qiang Huang</name>
<email>h.huangqiang@huawei.com</email>
</author>
<published>2016-02-29T11:28:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=53b0d62683ee798198c553353dc2106623a9259b'/>
<id>53b0d62683ee798198c553353dc2106623a9259b</id>
<content type='text'>
Signed-off-by: Qiang Huang &lt;h.huangqiang@huawei.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Qiang Huang &lt;h.huangqiang@huawei.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove static errors from errors package.</title>
<updated>2016-02-26T20:49:09+00:00</updated>
<author>
<name>David Calavera</name>
<email>david.calavera@gmail.com</email>
</author>
<published>2016-02-25T15:53:35+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/docker.git/commit/?id=a793564b2591035aec5412fbcbcccf220c773a4c'/>
<id>a793564b2591035aec5412fbcbcccf220c773a4c</id>
<content type='text'>
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 (&gt;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 &lt;david.calavera@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 (&gt;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 &lt;david.calavera@gmail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
