Repository: docker/docker-py

Issue:
credHelpers not passed in docker.images.build(pull=True)
When using docker.images.build with pull=True, credHelpers in ~/.docker/config.json are not passed. Thus the pull fails with `docker.errors.BuildError: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials.`.

it seems that `docker.api.build.BuildApiMixin.build` shoud use
```
header = auth.get_config_header(self, registry)
if header:
    headers['X-Registry-Auth'] = header
```
instead of its own implementation (`docker.api.build.BuildApiMixin._set_auth_headers`)


docker config:
```
docker==3.4.1
docker-pycreds==0.3.0
Python 2.7.14
Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:17:38 2018
 OS/Arch:      linux/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:15:45 2018
  OS/Arch:      linux/amd64
  Experimental: false
```


Discussion:

Resolving patch:
diff --git a/docker/api/build.py b/docker/api/build.py
--- a/docker/api/build.py
+++ b/docker/api/build.py
@@ -293,20 +293,28 @@ def _set_auth_headers(self, headers):
         # Send the full auth configuration (if any exists), since the build
         # could use any (or all) of the registries.
         if self._auth_configs:
+            auth_cfgs = self._auth_configs
             auth_data = {}
-            if self._auth_configs.get('credsStore'):
+            if auth_cfgs.get('credsStore'):
                 # Using a credentials store, we need to retrieve the
                 # credentials for each registry listed in the config.json file
                 # Matches CLI behavior: https://github.com/docker/docker/blob/
                 # 67b85f9d26f1b0b2b240f2d794748fac0f45243c/cliconfig/
                 # credentials/native_store.go#L68-L83
-                for registry in self._auth_configs.get('auths', {}).keys():
+                for registry in auth_cfgs.get('auths', {}).keys():
                     auth_data[registry] = auth.resolve_authconfig(
-                        self._auth_configs, registry,
+                        auth_cfgs, registry,
                         credstore_env=self.credstore_env,
                     )
             else:
-                auth_data = self._auth_configs.get('auths', {}).copy()
+                for registry in auth_cfgs.get('credHelpers', {}).keys():
+                    auth_data[registry] = auth.resolve_authconfig(
+                        auth_cfgs, registry,
+                        credstore_env=self.credstore_env
+                    )
+                for registry, creds in auth_cfgs.get('auths', {}).items():
+                    if registry not in auth_data:
+                        auth_data[registry] = creds
                 # See https://github.com/docker/docker-py/issues/1683
                 if auth.INDEX_NAME in auth_data:
                     auth_data[auth.INDEX_URL] = auth_data[auth.INDEX_NAME]


Test patch: