load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
load("@io_bazel_rules_docker//container:container.bzl", "container_image")

container_image(
    name = "nonroot_go_image_static",
    base = "@go_image_static//image",
    # See https://github.com/GoogleContainerTools/distroless/blob/2cac07c7c62b2dc52c4274a1810939fb06039ab9/base/base.bzl#L9
    user = "65532",
)

go_image(
    name = "image",
    base = ":nonroot_go_image_static",
    binary = ":sample",
    tags = ["manual"],
    visibility = ["//visibility:public"],
)

go_library(
    name = "go_default_library",
    srcs = ["main.go"],
    importpath = "github.com/jetstack/cert-manager/devel/addon/samplewebhook/sample",
    visibility = ["//visibility:private"],
    deps = [
        "//pkg/acme/webhook/apis/acme/v1alpha1:go_default_library",
        "//pkg/acme/webhook/cmd:go_default_library",
        "@io_k8s_apiextensions_apiserver//pkg/apis/apiextensions/v1:go_default_library",
        "@io_k8s_client_go//rest:go_default_library",
    ],
)

go_binary(
    name = "sample",
    embed = [":go_default_library"],
    pure = "on",
    visibility = ["//visibility:public"],
)

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

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