load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//bazel/go:go_test.bzl", "go_test")

go_library(
    name = "cryptmapper",
    srcs = [
        "cryptmapper.go",
        "cryptmapper_cgo.go",
        "cryptmapper_cross.go",
    ],
    importpath = "github.com/edgelesssys/constellation/v2/csi/cryptmapper",
    target_compatible_with = [
        "@platforms//os:linux",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "//internal/crypto",
        "//internal/cryptsetup",
    ] + select({
        "@io_bazel_rules_go//go/platform:android": [
            "@com_github_martinjungblut_go_cryptsetup//:go-cryptsetup",
            "@io_k8s_mount_utils//:mount-utils",
            "@io_k8s_utils//exec",
        ],
        "@io_bazel_rules_go//go/platform:linux": [
            "@com_github_martinjungblut_go_cryptsetup//:go-cryptsetup",
            "@io_k8s_mount_utils//:mount-utils",
            "@io_k8s_utils//exec",
        ],
        "//conditions:default": [],
    }),
)

go_test(
    name = "cryptmapper_test",
    srcs = ["cryptmapper_test.go"],
    embed = [":cryptmapper"],
    # keep
    pure = "on",
    # keep
    race = "off",
    deps = [
        "@com_github_stretchr_testify//assert",
        "@org_uber_go_goleak//:goleak",
    ],
)
