Skip to content

Commit 7cfbfd9

Browse files
committed
fix(version): allow users to disable version check via environment variable
Signed-off-by: Nicklas Frahm <nicklas.frahm@gmail.com>
1 parent 222a7f7 commit 7cfbfd9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

version/version.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"net/http"
7+
"os"
78
"strings"
89

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

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

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

30-
if c.Bool("disable-version-check") {
32+
if c.Bool("disable-version-check") || os.Getenv("SOPS_DISABLE_VERSION_CHECK") != "" {
3133
out.WriteString("\n")
3234
} else {
3335
upstreamVersion, upstreamURL, err := RetrieveLatestReleaseVersion()

0 commit comments

Comments
 (0)