[shivas] Create a local build that only targets local instances

This used to be the case. But seems to have been removed at somepoint.
This patch adds back a local build that will build shivas that will only
hit local endpoints irrespective of what command line options is used.
This is needed as it makes things really easy when debugging locally.
The existing solution of setting the namespace correctly adds an extra
step to set your env correctly every time you start a new session. Which
is not hard to forget.

Change-Id: I5d03c4482524b54ef88dc07b2f5ac3e48c07297b
Reviewed-on: https://chromium-review.googlesource.com/c/infra/infra/+/7248660
Reviewed-by: Gowri Denduluri <gowriden@google.com>
Commit-Queue: Anushruth Sasivehalli <anushruth@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77999}
diff --git a/go/src/infra/cmd/shivas/Makefile b/go/src/infra/cmd/shivas/Makefile
index 71982f7..b854f61 100644
--- a/go/src/infra/cmd/shivas/Makefile
+++ b/go/src/infra/cmd/shivas/Makefile
@@ -7,6 +7,10 @@
 	go test ./...
 	go test ../../libs/skylab/autotest/hostinfo/...
 
+.PHONY: local
+local:
+	go build -tags local -o shivas main.go
+
 .PHONY: clean
 clean:
 	$(RM) shivas
diff --git a/go/src/infra/cmd/shivas/site/config.go b/go/src/infra/cmd/shivas/site/config.go
new file mode 100644
index 0000000..3141536
--- /dev/null
+++ b/go/src/infra/cmd/shivas/site/config.go
@@ -0,0 +1,50 @@
+// Copyright 2025 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Only build this if local is not used
+//go:build !local
+
+// Package site contains site local constants for the shivas
+package site
+
+const localDefault = false
+
+// localDevEnv is the local dev environment.
+var localDevEnv = Environment{
+	// TODO(gregorynisbet): remove once stable version moves to UFS.
+	AdminService:        "skylab-staging-bot-fleet.appspot.com",
+	InventoryService:    "0.0.0.0:8082",
+	UnifiedFleetService: "127.0.0.1:8800",
+	SwarmingService:     "https://chromium-swarm-dev.appspot.com/",
+	// TODO(crbug/1128496): remove when fixed
+	SwarmingServiceAccount: "skylab-admin-task@chromeos-service-accounts-dev.iam.gserviceaccount.com",
+	LogdogService:          "luci-logdog-dev.appspot.com",
+	QueenService:           "drone-queen-dev.appspot.com",
+}
+
+// devEnv is the environment for the dev cloud project.
+var devEnv = Environment{
+	// TODO(gregorynisbet): remove once stable version moves to UFS.
+	AdminService:        "skylab-staging-bot-fleet.appspot.com",
+	InventoryService:    "cros-lab-inventory-dev.appspot.com",
+	UnifiedFleetService: "ufs.api.cr.dev",
+	SwarmingService:     "https://chromium-swarm-dev.appspot.com/",
+	// TODO(crbug/1128496): remove when fixed
+	SwarmingServiceAccount: "skylab-admin-task@chromeos-service-accounts-dev.iam.gserviceaccount.com",
+	LogdogService:          "luci-logdog-dev.appspot.com",
+	QueenService:           "drone-queen-dev.appspot.com",
+}
+
+// prodEnv is the prod environment.
+var prodEnv = Environment{
+	// TODO(gregorynisbet): remove once stable version moves to UFS.
+	AdminService:        "chromeos-skylab-bot-fleet.appspot.com",
+	InventoryService:    "cros-lab-inventory.appspot.com",
+	UnifiedFleetService: "ufs.api.cr.dev",
+	SwarmingService:     "https://chromeos-swarming.appspot.com/",
+	// TODO(crbug/1128496): remove when fixed
+	SwarmingServiceAccount: "skylab-admin-task@chromeos-service-accounts.iam.gserviceaccount.com",
+	LogdogService:          "luci-logdog.appspot.com",
+	QueenService:           "drone-queen-prod.appspot.com",
+}
diff --git a/go/src/infra/cmd/shivas/site/config_local.go b/go/src/infra/cmd/shivas/site/config_local.go
new file mode 100644
index 0000000..1360e4f
--- /dev/null
+++ b/go/src/infra/cmd/shivas/site/config_local.go
@@ -0,0 +1,44 @@
+// Copyright 2025 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Only build this if local is used
+//go:build local
+
+// Package site contains site local constants for the shivas
+package site
+
+const localDefault = true
+
+// localDevEnv is the local dev environment.
+var localDevEnv = Environment{
+	AdminService:           "skylab-staging-bot-fleet.appspot.com",
+	InventoryService:       "0.0.0.0:8082",
+	UnifiedFleetService:    "127.0.0.1:8800",
+	SwarmingService:        "https://chromium-swarm-dev.appspot.com/",
+	SwarmingServiceAccount: "skylab-admin-task@chromeos-service-accounts-dev.iam.gserviceaccount.com",
+	LogdogService:          "luci-logdog-dev.appspot.com",
+	QueenService:           "drone-queen-dev.appspot.com",
+}
+
+// devEnv is the environment for the dev cloud project.
+var devEnv = Environment{
+	AdminService:           "skylab-staging-bot-fleet.appspot.com",
+	InventoryService:       "0.0.0.0:8082",
+	UnifiedFleetService:    "127.0.0.1:8800",
+	SwarmingService:        "https://chromium-swarm-dev.appspot.com/",
+	SwarmingServiceAccount: "skylab-admin-task@chromeos-service-accounts-dev.iam.gserviceaccount.com",
+	LogdogService:          "luci-logdog-dev.appspot.com",
+	QueenService:           "drone-queen-dev.appspot.com",
+}
+
+// prodEnv is the prod environment.
+var prodEnv = Environment{
+	AdminService:           "skylab-staging-bot-fleet.appspot.com",
+	InventoryService:       "0.0.0.0:8082",
+	UnifiedFleetService:    "127.0.0.1:8800",
+	SwarmingService:        "https://chromium-swarm-dev.appspot.com/",
+	SwarmingServiceAccount: "skylab-admin-task@chromeos-service-accounts-dev.iam.gserviceaccount.com",
+	LogdogService:          "luci-logdog-dev.appspot.com",
+	QueenService:           "drone-queen-dev.appspot.com",
+}
diff --git a/go/src/infra/cmd/shivas/site/site.go b/go/src/infra/cmd/shivas/site/site.go
index 3d479db..6bd0620 100644
--- a/go/src/infra/cmd/shivas/site/site.go
+++ b/go/src/infra/cmd/shivas/site/site.go
@@ -48,19 +48,6 @@
 	return env
 }
 
