Browse Source

hostinfo: set Hostinfo.PackageType for mkctr container builds

Fixes tailscale/corp#21448

Change-Id: Id60fb5cd7d31ef94cdbb176141e034845a480a00
Signed-off-by: Brad Fitzpatrick <[email protected]>
Brad Fitzpatrick 1 year ago
parent
commit
0b32adf9ec
3 changed files with 18 additions and 1 deletions
  1. 1 1
      build_docker.sh
  2. 7 0
      hostinfo/hostinfo_linux.go
  3. 10 0
      hostinfo/packagetype_container.go

+ 1 - 1
build_docker.sh

@@ -49,7 +49,7 @@ case "$TARGET" in
         -X tailscale.com/version.gitCommitStamp=${VERSION_GIT_HASH}" \
       --base="${BASE}" \
       --tags="${TAGS}" \
-      --gotags="ts_kube" \
+      --gotags="ts_kube,ts_package_container" \
       --repos="${REPOS}" \
       --push="${PUSH}" \
       --target="${PLATFORM}" \

+ 7 - 0
hostinfo/hostinfo_linux.go

@@ -159,7 +159,14 @@ func linuxVersionMeta() (meta versionMeta) {
 	return
 }
 
+// linuxBuildTagPackageType is set by packagetype_*.go
+// build tag guarded files.
+var linuxBuildTagPackageType string
+
 func packageTypeLinux() string {
+	if v := linuxBuildTagPackageType; v != "" {
+		return v
+	}
 	// Report whether this is in a snap.
 	// See https://snapcraft.io/docs/environment-variables
 	// We just look at two somewhat arbitrarily.

+ 10 - 0
hostinfo/packagetype_container.go

@@ -0,0 +1,10 @@
+// Copyright (c) Tailscale Inc & AUTHORS
+// SPDX-License-Identifier: BSD-3-Clause
+
+//go:build linux && ts_package_container
+
+package hostinfo
+
+func init() {
+	linuxBuildTagPackageType = "container"
+}