treewide: replace hardcoded runfiles paths

We hardcoded some of the runfiles paths to find specific files. This replaces the hardcoded paths by a call to rlocationpath. This prevents running a target without the correct dependencies at build time instead of at runtime

Change-Id: I7ce56935ac80be6b28b824ccb0781ab401bd6521
Reviewed-on: https://review.monogon.dev/c/monogon/+/3301
Reviewed-by: Serge Bazanski <serge@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/test/launch/launch.go b/metropolis/test/launch/launch.go
new file mode 100644
index 0000000..d6c29fe
--- /dev/null
+++ b/metropolis/test/launch/launch.go
@@ -0,0 +1,37 @@
+package launch
+
+import (
+	"github.com/bazelbuild/rules_go/go/runfiles"
+)
+
+var (
+	// These are filled by bazel at linking time with the canonical path of
+	// their corresponding file. Inside the init function we resolve it
+	// with the rules_go runfiles package to the real path.
+	xSwtpmPath        string
+	xSwtpmSetupPath   string
+	xSwtpmLocalCAPath string
+	xSwtpmCertPath    string
+	xCerttoolPath     string
+	xMetroctlPath     string
+	xOvmfCodePath     string
+	xOvmfVarsPath     string
+	xKernelPath       string
+	xInitramfsPath    string
+	xNodeImagePath    string
+)
+
+func init() {
+	var err error
+	for _, path := range []*string{
+		&xSwtpmPath, &xSwtpmSetupPath, &xSwtpmLocalCAPath,
+		&xSwtpmCertPath, &xCerttoolPath, &xMetroctlPath,
+		&xOvmfCodePath, &xOvmfVarsPath, &xKernelPath,
+		&xInitramfsPath, &xNodeImagePath,
+	} {
+		*path, err = runfiles.Rlocation(*path)
+		if err != nil {
+			panic(err)
+		}
+	}
+}