load("@prysm//tools/go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load("//tools:prysm_image.bzl", "prysm_image_upload")

go_library(
    name = "go_default_library",
    srcs = [
        "main.go",
        "usage.go",
    ],
    importpath = "github.com/OffchainLabs/prysm/v6/cmd/validator",
    visibility = ["//validator:__subpackages__"],
    deps = [
        "//cmd:go_default_library",
        "//cmd/validator/accounts:go_default_library",
        "//cmd/validator/db:go_default_library",
        "//cmd/validator/flags:go_default_library",
        "//cmd/validator/slashing-protection:go_default_library",
        "//cmd/validator/wallet:go_default_library",
        "//cmd/validator/web:go_default_library",
        "//config/features:go_default_library",
        "//io/file:go_default_library",
        "//io/logs:go_default_library",
        "//monitoring/journald:go_default_library",
        "//runtime/debug:go_default_library",
        "//runtime/logging/logrus-prefixed-formatter:go_default_library",
        "//runtime/maxprocs:go_default_library",
        "//runtime/tos:go_default_library",
        "//runtime/version:go_default_library",
        "//validator/node:go_default_library",
        "@com_github_joonix_log//:go_default_library",
        "@com_github_pkg_errors//:go_default_library",
        "@com_github_sirupsen_logrus//:go_default_library",
        "@com_github_urfave_cli_v2//:go_default_library",
    ],
)

go_binary(
    name = "validator",
    embed = [":go_default_library"],
    pure = "off",  # Enabled unless there is a valid reason to include cgo dep.
    visibility = [
        "//testing/endtoend:__pkg__",
        "//validator:__subpackages__",
    ],
)

go_test(
    name = "go_default_test",
    srcs = ["usage_test.go"],
    embed = [":go_default_library"],
    visibility = ["//validator:__pkg__"],
    deps = [
        "//config/features:go_default_library",
        "@com_github_urfave_cli_v2//:go_default_library",
    ],
)

prysm_image_upload(
    name = "push_images",
    binary = ":validator",
    entrypoint = ["/validator"],
    repository = "gcr.io/offchainlabs/prysm/validator",
    symlinks = {
        # Backwards compatibility for images that depended on the old filepath.
        "/app/cmd/validator/validator": "/validator",
    },
    tags = ["manual"],
)
