package(default_visibility = ["//visibility:public"])

# General repo verification targets

py_test(
    name = "verify-boilerplate",
    srcs = ["verify_boilerplate.py"],
    data = ["//:all-srcs"],
    main = "verify_boilerplate.py",
    tags = ["lint"],
)

sh_test(
    name = "verify-errexit",
    srcs = ["verify-errexit.sh"],
    data = [
        "//:all-srcs",
    ],
    tags = ["lint"],
)

sh_test(
    name = "verify-links",
    srcs = ["verify-links.sh"],
    data = [
        "//:all-srcs",
    ],
    tags = ["lint"],
)

# Bazel file generation rules

sh_binary(
    name = "update-bazel",
    srcs = ["update-bazel.sh"],
    data = [
        "//hack/bin:buildozer",
        "//hack/bin:gazelle",
        "//hack/bin:kazel",
    ],
)

sh_test(
    name = "verify-bazel",
    srcs = ["verify-bazel.sh"],
    data = [
        ":update-bazel",
        "//:all-srcs",
    ],
)

# Dep/vendor rules
# These have been deprecated in favour of directly calling the shell scripts.
sh_binary(
    name = "update-deps",
    srcs = ["deprecated.sh"],
    args = ["hack/update-vendor.sh"],
)

sh_test(
    name = "verify-deps",
    srcs = ["deprecated.sh"],
    args = ["hack/verify-vendor.sh"],
    tags = ["manual"],
)

# Kubernetes codegen rules

sh_binary(
    name = "update-codegen",
    srcs = ["update-codegen.sh"],
    data = [
        "//hack:update-bazel",
        "//hack/boilerplate:all-srcs",
        "//third_party/k8s.io/code-generator:generate-groups",
        "//third_party/k8s.io/code-generator:generate-groups-internal",
    ],
)

sh_test(
    name = "verify-codegen",
    srcs = ["verify-codegen.sh"],
    data = [
        ":update-codegen",
        "//:all-srcs",
    ],
)

# Reference docs generation rules
sh_binary(
    name = "update-reference-docs",
    srcs = ["update-reference-docs.sh"],
    data = [
        "//docs/generated/reference/generate",
    ],
)

sh_test(
    name = "verify-reference-docs",
    srcs = ["verify-reference-docs.sh"],
    data = [
        "//docs/generated/reference:output",
        "//docs/generated/reference/generate",
        "//hack:update-reference-docs.sh",
    ],
)

# Gofmt rules

sh_binary(
    name = "update-gofmt",
    srcs = ["update-gofmt.sh"],
    data = [
        "//hack/bin:gofmt",
    ],
)

sh_test(
    name = "verify-gofmt",
    srcs = ["verify-gofmt.sh"],
    data = [
        "//:all-srcs",
        "//hack/bin:gofmt",
    ],
)

sh_binary(
    name = "update-crds",
    srcs = ["update-crds.sh"],
    data = [
        "//hack/bin:controller-gen",
        "//pkg/apis:all-srcs",
        # Include all of pkg/util in case the pkg/apis package depends on it.
        # Technically this shouldn't happen and should be avoided. Whilst we
        # still have some cases of it however, this helps us overcome problems.
        # These two are generally required due to the validation package being
        # built by the controller-gen tool.
        "//pkg/util:all-srcs",
        "//pkg/api/util:all-srcs",
        "//vendor:all-srcs",
        "@go_sdk//:files",
    ],
)

sh_test(
    name = "verify-crds",
    srcs = ["verify-crds.sh"],
    data = [
        ":update-crds",
        "//deploy:all-srcs",
    ],
)

filegroup(
    name = "package-srcs",
    srcs = glob(["**"]),
    tags = ["automanaged"],
    visibility = ["//visibility:private"],
)

filegroup(
    name = "all-srcs",
    srcs = [
        ":package-srcs",
        "//hack/bin:all-srcs",
        "//hack/boilerplate:all-srcs",
        "//hack/release:all-srcs",
    ],
    tags = ["automanaged"],
    visibility = ["//visibility:public"],
)
