load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_cross_binary", "go_library")

# keep
go_binary(
    name = "tf_provider",
    out = "terraform-provider-constellation",  # for complying with Terraform provider naming convention
    embed = [":terraform-provider-constellation_lib"],
    pure = "on",
    visibility = ["//visibility:public"],
)

[
    go_cross_binary(
        name = "tf_provider_%s" % platform,
        platform = "@io_bazel_rules_go//go/toolchain:" + platform,
        target = ":tf_provider",
        visibility = ["//visibility:public"],
    )
    for platform in [
        "darwin_amd64",
        "darwin_arm64",
        "linux_amd64",
        "linux_arm64",
        "windows_amd64",
    ]
]

go_library(
    name = "terraform-provider-constellation_lib",
    srcs = ["main.go"],
    importpath = "github.com/edgelesssys/constellation/v2/terraform-provider-constellation",
    visibility = ["//visibility:private"],
    x_defs = {
        "version": "{STABLE_STAMP_VERSION}",
    },
    deps = [
        "//terraform-provider-constellation/internal/provider",
        "@com_github_hashicorp_terraform_plugin_framework//providerserver",
    ],
)

copy_file(
    name = "terraform_rc",
    src = "config.tfrc.tpl",
    out = "config.tfrc",
    allow_symlink = True,
    visibility = ["//visibility:public"],
)
