treewide: replace datafile pkg with rules_go/runfiles pkg

rules_go/runfiles provides the same functionality as our datafile
package. This change also contains some specifics for the now active
bzlmod, which replaces all WORKSPACE related behaviour. As example the
WORKSPACE name is now always set to _main.


Change-Id: I1a69c72b479330a627b402135670f218c297906f
Reviewed-on: https://review.monogon.dev/c/monogon/+/2745
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/test/launch/cluster/BUILD.bazel b/metropolis/test/launch/cluster/BUILD.bazel
index 08d4cfe..6c9b10a 100644
--- a/metropolis/test/launch/cluster/BUILD.bazel
+++ b/metropolis/test/launch/cluster/BUILD.bazel
@@ -20,7 +20,6 @@
     visibility = ["//visibility:public"],
     deps = [
         "//metropolis/cli/metroctl/core",
-        "//metropolis/cli/pkg/datafile",
         "//metropolis/node",
         "//metropolis/node/core/identity",
         "//metropolis/node/core/rpc",
@@ -32,6 +31,7 @@
         "//metropolis/test/launch",
         "@com_github_cenkalti_backoff_v4//:backoff",
         "@com_github_kballard_go_shellquote//:go-shellquote",
+        "@io_bazel_rules_go//go/runfiles:go_default_library",
         "@io_k8s_client_go//kubernetes",
         "@io_k8s_client_go//rest",
         "@org_golang_google_grpc//:go_default_library",
diff --git a/metropolis/test/launch/cluster/cluster.go b/metropolis/test/launch/cluster/cluster.go
index 06b928b..fd69b77 100644
--- a/metropolis/test/launch/cluster/cluster.go
+++ b/metropolis/test/launch/cluster/cluster.go
@@ -25,6 +25,7 @@
 	"syscall"
 	"time"
 
+	"github.com/bazelbuild/rules_go/go/runfiles"
 	"github.com/cenkalti/backoff/v4"
 	"go.uber.org/multierr"
 	"golang.org/x/net/proxy"
@@ -39,7 +40,6 @@
 	cpb "source.monogon.dev/metropolis/proto/common"
 
 	metroctl "source.monogon.dev/metropolis/cli/metroctl/core"
-	"source.monogon.dev/metropolis/cli/pkg/datafile"
 	"source.monogon.dev/metropolis/node"
 	"source.monogon.dev/metropolis/node/core/identity"
 	"source.monogon.dev/metropolis/node/core/rpc"
@@ -130,7 +130,7 @@
 	}
 
 	// Initialize the node's storage with a prebuilt image.
-	si, err := datafile.ResolveRunfile("metropolis/node/image.img")
+	si, err := runfiles.Rlocation("_main/metropolis/node/image.img")
 	if err != nil {
 		return nil, fmt.Errorf("while resolving a path: %w", err)
 	}
@@ -141,7 +141,7 @@
 	}
 
 	// Initialize the OVMF firmware variables file.
-	sv, err := datafile.ResolveRunfile("external/edk2/OVMF_VARS.fd")
+	sv, err := runfiles.Rlocation("edk2/OVMF_VARS.fd")
 	if err != nil {
 		return nil, fmt.Errorf("while resolving a path: %w", err)
 	}
@@ -155,7 +155,7 @@
 	if err := os.Mkdir(tpmt, 0o755); err != nil {
 		return nil, fmt.Errorf("while creating the TPM directory: %w", err)
 	}
-	tpms, err := datafile.ResolveRunfile("metropolis/node/tpm")
+	tpms, err := runfiles.Rlocation("_main/metropolis/node/tpm")
 	if err != nil {
 		return nil, fmt.Errorf("while resolving a path: %w", err)
 	}
@@ -165,7 +165,7 @@
 	}
 	for _, file := range tpmf {
 		name := file.Name()
-		src, err := datafile.ResolveRunfile(filepath.Join(tpms, name))
+		src, err := runfiles.Rlocation(filepath.Join(tpms, name))
 		if err != nil {
 			return nil, fmt.Errorf("while resolving a path: %w", err)
 		}
diff --git a/metropolis/test/launch/cluster/metroctl.go b/metropolis/test/launch/cluster/metroctl.go
index 54a62fc..fbf968a 100644
--- a/metropolis/test/launch/cluster/metroctl.go
+++ b/metropolis/test/launch/cluster/metroctl.go
@@ -9,10 +9,10 @@
 	"path"
 	"sort"
 
+	"github.com/bazelbuild/rules_go/go/runfiles"
 	"github.com/kballard/go-shellquote"
 
 	metroctl "source.monogon.dev/metropolis/cli/metroctl/core"
-	"source.monogon.dev/metropolis/cli/pkg/datafile"
 )
 
 const metroctlRunfile = "metropolis/cli/metroctl/metroctl_/metroctl"
@@ -21,7 +21,7 @@
 // if the built target depends on //metropolis/cli/metroctl. Otherwise, an error
 // is returned.
 func MetroctlRunfilePath() (string, error) {
-	path, err := datafile.ResolveRunfile(metroctlRunfile)
+	path, err := runfiles.Rlocation(metroctlRunfile)
 	if err != nil {
 		return "", fmt.Errorf("//metropolis/cli/metroctl not found in runfiles, did you include it as a data dependency? error: %w", err)
 	}