Skip to content

Commit

Permalink
Added checks that docker CLI exists and also that docker info wor…
Browse files Browse the repository at this point in the history
…ks properly
  • Loading branch information
maoueh committed May 11, 2023
1 parent f341d60 commit 13ff608
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v0.4.1

* Added checks that `docker` CLI exists and also that `docker info` works properly.

## v0.4.0

* Added full `CGO` support when building Go application/library, `.goreleaser.yaml` file now has `C_INCLUDE_PATH` and `LIBRARY_PATH` sets correctly so it's possible to build Go that depends on C libraries.
Expand Down
15 changes: 15 additions & 0 deletions cmd/sfreleaser/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,18 @@ func verifyCommand(command string, onErrorText string) {
cli.Exit(1)
}
}

func verifyCommandRunSuccesfully(command string, onErrorText string) {
verifyCommand("docker", onErrorText)

output, _, err := maybeResultOf(command)
if err != nil {
zlog.Debug("command check failed", zap.String("command", command), zap.String("output", output))

fmt.Printf("Command %q did not execute succesfully, error with %q\n", command, err.Error())
fmt.Println()
fmt.Println(onErrorText)

cli.Exit(1)
}
}
40 changes: 31 additions & 9 deletions cmd/sfreleaser/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,7 @@ func release(cmd *cobra.Command, args []string) error {

cli.NoError(os.Chdir(global.WorkingDirectory), "Unable to change directory to %q", global.WorkingDirectory)

verifyCommand("gh", cli.Dedent(`
The GitHub CLI utility (https://cli.github.com/) is required to obtain
information about the current draft release.
Install via brew with 'brew install gh' or refer https://github.com/cli/cli#installation
otherwise.
Don't forget to activate link with GitHub by doing 'gh auth login'.
`))
verifyTools()

if release.Version == "" {
release.Version = promptVersion()
Expand Down Expand Up @@ -274,3 +266,33 @@ func prepareSubstreamsSpkg(spkgPath string, global *GlobalModel, release *Releas

return spkgPath
}

func verifyTools() {
verifyCommand("docker", cli.Dedent(`
The 'docker' utility (https://docs.docker.com/get-docker/) is perform the
release.
Install it via https://docs.docker.com/get-docker/. Ensure you have it enough
resources allocated to it. You should use the fastest available options for your
system. You should also allocate minimally 4 CPU and 8GiB of RAM.
`))

verifyCommandRunSuccesfully("docker info", cli.Dedent(`
Ensure that your Docker Engine is currently running, it seems it's not running
right now because the command 'docker info' failed.
Try running the command 'docker info' locally to see the output. Ensure that it
execute successuflly and exits with a 0 exit code (run 'echo $?' right after
execution of the 'docker info' command to get its exit code).
`))

verifyCommand("gh", cli.Dedent(`
The GitHub CLI utility (https://cli.github.com/) is required to obtain
information about the current draft release.
Install via brew with 'brew install gh' or refer https://github.com/cli/cli#installation
otherwise.
Don't forget to activate link with GitHub by doing 'gh auth login'.
`))
}

0 comments on commit 13ff608

Please sign in to comment.