Skip to content

Commit

Permalink
feat: add default yq and jq versions (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan authored Apr 23, 2022
1 parent cf7b195 commit c2d4481
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions lib/private/jq_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ JQ_PLATFORMS = {
),
}

DEFAULT_JQ_VERSION = "1.6"

# https://github.com/stedolan/jq/releases
#
# The integrity hashes can be computed with
Expand Down
2 changes: 2 additions & 0 deletions lib/private/yq_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ YQ_PLATFORMS = {
),
}

DEFAULT_YQ_VERSION = "4.24.5"

# https://github.com/mikefarah/yq/releases
#
# The integrity hashes can be automatically fetched for the latest yq release by running
Expand Down
16 changes: 10 additions & 6 deletions lib/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//lib/private:jq_toolchain.bzl", "JQ_PLATFORMS", "jq_host_alias_repo", "jq_platform_repo", "jq_toolchains_repo")
load("//lib/private:yq_toolchain.bzl", "YQ_PLATFORMS", "yq_host_alias_repo", "yq_platform_repo", "yq_toolchains_repo")
load("//lib/private:jq_toolchain.bzl", "JQ_PLATFORMS", "jq_host_alias_repo", "jq_platform_repo", "jq_toolchains_repo", _DEFAULT_JQ_VERSION = "DEFAULT_JQ_VERSION")
load("//lib/private:yq_toolchain.bzl", "YQ_PLATFORMS", "yq_host_alias_repo", "yq_platform_repo", "yq_toolchains_repo", _DEFAULT_YQ_VERSION = "DEFAULT_YQ_VERSION")

def aspect_bazel_lib_dependencies():
"Load dependencies required by aspect rules"
Expand All @@ -17,12 +17,16 @@ def aspect_bazel_lib_dependencies():
],
)

def register_jq_toolchains(version, name = "jq"):
# Re-export the default versions
DEFAULT_JQ_VERSION = _DEFAULT_JQ_VERSION
DEFAULT_YQ_VERSION = _DEFAULT_YQ_VERSION

def register_jq_toolchains(name = "jq", version = DEFAULT_JQ_VERSION):
"""Registers jq toolchain and repositories
Args:
version: the version of jq to execute (see https://github.com/stedolan/jq/releases)
name: override the prefix for the generated toolchain repositories
version: the version of jq to execute (see https://github.com/stedolan/jq/releases)
"""
for [platform, meta] in JQ_PLATFORMS.items():
jq_platform_repo(
Expand All @@ -42,12 +46,12 @@ def register_jq_toolchains(version, name = "jq"):
user_repository_name = name,
)

def register_yq_toolchains(version, name = "yq"):
def register_yq_toolchains(name = "yq", version = DEFAULT_YQ_VERSION):
"""Registers yq toolchain and repositories
Args:
version: the version of yq to execute (see https://github.com/mikefarah/yq/releases)
name: override the prefix for the generated toolchain repositories
version: the version of yq to execute (see https://github.com/mikefarah/yq/releases)
"""
for [platform, meta] in YQ_PLATFORMS.items():
yq_platform_repo(
Expand Down

0 comments on commit c2d4481

Please sign in to comment.