Skip to content

Commit

Permalink
Add ENV flag to skip update check in Docker container. (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Simmer authored Jul 16, 2020
1 parent a686893 commit bb7188b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM circleci/golang:1.10.3

ENV CIRCLECI_CLI_SKIP_UPDATE_CHECK true

COPY ./dist/circleci-cli_linux_amd64/circleci /usr/local/bin
2 changes: 2 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM alpine:3.8

ENV CIRCLECI_CLI_SKIP_UPDATE_CHECK true

COPY ./dist/circleci-cli_linux_amd64/circleci /usr/local/bin

RUN apk add --no-cache --upgrade git openssh ca-certificates
Expand Down
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func MakeCommands() *cobra.Command {
flags.StringVar(&rootOptions.Host, "host", rootOptions.Host, "URL to your CircleCI host, also CIRCLECI_CLI_HOST")
flags.StringVar(&rootOptions.Endpoint, "endpoint", rootOptions.Endpoint, "URI to your CircleCI GraphQL API endpoint")
flags.StringVar(&rootOptions.GitHubAPI, "github-api", "https://api.github.com/", "Change the default endpoint to GitHub API for retrieving updates")
flags.BoolVar(&rootOptions.SkipUpdateCheck, "skip-update-check", runningInCi(), "Skip the check for updates check run before every command.")
flags.BoolVar(&rootOptions.SkipUpdateCheck, "skip-update-check", skipUpdateByDefault(), "Skip the check for updates check run before every command.")

hidden := []string{"github-api", "debug", "endpoint"}

Expand Down Expand Up @@ -255,6 +255,6 @@ This project is the seed for CircleCI's new command-line application.`
For more help, see the documentation here: %s`, long, config.Data.Links.CLIDocs)
}

func runningInCi() bool {
return os.Getenv("CI") == "true"
func skipUpdateByDefault() bool {
return os.Getenv("CI") == "true" || os.Getenv("CIRCLECI_CLI_SKIP_UPDATE_CHECK") == "true"
}

0 comments on commit bb7188b

Please sign in to comment.