-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit a3e132a
Showing
9 changed files
with
136 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bazel-* | ||
.tags | ||
.tags.lock | ||
.tags.temp |
Empty file.
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,5 @@ | ||
workspace(name = "com_github_yujunz_rules_helm") | ||
|
||
load("@com_github_yujunz_rules_helm//helm:deps.bzl", "helm_register_toolchains", "helm_rules_dependencies") | ||
helm_rules_dependencies() | ||
helm_register_toolchains() |
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,4 @@ | ||
toolchain_type( | ||
name = "toolchain", | ||
visibility = ["//visibility:public"], | ||
) |
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,10 @@ | ||
def _helm_chart_impl(ctx): | ||
return [] | ||
|
||
def helm_chart(): | ||
return rule( | ||
implementation = _helm_chart_impl, | ||
attrs = {}, | ||
toolchains = ["@com_github_yujunz_rules_helm//helm:toolchain"], | ||
**kwargs | ||
) |
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,5 @@ | ||
def helm_rules_dependencies(): | ||
pass | ||
|
||
def helm_register_toolchains(): | ||
pass |
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,43 @@ | ||
BAZEL_HELM_OS_CONSTRAINTS = { | ||
"darwin": "@bazel_tools//platforms:osx", | ||
"linux": "@bazel_tools//platforms:linux", | ||
} | ||
|
||
BAZEL_HELM_ARCH_CONSTRAINTS = { | ||
"amd64": "@bazel_tools//platforms:x86_64", | ||
} | ||
|
||
HELM_OS_ARCH = ( | ||
("darwin", "amd64"), | ||
("linux", "amd64"), | ||
) | ||
|
||
def _generate_constraints(names, bazel_constraints): | ||
return { | ||
name: bazel_constraints.get(name, "@com_github_yujunz_rules_helm//helm/toolchain:" + name) | ||
for name in names | ||
} | ||
|
||
HELM_OS_CONSTRAINTS = _generate_constraints([p[0] for p in HELM_OS_ARCH], BAZEL_HELM_OS_CONSTRAINTS) | ||
HELM_ARCH_CONSTRAINTS = _generate_constraints([p[1] for p in HELM_OS_ARCH], BAZEL_HELM_ARCH_CONSTRAINTS) | ||
|
||
def _generate_platforms(): | ||
platforms = [] | ||
for os, arch in HELM_OS_ARCH: | ||
constraints = [ | ||
HELM_OS_CONSTRAINTS[os], | ||
HELM_ARCH_CONSTRAINTS[arch], | ||
] | ||
platforms.append(struct( | ||
name = os + "_" + arch, | ||
os = os, | ||
arch = arch, | ||
constraints = constraints, | ||
)) | ||
return platforms | ||
|
||
PLATFORMS = _generate_platforms() | ||
|
||
def generate_toolchain_names(): | ||
# keep in sync with declare_toolchains | ||
return ["helm_" + p.name for p in PLATFORMS] |
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,15 @@ | ||
load( | ||
":toolchains.bzl", | ||
"declare_constraints", | ||
) | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
declare_constraints() | ||
|
||
filegroup( | ||
name = "all_files", | ||
testonly = True, | ||
srcs = glob(["**"]), | ||
visibility = ["//visibility:public"], | ||
) |
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,50 @@ | ||
load( | ||
"@com_github_yujunz_rules_helm//helm:platforms.bzl", | ||
"HELM_ARCH_CONSTRAINTS", | ||
"HELM_OS_CONSTRAINTS", | ||
"PLATFORMS", | ||
) | ||
|
||
def declare_constraints(): | ||
"""Generates constraint_values and platform targets for valid platforms. | ||
Each constraint_value corresponds to a valid os or goarch. | ||
The os and goarch values belong to the constraint_settings | ||
@bazel_tools//platforms:os and @bazel_tools//platforms:cpu, respectively. | ||
To avoid redundancy, if there is an equivalent value in @bazel_tools, | ||
we define an alias here instead of another constraint_value. | ||
Each platform defined here selects a os and goarch constraint value. | ||
These platforms may be used with --platforms for cross-compilation, | ||
though users may create their own platforms (and | ||
@bazel_tools//platforms:default_platform will be used most of the time). | ||
""" | ||
for os, constraint in HELM_OS_CONSTRAINTS.items(): | ||
if constraint.startswith("@com_github_yujunz_rules_helm//helm/toolchain:"): | ||
native.constraint_value( | ||
name = os, | ||
constraint_setting = "@bazel_tools//platforms:os", | ||
) | ||
else: | ||
native.alias( | ||
name = os, | ||
actual = constraint, | ||
) | ||
|
||
for arch, constraint in HELM_ARCH_CONSTRAINTS.items(): | ||
if constraint.startswith("@com_github_yujunz_rules_helm//helm/toolchain:"): | ||
native.constraint_value( | ||
name = arch, | ||
constraint_setting = "@bazel_tools//platforms:cpu", | ||
) | ||
else: | ||
native.alias( | ||
name = arch, | ||
actual = constraint, | ||
) | ||
|
||
for p in PLATFORMS: | ||
native.platform( | ||
name = p.name, | ||
constraint_values = p.constraints, | ||
) |