DockerCLI/scripts/build
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
..
.variables Fix "make build" (non-containerized) on macOS 2019-12-31 15:06:11 +01:00
binary Add scripts folder to shellcheck 2017-07-19 16:33:58 +01:00
cross Remove some bashisms 2019-02-26 15:31:12 +01:00
dynbinary build: add -buildmode=pie 2018-07-30 19:34:01 +10:00
osx scripts/build/osx: set CXX, too 2018-10-11 01:15:33 -07:00
plugins Add some simple e2e tests for executing CLI plugins 2019-01-30 13:44:05 +00:00
plugins-osx Add basic framework for writing a CLI plugin 2019-01-29 11:26:40 +00:00
plugins-windows Add basic framework for writing a CLI plugin 2019-01-29 11:26:40 +00:00
windows Add windows resources to binary. 2017-05-15 18:03:03 -04:00