# Clone empty version of cert-manager repo and list all tags
genrule(
    name = "git_tags",
    outs = [":git_tags.txt"],
    cmd = "git ls-remote -t --refs https://github.com/jetstack/cert-manager.git | awk '{print $$2;}' | sed 's/refs\\/tags\\///' | sed -n '/v1.0.0/,$$p' > $@",
)

genrule(
    name = "test_manifests",
    srcs = [
        "//:version",
        "//deploy/manifests:cert-manager.yaml",
        ":git_tags.txt",
    ],
    outs = ["test_manifests.tar"],
    cmd = """
        $(location fetch.sh) \
        $(location //:version) \
        $(location //deploy/manifests:cert-manager.yaml) \
        $(location :git_tags.txt) \
        $(location test_manifests.tar)
    """,
    tools = [
        "fetch.sh",
    ],
    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"],
)
