From 18a6e3149133b97af6bef72a23bcddcc4700f4ce Mon Sep 17 00:00:00 2001 From: tobinio Date: Sat, 25 Jul 2026 11:54:10 +0200 Subject: [PATCH] feat: add ManagedBy build flag to disable auto-updates --- internal/config/config.go | 2 +- internal/config/const.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 internal/config/const.go diff --git a/internal/config/config.go b/internal/config/config.go index 4b2810c..81a18a6 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -112,7 +112,7 @@ func newConfigViper() (*viper.Viper, error) { // Defaults v.SetDefault("log_level", "info") v.SetDefault("log_file", defaultLogPath) - v.SetDefault("disable_update_check", false) + v.SetDefault("disable_update_check", IsExternallyManaged()) v.SetDefault("disable_companion_mode", false) v.SetDefault("companion_app_data_dirs", map[string]string{}) v.SetDefault("up.match_domains_dns", []string{}) diff --git a/internal/config/const.go b/internal/config/const.go new file mode 100644 index 0000000..63a4122 --- /dev/null +++ b/internal/config/const.go @@ -0,0 +1,13 @@ +package config + +// ManagedBy identifies the package manager managing this binary (e.g., "nix", "brew", "apt"). +// Defaults to "none", indicating the CLI manages its own updates internally. +// +// This value can be overridden at build time using ldflags: +// +// go build -ldflags "-X github.com/fosrl/cli/internal/config.ManagedBy=" +var ManagedBy = "none" + +func IsExternallyManaged() bool { + return ManagedBy != "none" +}