-// prodEnv is the prod environment.
-var prodEnv = Environment{
-	// TODO(gregorynisbet): remove once stable version moves to UFS.
-	AdminService:        "chromeos-skylab-bot-fleet.appspot.com",
-	InventoryService:    "cros-lab-inventory.appspot.com",
-	UnifiedFleetService: "ufs.api.cr.dev",
-	SwarmingService:     "https://chromeos-swarming.appspot.com/",
-	// TODO(crbug/1128496): remove when fixed
-	SwarmingServiceAccount: "skylab-admin-task@chromeos-service-accounts.iam.gserviceaccount.com",
-	LogdogService:          "luci-logdog.appspot.com",
-	QueenService:           "drone-queen-prod.appspot.com",
-}
-
 // dev is the environment for dev.
 func dev(isLocal bool, instance string) Environment {
 	if isLocal {
@@ -71,32 +58,6 @@
 	return env
 }
 
-// localDevEnv is the local dev environment.
-var localDevEnv = Environment{
-	// TODO(gregorynisbet): remove once stable version moves to UFS.
-	AdminService:        "skylab-staging-bot-fleet.appspot.com",
-	InventoryService:    "0.0.0.0:8082",
-	UnifiedFleetService: "127.0.0.1:8800",
-	SwarmingService:     "https://chromium-swarm-dev.appspot.com/",
-	// TODO(crbug/1128496): remove when fixed
-	SwarmingServiceAccount: "skylab-admin-task@chromeos-service-accounts-dev.iam.gserviceaccount.com",
-	LogdogService:          "luci-logdog-dev.appspot.com",
-	QueenService:           "drone-queen-dev.appspot.com",
-}
-
-// devEnv is the environment for the dev cloud project.
-var devEnv = Environment{
-	// TODO(gregorynisbet): remove once stable version moves to UFS.
-	AdminService:        "skylab-staging-bot-fleet.appspot.com",
-	InventoryService:    "cros-lab-inventory-dev.appspot.com",
-	UnifiedFleetService: "ufs.api.cr.dev",
-	SwarmingService:     "https://chromium-swarm-dev.appspot.com/",
-	// TODO(crbug/1128496): remove when fixed
-	SwarmingServiceAccount: "skylab-admin-task@chromeos-service-accounts-dev.iam.gserviceaccount.com",
-	LogdogService:          "luci-logdog-dev.appspot.com",
-	QueenService:           "drone-queen-dev.appspot.com",
-}
-
 // CommonFlags controls some commonly-used CLI flags.
 type CommonFlags struct {
 	verbose bool
@@ -161,13 +122,13 @@
 
 // Register sets up the -dev argument.
 func (f *EnvFlags) Register(fl *flag.FlagSet) {
-	fl.BoolVar(&f.local, "local", false, "Run locally (or use env var SHIVAS_ENV=LOCAL)")
+	fl.BoolVar(&f.local, "local", localDefault, "Run locally (or use env var SHIVAS_ENV=LOCAL)")
 	fl.BoolVar(&f.dev, "dev", false, "Run in dev environment (or use env var SHIVAS_ENV=DEV)")
 	fl.StringVar(&f.instance, "instance", "", "Target a specific instance (eg. canary, stable)")
 	fl.StringVar(&f.namespace, "namespace", "", fmt.Sprintf("namespace where data resides. Users can also set os env SHIVAS_NAMESPACE. Valid namespaces: [%s]", strings.Join(ufsUtil.ValidClientNamespaceStr(), ", ")))
 
 	shivasEnv := strings.ToLower(os.Getenv("SHIVAS_ENV"))
-	f.local = shivasEnv == "local"
+	f.local = f.local || (shivasEnv == "local")
 	f.dev = shivasEnv == "dev"
 }