diff --git a/cmd/sops/main.go b/cmd/sops/main.go index c82d8cc96..0563a2daa 100644 --- a/cmd/sops/main.go +++ b/cmd/sops/main.go @@ -1583,6 +1583,10 @@ func main() { Usage: "do not check whether the current version is latest during --version", EnvVar: "SOPS_DISABLE_VERSION_CHECK", }, + cli.BoolFlag{ + Name: "check-for-updates", + Usage: "do check whether the current version is latest during --version", + }, cli.StringFlag{ Name: "kms, k", Usage: "comma separated list of KMS ARNs", diff --git a/version/version.go b/version/version.go index 01c2640c1..4eb24216e 100644 --- a/version/version.go +++ b/version/version.go @@ -29,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") && !c.Bool("check-for-updates") { out.WriteString("\n") } else { upstreamVersion, upstreamURL, err := RetrieveLatestReleaseVersion() @@ -47,6 +47,12 @@ func PrintVersion(c *cli.Context) { } } } + if !c.Bool("check-for-updates") { + out.WriteString( + "\n[warning] Note that in a future version, sops will no longer check whether the current version is the latest when asking for sops' version." + + " If you want to explicitly check for the latest version, add the `--check-for-updates` option to `sops --version`." + + " This will hide this deprecation warning and will always check, even if the default behavior changes in the future.\n") + } } fmt.Fprintf(c.App.Writer, "%s", out.String()) }