From ea4b15d95ccd2b4bf13263d872930552b8be2547 Mon Sep 17 00:00:00 2001 From: Dan Fuhry Date: Thu, 23 Apr 2026 13:24:13 -0400 Subject: [PATCH] Cross-compilation support, phase 1 Get everything building without hooking up mtls_cgo. Co-Authored-By: Qwen3.6-35B-A3B --- BUILD.bazel | 2 + attestation/cgo/BUILD.bazel | 6 +- attestation/client/BUILD.bazel | 6 +- attestation/internal/attestation/BUILD.bazel | 4 +- attestation/rpc_client/BUILD.bazel | 6 +- attestation/rpc_server/BUILD.bazel | 6 +- automation/bryston_ctl/BUILD.bazel | 4 +- automation/bryston_ctl/cli/BUILD.bazel | 6 +- automation/bryston_ctl/client/BUILD.bazel | 6 +- automation/bryston_ctl/server/BUILD.bazel | 6 +- bazel/copy.bzl | 11 +++ bazel/cross.bzl | 55 ++++++++++++--- bazel/go.bzl | 64 +++++++++++++++++ bazel/pkg.bzl | 2 +- bazel/subst/BUILD.bazel | 6 +- cmd/apcups_exporter/BUILD.bazel | 12 +--- cmd/echo_client/BUILD.bazel | 6 +- cmd/echo_server/BUILD.bazel | 6 +- cmd/ephs_client/BUILD.bazel | 6 +- cmd/ephs_server/BUILD.bazel | 7 +- cmd/grpc_health_probe/BUILD.bazel | 6 +- cmd/http_proxy/BUILD.bazel | 6 +- cmd/ldap_health_exporter/BUILD.bazel | 6 +- cmd/machines_agent/BUILD.bazel | 6 +- cmd/machines_event_monitor/BUILD.bazel | 6 +- cmd/metricbus_server/BUILD.bazel | 6 +- cmd/mint_server/BUILD.bazel | 6 +- cmd/mtls_exporter/BUILD.bazel | 6 +- cmd/mtls_supervisor/BUILD.bazel | 6 +- cmd/mtls_verify_tool/BUILD.bazel | 6 +- cmd/prometheus_http_discovery/BUILD.bazel | 7 +- cmd/sase_ws_proxy_client/BUILD.bazel | 6 +- cmd/sase_ws_tcp_proxy/BUILD.bazel | 6 +- cmd/sd_health_exporter/BUILD.bazel | 6 +- cmd/sd_publish/BUILD.bazel | 6 +- cmd/sd_register/BUILD.bazel | 6 +- cmd/sd_watcher/BUILD.bazel | 6 +- config_watcher/BUILD.bazel | 4 +- constants/BUILD.bazel | 4 +- constants/generate/BUILD.bazel | 6 +- echo/BUILD.bazel | 4 +- ephs/BUILD.bazel | 4 +- ephs/ephsll/BUILD.bazel | 5 +- ephs/servicer/BUILD.bazel | 5 +- grpc/BUILD.bazel | 4 +- grpc/internal/acl/BUILD.bazel | 4 +- grpc/internal/client/BUILD.bazel | 4 +- grpc/internal/common/BUILD.bazel | 4 +- grpc/internal/server/BUILD.bazel | 4 +- http/BUILD.bazel | 5 +- ldap/BUILD.bazel | 4 +- machines/BUILD.bazel | 5 +- machines/coredns_plugin/BUILD.bazel | 4 +- metrics/metricbus/BUILD.bazel | 4 +- metrics/metricbus/mbclient/BUILD.bazel | 4 +- .../metricbus/mbclient/example/BUILD.bazel | 6 +- metrics/metricbus/mbserver/BUILD.bazel | 4 +- metrics/mtls/BUILD.bazel | 4 +- mint/BUILD.bazel | 4 +- mint/remote_signer/BUILD.bazel | 4 +- mint/servicer/BUILD.bazel | 5 +- mtls/BUILD.bazel | 69 ++++++++++++++----- mtls/certutil/BUILD.bazel | 4 +- mtls/fsnotify/BUILD.bazel | 5 +- mtls/pkcs11.go | 7 +- mtls/provider_keychain_macos.go | 6 +- mtls/provider_tpm2_pkcs11.go | 9 ++- net/BUILD.bazel | 4 +- net/dns/BUILD.bazel | 4 +- pkg/nfpmgen/BUILD.bazel | 6 +- proto/service/attest/BUILD.bazel | 4 +- proto/service/bryston_ctl/BUILD.bazel | 4 +- proto/service/echo/BUILD.bazel | 4 +- proto/service/ephs/BUILD.bazel | 4 +- proto/service/mint/BUILD.bazel | 4 +- rand/BUILD.bazel | 4 +- sase/BUILD.bazel | 5 +- sd/BUILD.bazel | 4 +- thirdparty/registry/BUILD.bazel | 6 +- utils/BUILD.bazel | 4 +- utils/ansi/BUILD.bazel | 4 +- utils/checkers/BUILD.bazel | 4 +- utils/context/BUILD.bazel | 4 +- utils/daemon/BUILD.bazel | 4 +- utils/debounce/BUILD.bazel | 5 +- utils/fsutil/BUILD.bazel | 4 +- utils/generics/BUILD.bazel | 4 +- utils/hashset/BUILD.bazel | 5 +- utils/hostname/BUILD.bazel | 5 +- utils/log/BUILD.bazel | 4 +- utils/option/BUILD.bazel | 4 +- utils/rollout/BUILD.bazel | 4 +- utils/slices2/BUILD.bazel | 4 +- utils/stringmatch/BUILD.bazel | 5 +- utils/strings2/BUILD.bazel | 4 +- utils/subst/BUILD.bazel | 4 +- 96 files changed, 408 insertions(+), 252 deletions(-) create mode 100644 bazel/copy.bzl create mode 100644 bazel/go.bzl diff --git a/BUILD.bazel b/BUILD.bazel index 56ab7d8..d91add0 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,7 @@ load("@gazelle//:def.bzl", "gazelle") # gazelle:proto legacy +# gazelle:map_kind go_binary go_multi_binary //bazel:go.bzl +# gazelle:map_kind go_library go_multi_library //bazel:go.bzl gazelle(name = "gazelle") diff --git a/attestation/cgo/BUILD.bazel b/attestation/cgo/BUILD.bazel index a3d633d..66d4835 100644 --- a/attestation/cgo/BUILD.bazel +++ b/attestation/cgo/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "cgo_lib", srcs = [ "extension.h", @@ -16,7 +16,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "cgo", embed = [":cgo_lib"], visibility = ["//visibility:public"], diff --git a/attestation/client/BUILD.bazel b/attestation/client/BUILD.bazel index 6db030d..66faf26 100644 --- a/attestation/client/BUILD.bazel +++ b/attestation/client/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "client_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/attestation/client", @@ -8,7 +8,7 @@ go_library( deps = ["//attestation/internal/attestation"], ) -go_binary( +go_multi_binary( name = "client", embed = [":client_lib"], visibility = ["//visibility:public"], diff --git a/attestation/internal/attestation/BUILD.bazel b/attestation/internal/attestation/BUILD.bazel index ccc655e..bc9213e 100644 --- a/attestation/internal/attestation/BUILD.bazel +++ b/attestation/internal/attestation/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "attestation", srcs = [ "api.go", diff --git a/attestation/rpc_client/BUILD.bazel b/attestation/rpc_client/BUILD.bazel index 71bcdad..5d48a3f 100644 --- a/attestation/rpc_client/BUILD.bazel +++ b/attestation/rpc_client/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "rpc_client_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/attestation/rpc_client", @@ -14,7 +14,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "rpc_client", embed = [":rpc_client_lib"], visibility = ["//visibility:public"], diff --git a/attestation/rpc_server/BUILD.bazel b/attestation/rpc_server/BUILD.bazel index 4043c16..c18bf2a 100644 --- a/attestation/rpc_server/BUILD.bazel +++ b/attestation/rpc_server/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "rpc_server_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/attestation/rpc_server", @@ -15,7 +15,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "rpc_server", embed = [":rpc_server_lib"], visibility = ["//visibility:public"], diff --git a/automation/bryston_ctl/BUILD.bazel b/automation/bryston_ctl/BUILD.bazel index 5a361c4..6c704c7 100644 --- a/automation/bryston_ctl/BUILD.bazel +++ b/automation/bryston_ctl/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "bryston_ctl", srcs = [ "bryston_ctl.go", diff --git a/automation/bryston_ctl/cli/BUILD.bazel b/automation/bryston_ctl/cli/BUILD.bazel index cb55047..deb4c98 100644 --- a/automation/bryston_ctl/cli/BUILD.bazel +++ b/automation/bryston_ctl/cli/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "cli_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/automation/bryston_ctl/cli", @@ -12,7 +12,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "cli", embed = [":cli_lib"], visibility = ["//visibility:public"], diff --git a/automation/bryston_ctl/client/BUILD.bazel b/automation/bryston_ctl/client/BUILD.bazel index be8018a..8f38fc3 100644 --- a/automation/bryston_ctl/client/BUILD.bazel +++ b/automation/bryston_ctl/client/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "client_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/automation/bryston_ctl/client", @@ -15,7 +15,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "client", embed = [":client_lib"], visibility = ["//visibility:public"], diff --git a/automation/bryston_ctl/server/BUILD.bazel b/automation/bryston_ctl/server/BUILD.bazel index f176641..7731157 100644 --- a/automation/bryston_ctl/server/BUILD.bazel +++ b/automation/bryston_ctl/server/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "server_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/automation/bryston_ctl/server", @@ -16,7 +16,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "server", embed = [":server_lib"], visibility = ["//visibility:public"], diff --git a/bazel/copy.bzl b/bazel/copy.bzl new file mode 100644 index 0000000..40ce900 --- /dev/null +++ b/bazel/copy.bzl @@ -0,0 +1,11 @@ +def deepcopy(thing): + if type(thing) == list: + return [deepcopy(i) for i in thing] + elif type(thing) == dict: + return { + k: deepcopy(v) for k, v in thing.items() + } + elif type(thing) in [str, bool, int] or thing == None: + return thing + else: + return thing diff --git a/bazel/cross.bzl b/bazel/cross.bzl index 1aa4b79..93828ef 100644 --- a/bazel/cross.bzl +++ b/bazel/cross.bzl @@ -3,11 +3,13 @@ load("@rules_go//go:def.bzl", "go_cross_binary") def _go_cross_target( base_target, platform, + cross_lib_target, ): + """Create a single cross-compiled binary variant.""" go_cross_binary( name = "{}_{}".format(base_target, platform), platform = "@rules_go//go/toolchain:{}".format(platform), - target = ":{}".format(base_target), + target = cross_lib_target, ) def go_cross_binaries( @@ -15,22 +17,53 @@ def go_cross_binaries( mac = False, openbsd = False, linux_arm = False, + linux_amd64_alpine = False, + cross_lib = None, ): """ - go_cross_binaries + Create cross-compiled binary variants of a base target. + + For libraries that have both no_cgo and _cgo variants (like mtls), + cross binaries automatically use the no_cgo variant to avoid CGO issues. Args: - base_target: base go_binary target - mac: generate targets for macOS - openbsd: generate targets for OpenBSD - linux_arm: generate targets for Linux arm64 + base_target: base go_binary target name (without :) + mac: generate targets for macOS (darwin_amd64, darwin_arm64) + openbsd: generate target for OpenBSD amd64 + linux_arm: generate target for Linux arm64 + linux_amd64_alpine: generate Alpine Linux amd64 target (pure, fully_static_link) + cross_lib: explicit label of the cross-compiled library to use. + If not provided, auto-derived from base_target: + - If {base_target}_lib exists and has a {base_target}_lib_no_cgo variant, + use that + - Otherwise falls back to {base_target}_lib (legacy behavior) """ + # Determine which library label to use for cross compilation + if cross_lib: + lib_target = cross_lib + else: + lib_target = ":" + base_target + "_lib" + + def _cross(lib_label, platform): + _go_cross_target(base_target, platform, lib_label) + if mac: for arch in ["amd64", "arm64"]: - _go_cross_target(base_target, "darwin_{}".format(arch)) - + _cross(lib_target, "darwin_{}".format(arch)) + if openbsd: - _go_cross_target(base_target, "openbsd_amd64") - + _cross(lib_target, "openbsd_amd64") + if linux_arm: - _go_cross_target(base_target, "linux_arm64") \ No newline at end of file + _cross(lib_target, "linux_arm64") + + if linux_amd64_alpine: + go_cross_binary( + name = "{}_linux_amd64_alpine".format(base_target), + platform = "@rules_go//go/toolchain:linux_amd64", + target = lib_target, + features = [ + "pure", + "fully_static_link", + ], + ) diff --git a/bazel/go.bzl b/bazel/go.bzl new file mode 100644 index 0000000..531c2ee --- /dev/null +++ b/bazel/go.bzl @@ -0,0 +1,64 @@ +load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:copy.bzl", "deepcopy") + +def rewrite_deps( + kwargs, # type: dict[str, Any] + keys, # type: list[str] + suffix, # type: str +): # type: dict[str, Any] + new_kwa = deepcopy(kwargs) + for k in keys: + if k in new_kwa: + new_kwa[k] = [ + dep + suffix if (dep.startswith(":") or dep.startswith("//")) else dep + for dep in new_kwa[k] + ] + + return new_kwa + +def go_multi_library(name, **kwargs): + """ + Create a Go library target. + + Args: + name: Library name (without : or //) + **kwargs: Passed to go_library. Must include srcs, importpath, deps, etc. + + Creates: + - {name}: single library target + """ + go_library( + name = name, + **kwargs, + ) + +def _pkcs11_select(): + """Return a select() expression that enables pkcs11 only on linux_amd64 host.""" + return select({ + "@rules_go//go/platform:linux_amd64": ["pkcs11"], + "//conditions:default": [], + }) + +def go_multi_binary(name, **kwargs): + """ + Create a Go binary target with conditional pkcs11 gotag. + + pkcs11 is only enabled when the host platform is linux_amd64 (where + cgo + libtpm2-pkcs11 are available). On other host platforms it is + excluded automatically via select(). + + Args: + name: Binary name + **kwargs: Passed to go_binary. embed, deps, etc. + + Creates: + - {name}: native binary with conditional pkcs11 gotag + """ + native_kwargs = deepcopy(kwargs) + # Conditional pkcs11: only when host platform is linux_amd64 + native_kwargs.setdefault("gotags", _pkcs11_select()) + + go_binary( + name = name, + **native_kwargs, + ) diff --git a/bazel/pkg.bzl b/bazel/pkg.bzl index 5144701..db25097 100644 --- a/bazel/pkg.bzl +++ b/bazel/pkg.bzl @@ -66,5 +66,5 @@ def nfpm_package( data, # type: list[str] ): #for packager in ["deb", "archlinux", "rpm"]: - for packager in ["archlinux"]: + for packager in ["archlinux", "apk", "deb"]: _nfpm_package(name, config, data, packager) \ No newline at end of file diff --git a/bazel/subst/BUILD.bazel b/bazel/subst/BUILD.bazel index 9bad5cd..9dd7a87 100644 --- a/bazel/subst/BUILD.bazel +++ b/bazel/subst/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "subst_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/bazel/subst", @@ -8,7 +8,7 @@ go_library( deps = ["//utils/subst"], ) -go_binary( +go_multi_binary( name = "subst", embed = [":subst_lib"], visibility = ["//visibility:public"], diff --git a/cmd/apcups_exporter/BUILD.bazel b/cmd/apcups_exporter/BUILD.bazel index 30ef531..2f829ec 100644 --- a/cmd/apcups_exporter/BUILD.bazel +++ b/cmd/apcups_exporter/BUILD.bazel @@ -1,8 +1,7 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") -load("//bazel:cross.bzl", "go_cross_binaries") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:svc.bzl", "systemd_service") -go_library( +go_multi_library( name = "apcups_exporter_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/apcups_exporter", @@ -16,7 +15,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "apcups_exporter", embed = [":apcups_exporter_lib"], visibility = ["//visibility:public"], @@ -46,8 +45,3 @@ systemd_service( user = "daemon", deps = ["apcupsd.service"], ) - -go_cross_binaries( - base_target = "apcups_exporter", - linux_arm = True, -) diff --git a/cmd/echo_client/BUILD.bazel b/cmd/echo_client/BUILD.bazel index 00441a3..0f6a746 100644 --- a/cmd/echo_client/BUILD.bazel +++ b/cmd/echo_client/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "echo_client_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/echo_client", @@ -15,7 +15,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "echo_client", embed = [":echo_client_lib"], visibility = ["//visibility:public"], diff --git a/cmd/echo_server/BUILD.bazel b/cmd/echo_server/BUILD.bazel index 799cc93..bba3355 100644 --- a/cmd/echo_server/BUILD.bazel +++ b/cmd/echo_server/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "echo_server_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/echo_server", @@ -16,7 +16,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "echo_server", embed = [":echo_server_lib"], visibility = ["//visibility:public"], diff --git a/cmd/ephs_client/BUILD.bazel b/cmd/ephs_client/BUILD.bazel index 1f4550e..5933180 100644 --- a/cmd/ephs_client/BUILD.bazel +++ b/cmd/ephs_client/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "ephs_client_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/ephs_client", @@ -17,7 +17,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "ephs_client", embed = [":ephs_client_lib"], visibility = ["//visibility:public"], diff --git a/cmd/ephs_server/BUILD.bazel b/cmd/ephs_server/BUILD.bazel index 3d77a80..9ae3d8e 100644 --- a/cmd/ephs_server/BUILD.bazel +++ b/cmd/ephs_server/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "ephs_server_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/ephs_server", @@ -8,6 +8,7 @@ go_library( deps = [ "//ephs/servicer", "//grpc", + "//mint", "//mtls", "//proto/service/ephs", "//utils/context", @@ -16,7 +17,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "ephs_server", embed = [":ephs_server_lib"], visibility = ["//visibility:public"], diff --git a/cmd/grpc_health_probe/BUILD.bazel b/cmd/grpc_health_probe/BUILD.bazel index 1d65ca1..7fb7f5b 100644 --- a/cmd/grpc_health_probe/BUILD.bazel +++ b/cmd/grpc_health_probe/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "grpc_health_probe_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/grpc_health_probe", @@ -14,7 +14,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "grpc_health_probe", embed = [":grpc_health_probe_lib"], visibility = ["//visibility:public"], diff --git a/cmd/http_proxy/BUILD.bazel b/cmd/http_proxy/BUILD.bazel index e701030..e289341 100644 --- a/cmd/http_proxy/BUILD.bazel +++ b/cmd/http_proxy/BUILD.bazel @@ -1,7 +1,7 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:svc.bzl", "systemd_service") -go_library( +go_multi_library( name = "http_proxy_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/http_proxy", @@ -17,7 +17,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "http_proxy", embed = [":http_proxy_lib"], visibility = ["//visibility:public"], diff --git a/cmd/ldap_health_exporter/BUILD.bazel b/cmd/ldap_health_exporter/BUILD.bazel index 472fe00..519c1dd 100644 --- a/cmd/ldap_health_exporter/BUILD.bazel +++ b/cmd/ldap_health_exporter/BUILD.bazel @@ -1,7 +1,7 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:svc.bzl", "systemd_service") -go_library( +go_multi_library( name = "ldap_health_exporter_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/ldap_health_exporter", @@ -16,7 +16,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "ldap_health_exporter", embed = [":ldap_health_exporter_lib"], visibility = ["//visibility:public"], diff --git a/cmd/machines_agent/BUILD.bazel b/cmd/machines_agent/BUILD.bazel index 7fed79b..a1871ec 100644 --- a/cmd/machines_agent/BUILD.bazel +++ b/cmd/machines_agent/BUILD.bazel @@ -1,7 +1,7 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") load("//bazel:cross.bzl", "go_cross_binaries") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "machines_agent_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/machines_agent", @@ -14,7 +14,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "machines_agent", embed = [":machines_agent_lib"], visibility = ["//visibility:public"], diff --git a/cmd/machines_event_monitor/BUILD.bazel b/cmd/machines_event_monitor/BUILD.bazel index 986d02c..696c862 100644 --- a/cmd/machines_event_monitor/BUILD.bazel +++ b/cmd/machines_event_monitor/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "machines_event_monitor_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/machines_event_monitor", @@ -12,7 +12,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "machines_event_monitor", embed = [":machines_event_monitor_lib"], visibility = ["//visibility:public"], diff --git a/cmd/metricbus_server/BUILD.bazel b/cmd/metricbus_server/BUILD.bazel index dceea28..959b9b0 100644 --- a/cmd/metricbus_server/BUILD.bazel +++ b/cmd/metricbus_server/BUILD.bazel @@ -1,7 +1,7 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:svc.bzl", "systemd_dbus_service") -go_library( +go_multi_library( name = "metricbus_server_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/metricbus_server", @@ -13,7 +13,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "metricbus_server", embed = [":metricbus_server_lib"], visibility = ["//visibility:public"], diff --git a/cmd/mint_server/BUILD.bazel b/cmd/mint_server/BUILD.bazel index 549c500..98c3e06 100644 --- a/cmd/mint_server/BUILD.bazel +++ b/cmd/mint_server/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "mint_server_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/mint_server", @@ -16,7 +16,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "mint_server", embed = [":mint_server_lib"], visibility = ["//visibility:public"], diff --git a/cmd/mtls_exporter/BUILD.bazel b/cmd/mtls_exporter/BUILD.bazel index 1e59ec1..5b4786a 100644 --- a/cmd/mtls_exporter/BUILD.bazel +++ b/cmd/mtls_exporter/BUILD.bazel @@ -1,7 +1,7 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:svc.bzl", "systemd_service") -go_library( +go_multi_library( name = "mtls_exporter_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/mtls_exporter", @@ -13,7 +13,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "mtls_exporter", embed = [":mtls_exporter_lib"], visibility = ["//visibility:public"], diff --git a/cmd/mtls_supervisor/BUILD.bazel b/cmd/mtls_supervisor/BUILD.bazel index 4c16b5b..419b4e6 100644 --- a/cmd/mtls_supervisor/BUILD.bazel +++ b/cmd/mtls_supervisor/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "mtls_supervisor_lib", srcs = [ "main.go", @@ -18,7 +18,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "mtls_supervisor", embed = [":mtls_supervisor_lib"], visibility = ["//visibility:public"], diff --git a/cmd/mtls_verify_tool/BUILD.bazel b/cmd/mtls_verify_tool/BUILD.bazel index 5ba2f6d..e55e24c 100644 --- a/cmd/mtls_verify_tool/BUILD.bazel +++ b/cmd/mtls_verify_tool/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "mtls_verify_tool_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/mtls_verify_tool", @@ -11,7 +11,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "mtls_verify_tool", embed = [":mtls_verify_tool_lib"], visibility = ["//visibility:public"], diff --git a/cmd/prometheus_http_discovery/BUILD.bazel b/cmd/prometheus_http_discovery/BUILD.bazel index b98bc6d..395ae14 100644 --- a/cmd/prometheus_http_discovery/BUILD.bazel +++ b/cmd/prometheus_http_discovery/BUILD.bazel @@ -1,13 +1,14 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:svc.bzl", "systemd_service") -go_library( +go_multi_library( name = "prometheus_http_discovery_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/prometheus_http_discovery", visibility = ["//visibility:private"], deps = [ "//constants", + "//mint", "//mtls", "//sd", "//utils/context", @@ -16,7 +17,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "prometheus_http_discovery", embed = [":prometheus_http_discovery_lib"], visibility = ["//visibility:public"], diff --git a/cmd/sase_ws_proxy_client/BUILD.bazel b/cmd/sase_ws_proxy_client/BUILD.bazel index a97c3f8..1bd0437 100644 --- a/cmd/sase_ws_proxy_client/BUILD.bazel +++ b/cmd/sase_ws_proxy_client/BUILD.bazel @@ -1,7 +1,7 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") load("//bazel:cross.bzl", "go_cross_binaries") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "sase_ws_proxy_client_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/sase_ws_proxy_client", @@ -12,7 +12,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "sase_ws_proxy_client", embed = [":sase_ws_proxy_client_lib"], visibility = ["//visibility:public"], diff --git a/cmd/sase_ws_tcp_proxy/BUILD.bazel b/cmd/sase_ws_tcp_proxy/BUILD.bazel index 2cfd80c..978906b 100644 --- a/cmd/sase_ws_tcp_proxy/BUILD.bazel +++ b/cmd/sase_ws_tcp_proxy/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "sase_ws_tcp_proxy_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/sase_ws_tcp_proxy", @@ -15,7 +15,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "sase_ws_tcp_proxy", embed = [":sase_ws_tcp_proxy_lib"], visibility = ["//visibility:public"], diff --git a/cmd/sd_health_exporter/BUILD.bazel b/cmd/sd_health_exporter/BUILD.bazel index da61a04..6fdcdad 100644 --- a/cmd/sd_health_exporter/BUILD.bazel +++ b/cmd/sd_health_exporter/BUILD.bazel @@ -1,7 +1,7 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:svc.bzl", "systemd_service") -go_library( +go_multi_library( name = "sd_health_exporter_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/sd_health_exporter", @@ -14,7 +14,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "sd_health_exporter", embed = [":sd_health_exporter_lib"], visibility = ["//visibility:public"], diff --git a/cmd/sd_publish/BUILD.bazel b/cmd/sd_publish/BUILD.bazel index 4ac44c6..31cbb73 100644 --- a/cmd/sd_publish/BUILD.bazel +++ b/cmd/sd_publish/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "sd_publish_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/sd_publish", @@ -13,7 +13,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "sd_publish", embed = [":sd_publish_lib"], visibility = ["//visibility:public"], diff --git a/cmd/sd_register/BUILD.bazel b/cmd/sd_register/BUILD.bazel index 1ac2f6b..16f7c81 100644 --- a/cmd/sd_register/BUILD.bazel +++ b/cmd/sd_register/BUILD.bazel @@ -1,7 +1,7 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") load("//bazel:svc.bzl", "systemd_service") -go_library( +go_multi_library( name = "sd_register_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/sd_register", @@ -15,7 +15,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "sd_register", embed = [":sd_register_lib"], visibility = ["//visibility:public"], diff --git a/cmd/sd_watcher/BUILD.bazel b/cmd/sd_watcher/BUILD.bazel index de324cd..5bbf167 100644 --- a/cmd/sd_watcher/BUILD.bazel +++ b/cmd/sd_watcher/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "sd_watcher_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/cmd/sd_watcher", @@ -12,7 +12,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "sd_watcher", embed = [":sd_watcher_lib"], visibility = ["//visibility:public"], diff --git a/config_watcher/BUILD.bazel b/config_watcher/BUILD.bazel index 42da7fa..cc81654 100644 --- a/config_watcher/BUILD.bazel +++ b/config_watcher/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "config_watcher", srcs = [ "backend_ephs.go", diff --git a/constants/BUILD.bazel b/constants/BUILD.bazel index e1c0ac0..b9a36a7 100644 --- a/constants/BUILD.bazel +++ b/constants/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") # Ignore this package in gazelle so constants_in.go is picked up by IDEs but not builds. # gazelle:exclude constants_fake.go @@ -13,7 +13,7 @@ genrule( ], ) -go_library( +go_multi_library( name = "constants", srcs = ["constants.go"], importpath = "go.fuhry.dev/runtime/constants", diff --git a/constants/generate/BUILD.bazel b/constants/generate/BUILD.bazel index ef577c4..ebec9af 100644 --- a/constants/generate/BUILD.bazel +++ b/constants/generate/BUILD.bazel @@ -1,13 +1,13 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "generate_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/constants/generate", visibility = ["//visibility:private"], ) -go_binary( +go_multi_binary( name = "generate", embed = [":generate_lib"], visibility = ["//visibility:public"], diff --git a/echo/BUILD.bazel b/echo/BUILD.bazel index 2d34dd0..8803580 100644 --- a/echo/BUILD.bazel +++ b/echo/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "echo", srcs = ["server.go"], importpath = "go.fuhry.dev/runtime/echo", diff --git a/ephs/BUILD.bazel b/ephs/BUILD.bazel index e4f36dd..8222d85 100644 --- a/ephs/BUILD.bazel +++ b/ephs/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "ephs", srcs = [ "client.go", diff --git a/ephs/ephsll/BUILD.bazel b/ephs/ephsll/BUILD.bazel index 3794d7e..14cc990 100644 --- a/ephs/ephsll/BUILD.bazel +++ b/ephs/ephsll/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "ephsll", srcs = [ "client.go", diff --git a/ephs/servicer/BUILD.bazel b/ephs/servicer/BUILD.bazel index 3b7481a..aa1329d 100644 --- a/ephs/servicer/BUILD.bazel +++ b/ephs/servicer/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "servicer", srcs = [ "acl.go", diff --git a/grpc/BUILD.bazel b/grpc/BUILD.bazel index 736056e..f2181c1 100644 --- a/grpc/BUILD.bazel +++ b/grpc/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "grpc", srcs = ["imports.go"], importpath = "go.fuhry.dev/runtime/grpc", diff --git a/grpc/internal/acl/BUILD.bazel b/grpc/internal/acl/BUILD.bazel index f190af5..f05ec69 100644 --- a/grpc/internal/acl/BUILD.bazel +++ b/grpc/internal/acl/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "acl", srcs = ["acl_yaml.go"], importpath = "go.fuhry.dev/runtime/grpc/internal/acl", diff --git a/grpc/internal/client/BUILD.bazel b/grpc/internal/client/BUILD.bazel index 40a50e8..5efc747 100644 --- a/grpc/internal/client/BUILD.bazel +++ b/grpc/internal/client/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") package( default_visibility = [ @@ -7,7 +7,7 @@ package( ], ) -go_library( +go_multi_library( name = "client", srcs = [ "client.go", diff --git a/grpc/internal/common/BUILD.bazel b/grpc/internal/common/BUILD.bazel index 024c911..c1b8f75 100644 --- a/grpc/internal/common/BUILD.bazel +++ b/grpc/internal/common/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") package( default_visibility = [ @@ -7,7 +7,7 @@ package( ], ) -go_library( +go_multi_library( name = "common", srcs = [ "conn_base.go", diff --git a/grpc/internal/server/BUILD.bazel b/grpc/internal/server/BUILD.bazel index ff78835..6c30886 100644 --- a/grpc/internal/server/BUILD.bazel +++ b/grpc/internal/server/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "server", srcs = [ "context.go", diff --git a/http/BUILD.bazel b/http/BUILD.bazel index b489a99..91f2ea7 100644 --- a/http/BUILD.bazel +++ b/http/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "http", srcs = [ "http.go", diff --git a/ldap/BUILD.bazel b/ldap/BUILD.bazel index 6942854..8b46183 100644 --- a/ldap/BUILD.bazel +++ b/ldap/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "ldap", srcs = [ "scraper.go", diff --git a/machines/BUILD.bazel b/machines/BUILD.bazel index b48f1d0..0bc4083 100644 --- a/machines/BUILD.bazel +++ b/machines/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "machines", srcs = [ "agent.go", diff --git a/machines/coredns_plugin/BUILD.bazel b/machines/coredns_plugin/BUILD.bazel index 28605ad..eed9003 100644 --- a/machines/coredns_plugin/BUILD.bazel +++ b/machines/coredns_plugin/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "coredns_plugin", srcs = [ "registry.go", diff --git a/metrics/metricbus/BUILD.bazel b/metrics/metricbus/BUILD.bazel index 6dd6ffc..54cbb3a 100644 --- a/metrics/metricbus/BUILD.bazel +++ b/metrics/metricbus/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "metricbus", srcs = ["constants.go"], importpath = "go.fuhry.dev/runtime/metrics/metricbus", diff --git a/metrics/metricbus/mbclient/BUILD.bazel b/metrics/metricbus/mbclient/BUILD.bazel index 7cbdcec..bf84393 100644 --- a/metrics/metricbus/mbclient/BUILD.bazel +++ b/metrics/metricbus/mbclient/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "mbclient", srcs = [ "common.go", diff --git a/metrics/metricbus/mbclient/example/BUILD.bazel b/metrics/metricbus/mbclient/example/BUILD.bazel index b6ec816..f9b23f9 100644 --- a/metrics/metricbus/mbclient/example/BUILD.bazel +++ b/metrics/metricbus/mbclient/example/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "example_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/metrics/metricbus/mbclient/example", @@ -11,7 +11,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "example", embed = [":example_lib"], visibility = ["//visibility:public"], diff --git a/metrics/metricbus/mbserver/BUILD.bazel b/metrics/metricbus/mbserver/BUILD.bazel index 6e32ee3..ef04a70 100644 --- a/metrics/metricbus/mbserver/BUILD.bazel +++ b/metrics/metricbus/mbserver/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "mbserver", srcs = [ "dbus_interface.go", diff --git a/metrics/mtls/BUILD.bazel b/metrics/mtls/BUILD.bazel index 066b46b..c4adcaa 100644 --- a/metrics/mtls/BUILD.bazel +++ b/metrics/mtls/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "mtls", srcs = ["stats.go"], importpath = "go.fuhry.dev/runtime/metrics/mtls", diff --git a/mint/BUILD.bazel b/mint/BUILD.bazel index 84460a4..77af573 100644 --- a/mint/BUILD.bazel +++ b/mint/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "mint", srcs = [ "client.go", diff --git a/mint/remote_signer/BUILD.bazel b/mint/remote_signer/BUILD.bazel index 53bfb2d..4ad1cd2 100644 --- a/mint/remote_signer/BUILD.bazel +++ b/mint/remote_signer/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "remote_signer", srcs = ["remote_signer.go"], importpath = "go.fuhry.dev/runtime/mint/remote_signer", diff --git a/mint/servicer/BUILD.bazel b/mint/servicer/BUILD.bazel index 9090ca0..bb3880f 100644 --- a/mint/servicer/BUILD.bazel +++ b/mint/servicer/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "servicer", srcs = [ "acl.go", diff --git a/mtls/BUILD.bazel b/mtls/BUILD.bazel index 9fa9e32..e570fe9 100644 --- a/mtls/BUILD.bazel +++ b/mtls/BUILD.bazel @@ -1,7 +1,43 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( - name = "mtls", +# No-CGO variant: excludes all CGO-gated source files. +# Used by cross-compiled binaries where CGO is not supported. +go_multi_library( + name = "mtls_no_cgo", + srcs = [ + "config.go", + "identity.go", + "lazy_identity.go", + "provider_anonymous.go", + "provider_file.go", + "provider_interface.go", + "provider_shared.go", + "verify_names.go", + "verify_roots.go", + ], + embedsrcs = [ + "configs/prod.yaml", + "configs/user.yaml", + ], + importpath = "go.fuhry.dev/runtime/mtls", + visibility = ["//visibility:public"], + deps = [ + "//constants", + "//mtls/certutil", + "//mtls/fsnotify", + "//utils/fsutil", + "//utils/hashset", + "//utils/hostname", + "//utils/log", + "//utils/subst", + "@in_gopkg_yaml_v3//:yaml_v3", + ], +) + +# CGO variant: includes all source files including platform-specific ones. +# Used by native linux_amd64 builds (with pkcs11) and darwin builds (with keychain). +go_multi_library( + name = "mtls_cgo", srcs = [ "config.go", "identity.go", @@ -16,10 +52,7 @@ go_library( "verify_names.go", "verify_roots.go", ], - cgo = select({ - "@rules_go//go/platform:linux_amd64": True, - "//conditions:default": False, - }), + cgo = True, embedsrcs = [ "configs/prod.yaml", "configs/user.yaml", @@ -36,16 +69,18 @@ go_library( "//utils/log", "//utils/subst", "@com_github_thalesignite_crypto11//:crypto11", + "@com_github_keybase_go_keychain//:go-keychain", "@in_gopkg_yaml_v3//:yaml_v3", - ] + select({ - "@rules_go//go/platform:darwin": [ - "//utils/stringmatch", - "@com_github_keybase_go_keychain//:go-keychain", - ], - "@rules_go//go/platform:ios": [ - "//utils/stringmatch", - "@com_github_keybase_go_keychain//:go-keychain", - ], - "//conditions:default": [], + ], +) + +alias( + name = "mtls", + actual = select({ + "@rules_go//go/platform:linux_amd64": ":mtls_cgo", + "@rules_go//go/platform:darwin_amd64": ":mtls_cgo", + "@rules_go//go/platform:darwin_arm64": ":mtls_cgo", + "//conditions:default": ":mtls_no_cgo", }), + visibility = ["//visibility:public"], ) diff --git a/mtls/certutil/BUILD.bazel b/mtls/certutil/BUILD.bazel index ad82664..9456348 100644 --- a/mtls/certutil/BUILD.bazel +++ b/mtls/certutil/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "certutil", srcs = ["certutil.go"], importpath = "go.fuhry.dev/runtime/mtls/certutil", diff --git a/mtls/fsnotify/BUILD.bazel b/mtls/fsnotify/BUILD.bazel index 76a690a..8ad017a 100644 --- a/mtls/fsnotify/BUILD.bazel +++ b/mtls/fsnotify/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "fsnotify", srcs = [ "fsnotify.go", diff --git a/mtls/pkcs11.go b/mtls/pkcs11.go index fb5835d..cda2923 100644 --- a/mtls/pkcs11.go +++ b/mtls/pkcs11.go @@ -1,4 +1,4 @@ -//go:build cgo +//go:build pkcs11 package mtls @@ -10,6 +10,7 @@ import ( "sync" "github.com/ThalesIgnite/crypto11" + "go.fuhry.dev/runtime/constants" "go.fuhry.dev/runtime/utils/log" ) @@ -84,13 +85,13 @@ func (p *p11) GetCertificate() (*tls.Certificate, error) { pkcs11Logger.V(1).Infof("trying to find device trust certificate with object label %s", deviceTrustObjectLabel) cert, err := p.cHandle.FindCertificate(nil, []byte(deviceTrustObjectLabel), nil) if err != nil { - pkcs11Logger.V(1).Errorf("find devicetrust certificate filed: %v", err) + pkcs11Logger.V(1).Errorf("find devicetrust certificate failed: %v", err) return nil, err } privateKey, err := p.GetPrivateKey() if err != nil { - pkcs11Logger.V(1).Errorf("find devicetrust private key filed: %v", err) + pkcs11Logger.V(1).Errorf("find devicetrust private key failed: %v", err) return nil, err } diff --git a/mtls/provider_keychain_macos.go b/mtls/provider_keychain_macos.go index cbce997..b794123 100644 --- a/mtls/provider_keychain_macos.go +++ b/mtls/provider_keychain_macos.go @@ -19,12 +19,13 @@ import ( "time" "github.com/keybase/go-keychain" + "gopkg.in/yaml.v3" + "go.fuhry.dev/runtime/constants" "go.fuhry.dev/runtime/mtls/certutil" "go.fuhry.dev/runtime/utils/hashset" "go.fuhry.dev/runtime/utils/log" "go.fuhry.dev/runtime/utils/stringmatch" - "gopkg.in/yaml.v3" ) type macosKeychainCertificate struct { @@ -234,7 +235,6 @@ func findCertificateAndPrivateKeyMatchingKeyPairInKeychain(leaves []*kcCertResul return nil, fmt.Errorf("failed to identify any private key/certificate pairs") }) - if err != nil { return nil, nil, err } @@ -448,7 +448,7 @@ func (kcr *macosKeychainRoots) IntermediateCertificates() ([]*x509.Certificate, return getMtlsIntermediatesFromMacKeychain() } -func (f *macosKeychainProviderFactory) New(_ *yaml.Node) (identityLoaderFunc, error) { +func (f *macosKeychainProviderFactory) New(_ *yaml.Node) (IdentityLoaderFunc, error) { return NewCertificateFromMacKeychain, nil } diff --git a/mtls/provider_tpm2_pkcs11.go b/mtls/provider_tpm2_pkcs11.go index c755aef..4b4b1aa 100644 --- a/mtls/provider_tpm2_pkcs11.go +++ b/mtls/provider_tpm2_pkcs11.go @@ -1,4 +1,4 @@ -//go:build cgo +//go:build pkcs11 package mtls @@ -10,9 +10,10 @@ import ( "fmt" "path" + "gopkg.in/yaml.v3" + "go.fuhry.dev/runtime/constants" "go.fuhry.dev/runtime/mtls/certutil" - "gopkg.in/yaml.v3" ) type tpmProviderFactory struct{} @@ -132,10 +133,12 @@ func (f *tpmProviderFactory) New(_ *yaml.Node) (IdentityLoaderFunc, error) { } func init() { - RegisterIdentityDriver("tpm2-pkcs11", func(cls PrincipalClass, serviceName string) (CertificateProvider, error) { + RegisterIdentityDriver("tpm2_pkcs11", func(cls PrincipalClass, serviceName string) (CertificateProvider, error) { if cls != ServicePrincipal || serviceName != constants.DeviceTrustPrincipal { return nil, ErrUnsupportedClass } return NewTPMBackedCertificate() }) + + RegisterProviderFactory("tpm2_pkcs11", &tpmProviderFactory{}) } diff --git a/net/BUILD.bazel b/net/BUILD.bazel index b2ae290..81f90f8 100644 --- a/net/BUILD.bazel +++ b/net/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "net", srcs = ["happy_eyeballs.go"], importpath = "go.fuhry.dev/runtime/net", diff --git a/net/dns/BUILD.bazel b/net/dns/BUILD.bazel index 055b39c..5807f56 100644 --- a/net/dns/BUILD.bazel +++ b/net/dns/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "dns", srcs = [ "dns_cache.go", diff --git a/pkg/nfpmgen/BUILD.bazel b/pkg/nfpmgen/BUILD.bazel index 6260654..7532737 100644 --- a/pkg/nfpmgen/BUILD.bazel +++ b/pkg/nfpmgen/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "nfpmgen_lib", srcs = [ "config_generator.go", @@ -17,7 +17,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "nfpmgen", embed = [":nfpmgen_lib"], visibility = ["//visibility:public"], diff --git a/proto/service/attest/BUILD.bazel b/proto/service/attest/BUILD.bazel index f9436a6..5b50640 100644 --- a/proto/service/attest/BUILD.bazel +++ b/proto/service/attest/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") filegroup( name = "go_default_library_protos", @@ -6,7 +6,7 @@ filegroup( visibility = ["//visibility:public"], ) -go_library( +go_multi_library( name = "attest", srcs = [ "attest_server.pb.go", diff --git a/proto/service/bryston_ctl/BUILD.bazel b/proto/service/bryston_ctl/BUILD.bazel index bb46bad..fb80d05 100644 --- a/proto/service/bryston_ctl/BUILD.bazel +++ b/proto/service/bryston_ctl/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") filegroup( name = "go_default_library_protos", @@ -6,7 +6,7 @@ filegroup( visibility = ["//visibility:public"], ) -go_library( +go_multi_library( name = "bryston_ctl", srcs = [ "bryston_ctl.pb.go", diff --git a/proto/service/echo/BUILD.bazel b/proto/service/echo/BUILD.bazel index 018ccc2..afa070e 100644 --- a/proto/service/echo/BUILD.bazel +++ b/proto/service/echo/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") filegroup( name = "go_default_library_protos", @@ -6,7 +6,7 @@ filegroup( visibility = ["//visibility:public"], ) -go_library( +go_multi_library( name = "echo", srcs = [ "echo_server.pb.go", diff --git a/proto/service/ephs/BUILD.bazel b/proto/service/ephs/BUILD.bazel index 4488ec7..6d06eea 100644 --- a/proto/service/ephs/BUILD.bazel +++ b/proto/service/ephs/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") filegroup( name = "go_default_library_protos", @@ -9,7 +9,7 @@ filegroup( visibility = ["//visibility:public"], ) -go_library( +go_multi_library( name = "ephs", srcs = [ "ephs_service.pb.go", diff --git a/proto/service/mint/BUILD.bazel b/proto/service/mint/BUILD.bazel index 2d13bb7..a4f208e 100644 --- a/proto/service/mint/BUILD.bazel +++ b/proto/service/mint/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") # gazelle:proto legacy @@ -11,7 +11,7 @@ filegroup( visibility = ["//visibility:public"], ) -go_library( +go_multi_library( name = "mint", srcs = [ "mint_service.pb.go", diff --git a/rand/BUILD.bazel b/rand/BUILD.bazel index 3ebfe66..b823773 100644 --- a/rand/BUILD.bazel +++ b/rand/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "rand", srcs = ["range.go"], importpath = "go.fuhry.dev/runtime/rand", diff --git a/sase/BUILD.bazel b/sase/BUILD.bazel index 6aef301..3749298 100644 --- a/sase/BUILD.bazel +++ b/sase/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "sase", srcs = [ "acl.go", diff --git a/sd/BUILD.bazel b/sd/BUILD.bazel index 9c2fa50..3242353 100644 --- a/sd/BUILD.bazel +++ b/sd/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "sd", srcs = [ "etcd_factory.go", diff --git a/thirdparty/registry/BUILD.bazel b/thirdparty/registry/BUILD.bazel index 44f7322..f658d55 100644 --- a/thirdparty/registry/BUILD.bazel +++ b/thirdparty/registry/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_binary", "go_library") +load("//bazel:go.bzl", "go_multi_binary", "go_multi_library") -go_library( +go_multi_library( name = "registry_lib", srcs = ["main.go"], importpath = "go.fuhry.dev/runtime/thirdparty/registry", @@ -24,7 +24,7 @@ go_library( ], ) -go_binary( +go_multi_binary( name = "registry", embed = [":registry_lib"], visibility = ["//visibility:public"], diff --git a/utils/BUILD.bazel b/utils/BUILD.bazel index 5bff527..cb62fe9 100644 --- a/utils/BUILD.bazel +++ b/utils/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "utils", srcs = ["reverse.go"], importpath = "go.fuhry.dev/runtime/utils", diff --git a/utils/ansi/BUILD.bazel b/utils/ansi/BUILD.bazel index 0e828b7..28dcd55 100644 --- a/utils/ansi/BUILD.bazel +++ b/utils/ansi/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "ansi", srcs = ["color.go"], importpath = "go.fuhry.dev/runtime/utils/ansi", diff --git a/utils/checkers/BUILD.bazel b/utils/checkers/BUILD.bazel index 6a05106..099724c 100644 --- a/utils/checkers/BUILD.bazel +++ b/utils/checkers/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "checkers", srcs = ["contains_key.go"], importpath = "go.fuhry.dev/runtime/utils/checkers", diff --git a/utils/context/BUILD.bazel b/utils/context/BUILD.bazel index d91ba7c..474232b 100644 --- a/utils/context/BUILD.bazel +++ b/utils/context/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "context", srcs = [ "imports.go", diff --git a/utils/daemon/BUILD.bazel b/utils/daemon/BUILD.bazel index 0f586ff..cad7856 100644 --- a/utils/daemon/BUILD.bazel +++ b/utils/daemon/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "daemon", srcs = [ "constants_linux.go", diff --git a/utils/debounce/BUILD.bazel b/utils/debounce/BUILD.bazel index 491997a..a11f877 100644 --- a/utils/debounce/BUILD.bazel +++ b/utils/debounce/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "debounce", srcs = ["debounce.go"], importpath = "go.fuhry.dev/runtime/utils/debounce", diff --git a/utils/fsutil/BUILD.bazel b/utils/fsutil/BUILD.bazel index 006933b..ff2882c 100644 --- a/utils/fsutil/BUILD.bazel +++ b/utils/fsutil/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "fsutil", srcs = ["file.go"], importpath = "go.fuhry.dev/runtime/utils/fsutil", diff --git a/utils/generics/BUILD.bazel b/utils/generics/BUILD.bazel index 42b1a52..7dda0a6 100644 --- a/utils/generics/BUILD.bazel +++ b/utils/generics/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "generics", srcs = ["math.go"], importpath = "go.fuhry.dev/runtime/utils/generics", diff --git a/utils/hashset/BUILD.bazel b/utils/hashset/BUILD.bazel index 5ca84f5..9e0417d 100644 --- a/utils/hashset/BUILD.bazel +++ b/utils/hashset/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "hashset", srcs = ["hashset.go"], importpath = "go.fuhry.dev/runtime/utils/hashset", diff --git a/utils/hostname/BUILD.bazel b/utils/hostname/BUILD.bazel index 36f467d..1dc4f99 100644 --- a/utils/hostname/BUILD.bazel +++ b/utils/hostname/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "hostname", srcs = [ "hostname.go", diff --git a/utils/log/BUILD.bazel b/utils/log/BUILD.bazel index a0526cf..54c0874 100644 --- a/utils/log/BUILD.bazel +++ b/utils/log/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "log", srcs = [ "http.go", diff --git a/utils/option/BUILD.bazel b/utils/option/BUILD.bazel index 8f8fe87..ff60ddd 100644 --- a/utils/option/BUILD.bazel +++ b/utils/option/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "option", srcs = ["option.go"], importpath = "go.fuhry.dev/runtime/utils/option", diff --git a/utils/rollout/BUILD.bazel b/utils/rollout/BUILD.bazel index 157952b..4e07450 100644 --- a/utils/rollout/BUILD.bazel +++ b/utils/rollout/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "rollout", srcs = ["rollout.go"], importpath = "go.fuhry.dev/runtime/utils/rollout", diff --git a/utils/slices2/BUILD.bazel b/utils/slices2/BUILD.bazel index 0fb9a05..67047f2 100644 --- a/utils/slices2/BUILD.bazel +++ b/utils/slices2/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "slices2", srcs = ["map.go"], importpath = "go.fuhry.dev/runtime/utils/slices2", diff --git a/utils/stringmatch/BUILD.bazel b/utils/stringmatch/BUILD.bazel index 51fc68c..f96323b 100644 --- a/utils/stringmatch/BUILD.bazel +++ b/utils/stringmatch/BUILD.bazel @@ -1,6 +1,7 @@ -load("@rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_go//go:def.bzl", "go_test") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "stringmatch", srcs = [ "matchers.go", diff --git a/utils/strings2/BUILD.bazel b/utils/strings2/BUILD.bazel index 89b9128..104c89f 100644 --- a/utils/strings2/BUILD.bazel +++ b/utils/strings2/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "strings2", srcs = ["strings2.go"], importpath = "go.fuhry.dev/runtime/utils/strings2", diff --git a/utils/subst/BUILD.bazel b/utils/subst/BUILD.bazel index f795b73..4967ad4 100644 --- a/utils/subst/BUILD.bazel +++ b/utils/subst/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_go//go:def.bzl", "go_library") +load("//bazel:go.bzl", "go_multi_library") -go_library( +go_multi_library( name = "subst", srcs = ["subst.go"], importpath = "go.fuhry.dev/runtime/utils/subst", -- 2.52.0