1
0
mirror of https://github.com/docker/cli.git synced 2025-09-02 10:21:16 +03:00
Sebastiaan van Stijn ef37a8a57c Fix "make build" (non-containerized) on macOS
macOS doesn't ship with the GNU version of `date`, which
causes the command to fail if the `--rfc-3339 ns` format option
is used.

Given that we don't need the build-time with nanosecond precision,
this patch changes the format used, so that the CLI binary can be
built on the host (outside of a container);

Before this change, `make binary` would fail:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    WARNING: binary creates a Linux executable. Use cross for macOS or Windows.
    ./scripts/build/binary
    make: *** [binary] Error 1

With this change, the binary can be built on the host:

    DISABLE_WARN_OUTSIDE_CONTAINER=1 make binary
    WARNING: binary creates a Linux executable. Use cross for macOS or Windows.
    ./scripts/build/binary
    Building statically linked build/docker-darwin-amd64

While the previous version formatted (and parsed) the date with nanoseconds precision,
that level of precision is not actually used;

```go
func reformatDate(buildTime string) string {
	t, errTime := time.Parse(time.RFC3339Nano, buildTime)
	if errTime == nil {
		return t.Format(time.ANSIC)
	}
	return buildTime
}
```

Both the old, and new input will yield the same output:

```go
fmt.Println(reformatDate("2019-12-31T13:41:44.846741804+00:00"))
// Tue Dec 31 13:41:44 2019

fmt.Println(reformatDate("2019-12-31T13:41:44Z"))
// Tue Dec 31 13:41:44 2019
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-12-31 15:06:11 +01:00
2019-01-10 17:32:07 +01:00
2019-12-12 17:51:25 +01:00
2019-08-12 11:28:57 +02:00
2017-09-27 16:45:35 +02:00
2019-08-11 21:53:44 +02:00
2019-08-11 21:53:44 +02:00
2018-01-03 10:23:32 +01:00
2017-07-28 11:33:19 -07:00
2019-08-30 10:58:05 +02:00
2019-08-12 11:29:04 +02:00
2017-04-17 17:49:33 -04:00
2019-08-30 10:58:05 +02:00
2019-07-29 16:45:41 -07:00
2019-12-12 17:51:25 +01:00
2019-05-10 17:30:44 -07:00

build status Build Status

docker/cli

This repository is the home of the cli used in the Docker CE and Docker EE products.

Development

docker/cli is developed using Docker.

Build a linux binary:

$ make -f docker.Makefile binary

Build binaries for all supported platforms:

$ make -f docker.Makefile cross

Run all linting:

$ make -f docker.Makefile lint

List all the available targets:

$ make help

In-container development environment

Start an interactive development environment:

$ make -f docker.Makefile shell

In the development environment you can run many tasks, including build binaries:

$ make binary

Legal

Brought to you courtesy of our legal counsel. For more context, please see the NOTICE document in this repo.

Use and transfer of Docker may be subject to certain restrictions by the United States and other governments.

It is your responsibility to ensure that your use and/or transfer does not violate applicable laws.

For more information, please see https://www.bis.doc.gov

Licensing

docker/cli is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Description
Интерфейс командной строки Docker
Readme 294 MiB
Languages
Go 91.6%
Shell 5.4%
Go-Checksums 1.3%
Dockerfile 1.2%
Makefile 0.3%
Other 0.2%