load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//bazel/go:go_test.bzl", "go_ld_test", "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 = select({
        "@io_bazel_rules_go//go/platform:android": [
            "//internal/crypto",
            "//internal/cryptsetup",
            "@com_github_martinjungblut_go_cryptsetup//:go-cryptsetup",
            "@io_k8s_mount_utils//:mount-utils",
            "@io_k8s_utils//exec",
        ],
        "@io_bazel_rules_go//go/platform:linux": [
            "//internal/crypto",
            "//internal/cryptsetup",
            "@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
    tags = ["manual"],
    deps = select({
        "@io_bazel_rules_go//go/platform:android": [
            "@com_github_martinjungblut_go_cryptsetup//:go-cryptsetup",
            "@com_github_stretchr_testify//assert",
            "@org_uber_go_goleak//:goleak",
        ],
        "@io_bazel_rules_go//go/platform:linux": [
            "@com_github_martinjungblut_go_cryptsetup//:go-cryptsetup",
            "@com_github_stretchr_testify//assert",
            "@org_uber_go_goleak//:goleak",
        ],
        "//conditions:default": [],
    }),
)

go_ld_test(
    name = "cryptmapper_ld_test",
    src = "cryptmapper_test",
    ld = "//rpm:ld",
)