Skip to content

Commit

Permalink
fix(version): allow users to disable version check via environment va…
Browse files Browse the repository at this point in the history
…riable

Signed-off-by: Nicklas Frahm <[email protected]>
  • Loading branch information
nicklasfrahm committed Nov 24, 2024
1 parent 222a7f7 commit 7cfbfd9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"
"strings"

"github.com/blang/semver"
Expand All @@ -15,8 +16,9 @@ import (
var Version = "3.9.1"

// PrintVersion prints the current version of sops. If the flag
// `--disable-version-check` is set, the function will not attempt
// to retrieve the latest version from the GitHub API.
// `--disable-version-check` is set or if the environment variable
// SOPS_DISABLE_VERSION_CHECK has any value, the function will not
// attempt to retrieve the latest version from the GitHub API.
//
// If the flag is not set, the function will attempt to retrieve
// the latest version from the GitHub API and compare it to the
Expand All @@ -27,7 +29,7 @@ func PrintVersion(c *cli.Context) {

out.WriteString(fmt.Sprintf("%s %s", c.App.Name, c.App.Version))

if c.Bool("disable-version-check") {
if c.Bool("disable-version-check") || os.Getenv("SOPS_DISABLE_VERSION_CHECK") != "" {
out.WriteString("\n")
} else {
upstreamVersion, upstreamURL, err := RetrieveLatestReleaseVersion()
Expand Down

0 comments on commit 7cfbfd9

Please sign in to comment.