feature/buildfeatures: split const bools out of the featuretags package, add Has prefix

This renames the package+symbols in the earlier 17ffa80138 to be
in their own package ("buildfeatures") and start with the word "Has"
like "if buildfeatures.HasFoo {".

Updates #12614

Change-Id: I510e5f65993e5b76a0e163e3aa4543755213cbf6
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2025-09-15 09:52:17 -07:00
committed by Brad Fitzpatrick
parent 510830ca7a
commit 6fb316f5ed
41 changed files with 166 additions and 158 deletions
+10
View File
@@ -0,0 +1,10 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
//go:generate go run gen.go
// The buildfeatures package contains boolean constants indicating which
// features were included in the binary (via build tags), for use in dead code
// elimination when using separate build tag protected files is impractical
// or undesirable.
package buildfeatures
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_aws
package buildfeatures
// HasAWS is whether the binary was built with support for modular feature "AWS integration".
// Specifically, it's whether the binary was NOT built with the "ts_omit_aws" build tag.
// It's a const so it can be used for dead code elimination.
const HasAWS = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_aws
package buildfeatures
// HasAWS is whether the binary was built with support for modular feature "AWS integration".
// Specifically, it's whether the binary was NOT built with the "ts_omit_aws" build tag.
// It's a const so it can be used for dead code elimination.
const HasAWS = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_bird
package buildfeatures
// HasBird is whether the binary was built with support for modular feature "Bird BGP integration".
// Specifically, it's whether the binary was NOT built with the "ts_omit_bird" build tag.
// It's a const so it can be used for dead code elimination.
const HasBird = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_bird
package buildfeatures
// HasBird is whether the binary was built with support for modular feature "Bird BGP integration".
// Specifically, it's whether the binary was NOT built with the "ts_omit_bird" build tag.
// It's a const so it can be used for dead code elimination.
const HasBird = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_capture
package buildfeatures
// HasCapture is whether the binary was built with support for modular feature "Packet capture".
// Specifically, it's whether the binary was NOT built with the "ts_omit_capture" build tag.
// It's a const so it can be used for dead code elimination.
const HasCapture = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_capture
package buildfeatures
// HasCapture is whether the binary was built with support for modular feature "Packet capture".
// Specifically, it's whether the binary was NOT built with the "ts_omit_capture" build tag.
// It's a const so it can be used for dead code elimination.
const HasCapture = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_completion
package buildfeatures
// HasCompletion is whether the binary was built with support for modular feature "CLI shell completion".
// Specifically, it's whether the binary was NOT built with the "ts_omit_completion" build tag.
// It's a const so it can be used for dead code elimination.
const HasCompletion = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_completion
package buildfeatures
// HasCompletion is whether the binary was built with support for modular feature "CLI shell completion".
// Specifically, it's whether the binary was NOT built with the "ts_omit_completion" build tag.
// It's a const so it can be used for dead code elimination.
const HasCompletion = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_debugeventbus
package buildfeatures
// HasDebugEventBus is whether the binary was built with support for modular feature "eventbus debug support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_debugeventbus" build tag.
// It's a const so it can be used for dead code elimination.
const HasDebugEventBus = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_debugeventbus
package buildfeatures
// HasDebugEventBus is whether the binary was built with support for modular feature "eventbus debug support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_debugeventbus" build tag.
// It's a const so it can be used for dead code elimination.
const HasDebugEventBus = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_desktop_sessions
package buildfeatures
// HasDesktopSessions is whether the binary was built with support for modular feature "Desktop sessions support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_desktop_sessions" build tag.
// It's a const so it can be used for dead code elimination.
const HasDesktopSessions = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_desktop_sessions
package buildfeatures
// HasDesktopSessions is whether the binary was built with support for modular feature "Desktop sessions support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_desktop_sessions" build tag.
// It's a const so it can be used for dead code elimination.
const HasDesktopSessions = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_drive
package buildfeatures
// HasDrive is whether the binary was built with support for modular feature "Tailscale Drive (file server) support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_drive" build tag.
// It's a const so it can be used for dead code elimination.
const HasDrive = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_drive
package buildfeatures
// HasDrive is whether the binary was built with support for modular feature "Tailscale Drive (file server) support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_drive" build tag.
// It's a const so it can be used for dead code elimination.
const HasDrive = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_kube
package buildfeatures
// HasKube is whether the binary was built with support for modular feature "Kubernetes integration".
// Specifically, it's whether the binary was NOT built with the "ts_omit_kube" build tag.
// It's a const so it can be used for dead code elimination.
const HasKube = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_kube
package buildfeatures
// HasKube is whether the binary was built with support for modular feature "Kubernetes integration".
// Specifically, it's whether the binary was NOT built with the "ts_omit_kube" build tag.
// It's a const so it can be used for dead code elimination.
const HasKube = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_relayserver
package buildfeatures
// HasRelayServer is whether the binary was built with support for modular feature "Relay server".
// Specifically, it's whether the binary was NOT built with the "ts_omit_relayserver" build tag.
// It's a const so it can be used for dead code elimination.
const HasRelayServer = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_relayserver
package buildfeatures
// HasRelayServer is whether the binary was built with support for modular feature "Relay server".
// Specifically, it's whether the binary was NOT built with the "ts_omit_relayserver" build tag.
// It's a const so it can be used for dead code elimination.
const HasRelayServer = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_serve
package buildfeatures
// HasServe is whether the binary was built with support for modular feature "Serve and Funnel support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_serve" build tag.
// It's a const so it can be used for dead code elimination.
const HasServe = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_serve
package buildfeatures
// HasServe is whether the binary was built with support for modular feature "Serve and Funnel support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_serve" build tag.
// It's a const so it can be used for dead code elimination.
const HasServe = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_ssh
package buildfeatures
// HasSSH is whether the binary was built with support for modular feature "Tailscale SSH support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_ssh" build tag.
// It's a const so it can be used for dead code elimination.
const HasSSH = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_ssh
package buildfeatures
// HasSSH is whether the binary was built with support for modular feature "Tailscale SSH support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_ssh" build tag.
// It's a const so it can be used for dead code elimination.
const HasSSH = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_syspolicy
package buildfeatures
// HasSystemPolicy is whether the binary was built with support for modular feature "System policy configuration (MDM) support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_syspolicy" build tag.
// It's a const so it can be used for dead code elimination.
const HasSystemPolicy = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_syspolicy
package buildfeatures
// HasSystemPolicy is whether the binary was built with support for modular feature "System policy configuration (MDM) support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_syspolicy" build tag.
// It's a const so it can be used for dead code elimination.
const HasSystemPolicy = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_systray
package buildfeatures
// HasSysTray is whether the binary was built with support for modular feature "Linux system tray".
// Specifically, it's whether the binary was NOT built with the "ts_omit_systray" build tag.
// It's a const so it can be used for dead code elimination.
const HasSysTray = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_systray
package buildfeatures
// HasSysTray is whether the binary was built with support for modular feature "Linux system tray".
// Specifically, it's whether the binary was NOT built with the "ts_omit_systray" build tag.
// It's a const so it can be used for dead code elimination.
const HasSysTray = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_taildrop
package buildfeatures
// HasTaildrop is whether the binary was built with support for modular feature "Taildrop (file sending) support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_taildrop" build tag.
// It's a const so it can be used for dead code elimination.
const HasTaildrop = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_taildrop
package buildfeatures
// HasTaildrop is whether the binary was built with support for modular feature "Taildrop (file sending) support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_taildrop" build tag.
// It's a const so it can be used for dead code elimination.
const HasTaildrop = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_tailnetlock
package buildfeatures
// HasTailnetLock is whether the binary was built with support for modular feature "Tailnet Lock support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_tailnetlock" build tag.
// It's a const so it can be used for dead code elimination.
const HasTailnetLock = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_tailnetlock
package buildfeatures
// HasTailnetLock is whether the binary was built with support for modular feature "Tailnet Lock support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_tailnetlock" build tag.
// It's a const so it can be used for dead code elimination.
const HasTailnetLock = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_tap
package buildfeatures
// HasTap is whether the binary was built with support for modular feature "Experimental Layer 2 (ethernet) support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_tap" build tag.
// It's a const so it can be used for dead code elimination.
const HasTap = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_tap
package buildfeatures
// HasTap is whether the binary was built with support for modular feature "Experimental Layer 2 (ethernet) support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_tap" build tag.
// It's a const so it can be used for dead code elimination.
const HasTap = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_tpm
package buildfeatures
// HasTPM is whether the binary was built with support for modular feature "TPM support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_tpm" build tag.
// It's a const so it can be used for dead code elimination.
const HasTPM = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_tpm
package buildfeatures
// HasTPM is whether the binary was built with support for modular feature "TPM support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_tpm" build tag.
// It's a const so it can be used for dead code elimination.
const HasTPM = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_wakeonlan
package buildfeatures
// HasWakeOnLAN is whether the binary was built with support for modular feature "Wake-on-LAN support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_wakeonlan" build tag.
// It's a const so it can be used for dead code elimination.
const HasWakeOnLAN = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_wakeonlan
package buildfeatures
// HasWakeOnLAN is whether the binary was built with support for modular feature "Wake-on-LAN support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_wakeonlan" build tag.
// It's a const so it can be used for dead code elimination.
const HasWakeOnLAN = true
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build ts_omit_webclient
package buildfeatures
// HasWebClient is whether the binary was built with support for modular feature "Web client support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_webclient" build tag.
// It's a const so it can be used for dead code elimination.
const HasWebClient = false
@@ -0,0 +1,13 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code generated by gen.go; DO NOT EDIT.
//go:build !ts_omit_webclient
package buildfeatures
// HasWebClient is whether the binary was built with support for modular feature "Web client support".
// Specifically, it's whether the binary was NOT built with the "ts_omit_webclient" build tag.
// It's a const so it can be used for dead code elimination.
const HasWebClient = true
+49
View File
@@ -0,0 +1,49 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
//go:build ignore
// The gens.go program generates the feature_<feature>_enabled.go
// and feature_<feature>_disabled.go files for each feature tag.
package main
import (
"cmp"
"fmt"
"os"
"strings"
"tailscale.com/feature/featuretags"
"tailscale.com/util/must"
)
const header = `// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// Code g|e|n|e|r|a|t|e|d by gen.go; D|O N|OT E|D|I|T.
`
func main() {
header := strings.ReplaceAll(header, "|", "") // to avoid this file being marked as generated
for k, m := range featuretags.Features {
if !k.IsOmittable() {
continue
}
sym := "Has" + cmp.Or(m.Sym, strings.ToUpper(string(k)[:1])+string(k)[1:])
for _, suf := range []string{"enabled", "disabled"} {
bang := ""
if suf == "enabled" {
bang = "!" // !ts_omit_...
}
must.Do(os.WriteFile("feature_"+string(k)+"_"+suf+".go",
fmt.Appendf(nil, "%s//go:build %s%s\n\npackage buildfeatures\n\n"+
"// %s is whether the binary was built with support for modular feature %q.\n"+
"// Specifically, it's whether the binary was NOT built with the %q build tag.\n"+
"// It's a const so it can be used for dead code elimination.\n"+
"const %s = %t\n",
header, bang, k.OmitTag(), sym, m.Desc, k.OmitTag(), sym, suf == "enabled"), 0644))
}
}
}