Skip to content

Commit

Permalink
bazel: provide k8s / envtest toolchains
Browse files Browse the repository at this point in the history
  • Loading branch information
malt3 committed Aug 17, 2023
1 parent 1846221 commit 3052c0f
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
5 changes: 5 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,8 @@ node_maintainance_operator_deps()
load("//bazel/toolchains:ci_deps.bzl", "ci_deps")

ci_deps()

# k8s deps
load("//bazel/toolchains:k8s.bzl", "k8s_deps")

k8s_deps()
52 changes: 52 additions & 0 deletions bazel/toolchains/k8s.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""versioned kubernetes release artifacts (dl.k8s.io)"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def k8s_deps():
envtest_deps()

def envtest_deps():
http_archive(
name = "kubebuilder_tools_darwin_amd64",
strip_prefix = "kubebuilder/bin",
type = "tar.gz",
urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/e1913674bacaa70c067e15649237e1f67d891ba53f367c0a50786b4a274ee047",
"https://kubebuilder-tools.storage.googleapis.com/kubebuilder-tools-1.27.1-darwin-amd64.tar.gz",
],
sha256 = "e1913674bacaa70c067e15649237e1f67d891ba53f367c0a50786b4a274ee047",
build_file_content = """exports_files(["etcd", "kubectl", "kube-apiserver"], visibility = ["//visibility:public"])""",
)
http_archive(
name = "kubebuilder_tools_darwin_arm64",
strip_prefix = "kubebuilder/bin",
type = "tar.gz",
urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/0422632a2bbb0d4d14d7d8b0f05497a4d041c11d770a07b7a55c44bcc5e8ce66",
"https://kubebuilder-tools.storage.googleapis.com/kubebuilder-tools-1.27.1-darwin-arm64.tar.gz",
],
sha256 = "0422632a2bbb0d4d14d7d8b0f05497a4d041c11d770a07b7a55c44bcc5e8ce66",
build_file_content = """exports_files(["etcd", "kubectl", "kube-apiserver"], visibility = ["//visibility:public"])""",
)
http_archive(
name = "kubebuilder_tools_linux_amd64",
strip_prefix = "kubebuilder/bin",
type = "tar.gz",
urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/f9699df7b021f71a1ab55329b36b48a798e6ae3a44d2132255fc7e46c6790d4d",
"https://kubebuilder-tools.storage.googleapis.com/kubebuilder-tools-1.27.1-linux-amd64.tar.gz",
],
sha256 = "f9699df7b021f71a1ab55329b36b48a798e6ae3a44d2132255fc7e46c6790d4d",
build_file_content = """exports_files(["etcd", "kubectl", "kube-apiserver"], visibility = ["//visibility:public"])""",
)
http_archive(
name = "kubebuilder_tools_linux_arm64",
strip_prefix = "kubebuilder/bin",
type = "tar.gz",
urls = [
"https://cdn.confidential.cloud/constellation/cas/sha256/9d2803e8ca85c465b33c12b06d0b2eba3ddb64b53a468628f741e50b462c46ad",
"https://kubebuilder-tools.storage.googleapis.com/kubebuilder-tools-1.27.1-linux-arm64.tar.gz",
],
sha256 = "9d2803e8ca85c465b33c12b06d0b2eba3ddb64b53a468628f741e50b462c46ad",
build_file_content = """exports_files(["etcd", "kubectl", "kube-apiserver"], visibility = ["//visibility:public"])""",
)
47 changes: 47 additions & 0 deletions operators/envtest/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")

# tools (aka KUBEBUILDER_ASSETS) are a collection of binaries that are used by
# kubebuilder for envtests.
copy_to_directory(
name = "tools",
srcs = [
":etcd",
":kube-apiserver",
":kubectl",
],
include_external_repositories = ["kubebuilder_tools_*"],
visibility = ["//visibility:public"],
)

alias(
name = "etcd",
actual = select({
"@io_bazel_rules_go//go/platform:darwin_amd64": "@kubebuilder_tools_darwin_amd64//:etcd",
"@io_bazel_rules_go//go/platform:darwin_arm64": "@kubebuilder_tools_darwin_arm64//:etcd",
"@io_bazel_rules_go//go/platform:linux_amd64": "@kubebuilder_tools_linux_amd64//:etcd",
"@io_bazel_rules_go//go/platform:linux_arm64": "@kubebuilder_tools_linux_arm64//:etcd",
}),
visibility = ["//visibility:public"],
)

alias(
name = "kube-apiserver",
actual = select({
"@io_bazel_rules_go//go/platform:darwin_amd64": "@kubebuilder_tools_darwin_amd64//:kube-apiserver",
"@io_bazel_rules_go//go/platform:darwin_arm64": "@kubebuilder_tools_darwin_arm64//:kube-apiserver",
"@io_bazel_rules_go//go/platform:linux_amd64": "@kubebuilder_tools_linux_amd64//:kube-apiserver",
"@io_bazel_rules_go//go/platform:linux_arm64": "@kubebuilder_tools_linux_arm64//:kube-apiserver",
}),
visibility = ["//visibility:public"],
)

alias(
name = "kubectl",
actual = select({
"@io_bazel_rules_go//go/platform:darwin_amd64": "@kubebuilder_tools_darwin_amd64//:kubectl",
"@io_bazel_rules_go//go/platform:darwin_arm64": "@kubebuilder_tools_darwin_arm64//:kubectl",
"@io_bazel_rules_go//go/platform:linux_amd64": "@kubebuilder_tools_linux_amd64//:kubectl",
"@io_bazel_rules_go//go/platform:linux_arm64": "@kubebuilder_tools_linux_arm64//:kubectl",
}),
visibility = ["//visibility:public"],
)

0 comments on commit 3052c0f

Please sign in to comment.