2020-04-06 16:40:40 +02:00
# Docker API
2020-05-03 15:31:05 +02:00
[![Actions Status ](https://github.com/docker/api/workflows/Continuous%20integration/badge.svg )](https://github.com/docker/api/actions)
2020-05-03 15:25:50 +02:00
2020-04-06 16:40:40 +02:00
## Dev Setup
2020-05-04 23:50:00 +02:00
The recommended way is to use the main `Makefile` that runs everything inside a container.
If you don't have or want to use Docker for building you need to make sure you have all the needed tools installed locally:
* go 1.14
2020-05-14 21:48:50 +02:00
* [protoc ](https://github.com/protocolbuffers/protobuf )
2020-05-04 23:50:00 +02:00
* `go get github.com/golang/protobuf/protoc-gen-go@v1.4.1`
* `go get golang.org/x/tools/cmd/goimports`
* `go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.26.0`
And then you can call the same make targets but you need to pass it the `builder.Makefile` (`make -f builder.Makefile`).
2020-04-06 16:43:36 +02:00
2020-06-17 17:57:44 +02:00
The new CLI delegates to the classic docker for default contexts ; delegation is done to `com.docker.cli` .
* `make moby-cli-link` will create a `com.docker.cli` link in `/usr/local/bin` if you don't already have it from Docker Desktop
2020-05-19 21:46:44 +02:00
2020-05-04 22:31:59 +02:00
## Building the project
2020-04-06 16:43:36 +02:00
```bash
2020-05-04 22:31:59 +02:00
$ make
2020-04-06 16:43:36 +02:00
```
2020-05-04 22:31:59 +02:00
2020-06-15 17:41:59 +02:00
This will make the cli with all backends enabled. `make cross` on the other hand will cross-compile the cli without the
example and local backend. We use `make cross` to build for our release, hence the exclusion of those backends. You can
still cross-compile with all backends enabled: `BUILD_TAGS=example,local make cross` .
2020-05-06 09:37:52 +02:00
2020-06-15 17:41:59 +02:00
If you make changes to the `.proto` files, make sure to `make protos` to generate go code.
2020-05-06 09:37:52 +02:00
## Tests
2020-06-30 11:31:49 +02:00
### unit tests
2020-05-06 09:37:52 +02:00
```
make test
```
If you need to update a golden file simply do `go test ./... -test.update-golden` .
2020-06-30 11:31:49 +02:00
### e2e tests
```
make e2e_local
```
This requires a local docker engine running
```
AZURE_TENANT_ID="xxx" AZURE_CLIENT_ID="yyy" AZURE_CLIENT_SECRET="yyy" make e2e_aci
```
This requires azure service principal credentials to login to azure.
To get the values to be set in local environment variables, you can create a new service principal once you're logged in azure (with `docker login azure` )
```
az ad sp create-for-rbac --name 'MyTestServicePrincipal' --sdk-auth
```
Running aci e2e tests will override your local login, the service principal credentials use a token that cannot be refreshed automatically.
You might need to run again `docker login azure` to properly use the command line after running ACI e2e tests.