From 3436b037a86e330d7c7340159a195ed06614cd20 Mon Sep 17 00:00:00 2001 From: Nicklas Frahm Date: Mon, 25 Nov 2024 00:00:08 +0100 Subject: [PATCH] fix(version): allow users to disable version check via environment variable Signed-off-by: Nicklas Frahm --- cmd/sops/main.go | 5 +++-- version/version.go | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/sops/main.go b/cmd/sops/main.go index 42883ff37..ea403ec5c 100644 --- a/cmd/sops/main.go +++ b/cmd/sops/main.go @@ -1517,8 +1517,9 @@ func main() { Usage: "generate a new data encryption key and reencrypt all values with the new key", }, cli.BoolFlag{ - Name: "disable-version-check", - Usage: "do not check whether the current version is latest during --version", + Name: "disable-version-check", + Usage: "do not check whether the current version is latest during --version", + EnvVar: "SOPS_DISABLE_VERSION_CHECK", }, cli.StringFlag{ Name: "kms, k", diff --git a/version/version.go b/version/version.go index c015a59d7..3633443dd 100644 --- a/version/version.go +++ b/version/version.go @@ -15,8 +15,10 @@ 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 is set to a value that is considered +// true by https://pkg.go.dev/strconv#ParseBool, 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