-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
218 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,3 @@ | ||
package(default_visibility = ["//visibility:private"]) | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load(":helm_toolchain.bzl", "helm_toolchain") | ||
|
||
toolchain_type(name = "toolchain_type", visibility = ["//visibility:public"]) | ||
|
||
# Helm toolchain that points to helm binary version 2.17.0 | ||
helm_toolchain( | ||
name = "helm_v2.17.0_darwin", | ||
tool = "@helm_v2.17.0_darwin//:helm", | ||
helm_version = "2.17.0", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
helm_toolchain( | ||
name = "helm_v2.17.0_linux", | ||
tool = "@helm_v2.17.0_linux//:helm", | ||
helm_version = "2.17.0", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
toolchain( | ||
name = "helm_v2.17.0_linux_toolchain", | ||
exec_compatible_with = [ | ||
"@platforms//os:linux", | ||
"@platforms//cpu:x86_64", | ||
], | ||
target_compatible_with = [ | ||
"@platforms//os:linux", | ||
"@platforms//cpu:x86_64", | ||
], | ||
toolchain = ":helm_v2.17.0_linux", | ||
toolchain_type = ":toolchain_type", | ||
) | ||
|
||
toolchain( | ||
name = "helm_v2.17.0_osx_toolchain", | ||
target_compatible_with = [ | ||
"@bazel_tools//platforms:osx", | ||
], | ||
toolchain = ":helm_v2.17.0_darwin", | ||
toolchain_type = ":toolchain_type", | ||
) | ||
toolchain_type(name = "toolchain_type") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package(default_visibility = ["//visibility:private"]) | ||
|
||
load("@com_github_masmovil_bazel_rules//toolchains/helm:toolchain.bzl", "helm_toolchain") | ||
|
||
helm_toolchain( | ||
name = "helm_linux", | ||
tool = "@helm_linux//:helm", | ||
version = "{VERSION}", | ||
xdg_data_home = "%{HOME}/Library", | ||
xdg_config_home = "%{HOME}/Library/Preferences", | ||
xdg_cache_home = "%{HOME}/Library/Caches", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
helm_toolchain( | ||
name = "helm_darwin", | ||
tool = "@helm_darwin//:helm", | ||
version = "{VERSION}", | ||
xdg_data_home = "%{HOME}/Library", | ||
xdg_config_home = "%{HOME}/Library/Preferences", | ||
xdg_cache_home = "%{HOME}/Library/Caches", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
helm_toolchain( | ||
name = "helm_darwin_arm64", | ||
tool = "@helm_darwin//:helm", | ||
version = "{VERSION}", | ||
xdg_data_home = "%{HOME}/Library", | ||
xdg_config_home = "%{HOME}/Library/Preferences", | ||
xdg_cache_home = "%{HOME}/Library/Caches", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
helm_toolchain( | ||
name = "helm_windows", | ||
tool = "@helm_windows//:helm", | ||
version = "{VERSION}", | ||
xdg_data_home = "%{HOME}/Library", | ||
xdg_config_home = "%{HOME}/Library/Preferences", | ||
xdg_cache_home = "%{HOME}/Library/Caches", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
toolchain( | ||
name = "helm_linux_toolchain", | ||
exec_compatible_with = [ | ||
"@platforms//os:linux", | ||
"@platforms//cpu:x86_64", | ||
], | ||
toolchain = ":helm_linux", | ||
toolchain_type = "@com_github_masmovil_bazel_rules//toolchains/helm:toolchain_type", | ||
) | ||
|
||
toolchain( | ||
name = "helm_osx_toolchain", | ||
exec_compatible_with = [ | ||
"@bazel_tools//platforms:osx", | ||
"@platforms//cpu:x86_64", | ||
], | ||
toolchain = ":helm_darwin", | ||
toolchain_type = "@com_github_masmovil_bazel_rules//toolchains/helm:toolchain_type", | ||
) | ||
|
||
toolchain( | ||
name = "helm_osx_arm64_toolchain", | ||
exec_compatible_with = [ | ||
"@bazel_tools//platforms:osx", | ||
"@platforms//cpu:arm64", | ||
], | ||
toolchain = ":helm_darwin_arm64", | ||
toolchain_type = "@com_github_masmovil_bazel_rules//toolchains/helm:toolchain_type", | ||
) | ||
|
||
toolchain( | ||
name = "helm_windows_toolchain", | ||
exec_compatible_with = [ | ||
"@platforms//os:windows", | ||
"@platforms//cpu:x86_64", | ||
], | ||
toolchain = ":helm_windows", | ||
toolchain_type = "@com_github_masmovil_bazel_rules//toolchains/helm:toolchain_type", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""def.bzl contains public definitions for helm_rules. | ||
These definitions may be used by Bazel projects for building helm packages. | ||
These definitions should be loaded from here, not any internal directory. | ||
Internal definitions may change without notice. | ||
""" | ||
|
||
load( | ||
"@com_github_masmovil_bazel_rules//toolchains/helm:repositories.bzl", | ||
_helm_configure = "helm_configure", | ||
) | ||
|
||
|
||
helm_configure = _helm_configure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
filegroup( | ||
name = "helm", | ||
srcs = glob([ | ||
"**/helm", | ||
]), | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") | ||
|
||
def _helm_toolchain_configure_impl(repository_ctx): | ||
environ = repository_ctx.os.environ | ||
helm_version = repository_ctx.attr.helm_version | ||
|
||
repository_ctx.template( | ||
"BUILD.bazel", | ||
Label("@com_github_masmovil_bazel_rules//toolchains/helm:BUILD.tpl"), | ||
{ | ||
"%{HOME}": "%s" % environ["HOME"], | ||
"%{VERSION}": helm_version, | ||
}, | ||
False, | ||
) | ||
|
||
helm_toolchain_configure = repository_rule( | ||
implementation = _helm_toolchain_configure_impl, | ||
attrs = { | ||
"helm_version": attr.string( | ||
mandatory = True, | ||
doc = "Helm version to configure" | ||
) | ||
}, | ||
environ = [ | ||
"HOME" | ||
] | ||
) | ||
|
||
def helm_configure(version, linux_amd64_sha, darwin_amd64_sha, darwin_arm64_sha, windows_amd64_sha): | ||
helm_toolchain_configure( | ||
name = "mm_helm_toolchain_configure", | ||
helm_version = version | ||
) | ||
|
||
http_archive( | ||
name = "helm_linux", | ||
sha256 = linux_amd64_sha, | ||
urls = ["https://get.helm.sh/helm-v{version}-linux-amd64.tar.gz".format(version = version)], | ||
build_file = "@com_github_com_github_masmovil_bazel_rules//:helm.BUILD", | ||
) | ||
|
||
http_archive( | ||
name = "helm_darwin", | ||
sha256 = darwin_amd64_sha, | ||
urls = ["https://get.helm.sh/helm-v{version}-darwin-amd64.tar.gz".format(version = version)], | ||
build_file = "@com_github_com_github_masmovil_bazel_rules//:helm.BUILD", | ||
) | ||
|
||
|
||
http_archive( | ||
name = "helm_darwin_arm64", | ||
sha256 = darwin_arm64_sha, | ||
urls = ["https://get.helm.sh/helm-v{version}-darwin-arm64.tar.gz".format(version = version)], | ||
build_file = "@com_github_com_github_masmovil_bazel_rules//:helm.BUILD", | ||
) | ||
|
||
|
||
|
||
http_archive( | ||
name = "helm_windows", | ||
sha256 = windows_amd64_sha, | ||
urls = ["https://get.helm.sh/helm-v{version}-windows-amd64.tar.gz".format(version = version)], | ||
build_file = "@com_github_com_github_masmovil_bazel_rules//:helm.BUILD", | ||
) | ||
|
||
native.register_toolchains( | ||
"@mm_helm_toolchain_configure//:helm_linux_toolchain", | ||
"@mm_helm_toolchain_configure//:helm_osx_toolchain", | ||
"@mm_helm_toolchain_configure//:helm_osx_arm64_toolchain", | ||
"@mm_helm_toolchain_configure//:helm_windows_toolchain" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
HelmInfo = provider( | ||
doc = "Helm info", | ||
fields = { | ||
"version": "Helm specific version", | ||
"binary": "Helm executable binary", | ||
"xdg_data_home": "Helm data home path", | ||
"xdg_config_home": "Helm config home path", | ||
"xdg_cache_home": "Helm cache home path" | ||
}, | ||
) | ||
|
||
def _helm_toolchain_impl(ctx): | ||
for toolFile in ctx.files.tool: | ||
if toolFile.path.endswith("helm") or toolFile.path.endswith("helm.exe"): | ||
binary = toolFile | ||
|
||
if not binary: | ||
fail("Could not locate helm binary") | ||
|
||
toolchain_info = platform_common.ToolchainInfo( | ||
helminfo = HelmInfo( | ||
version = ctx.attr.version, | ||
binary = binary, | ||
xdg_data_home = ctx.attr.xdg_data_home, | ||
xdg_config_home = ctx.attr.xdg_config_home, | ||
xdg_cache_home = ctx.attr.xdg_cache_home | ||
), | ||
) | ||
return [toolchain_info] | ||
|
||
helm_toolchain = rule( | ||
implementation = _helm_toolchain_impl, | ||
attrs = { | ||
"version": attr.string(), | ||
"tool": attr.label(allow_files = True), | ||
"xdg_data_home": attr.string(), | ||
"xdg_config_home": attr.string(), | ||
"xdg_cache_home": attr.string() | ||
}, | ||
) |