load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_docker//container:bundle.bzl", "container_bundle")

container_bundle(
    name = "images",
    images = {
        # A set of images to bundle up into a single tarball.
        "pebble:bazel": "//test/e2e/charts/pebble:image",
        "quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.23.0": "@io_kubernetes_ingress-nginx//image",
        "k8s.gcr.io/defaultbackend:bazel": "@io_gcr_k8s_defaultbackend//image",
        "vault:bazel": "@com_hashicorp_vault//image",
        "sample-webhook:bazel": "//test/e2e/framework/addon/samplewebhook/sample:image",
        "gcr.io/kubernetes-helm/tiller:bazel": "@io_gcr_helm_tiller//image",
        "{STABLE_DOCKER_REPO}/cert-manager-controller:{STABLE_DOCKER_TAG}": "//cmd/controller:image",
        "{STABLE_DOCKER_REPO}/cert-manager-acmesolver:{STABLE_DOCKER_TAG}": "//cmd/acmesolver:image",
        "{STABLE_DOCKER_REPO}/cert-manager-webhook:{STABLE_DOCKER_TAG}": "//cmd/webhook:image",
        "{STABLE_DOCKER_REPO}/cert-manager-cainjector:{STABLE_DOCKER_TAG}": "//cmd/cainjector:image",
    },
    tags = ["manual"],
)

# we add this rule so users can `bazel build //test/e2e` to run a
# platform-independent version of the e2e test binary
genrule(
    name = "e2e",
    testonly = True,
    srcs = [":go_default_test"],
    outs = ["e2e.test"],
    cmd = "cp $(SRCS) $@",
    visibility = ["//visibility:public"],
)

go_library(
    name = "go_default_library",
    srcs = ["e2e.go"],
    importpath = "github.com/jetstack/cert-manager/test/e2e",
    tags = ["manual"],
    visibility = ["//visibility:public"],
    deps = [
        "//test/e2e/framework:go_default_library",
        "//test/e2e/framework/addon:go_default_library",
        "//test/e2e/framework/log:go_default_library",
        "//vendor/github.com/onsi/ginkgo:go_default_library",
    ],
)

go_test(
    name = "go_default_test",
    srcs = ["e2e_test.go"],
    embed = [":go_default_library"],
    tags = ["manual"],
    deps = [
        "//pkg/logs:go_default_library",
        "//test/e2e/framework:go_default_library",
        "//test/e2e/suite:go_default_library",
        "//vendor/github.com/onsi/ginkgo:go_default_library",
        "//vendor/github.com/onsi/ginkgo/config:go_default_library",
        "//vendor/github.com/onsi/ginkgo/reporters:go_default_library",
        "//vendor/github.com/onsi/gomega:go_default_library",
        "//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
    ],
)

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

filegroup(
    name = "all-srcs",
    srcs = [
        ":package-srcs",
        "//test/e2e/bin/cloudflare-clean:all-srcs",
        "//test/e2e/charts:all-srcs",
        "//test/e2e/framework:all-srcs",
        "//test/e2e/suite:all-srcs",
        "//test/e2e/util:all-srcs",
    ],
    tags = ["automanaged"],
    visibility = ["//visibility:public"],
)
