Skip to content

Commit

Permalink
Merge pull request #2 from banksalad/coin-795
Browse files Browse the repository at this point in the history
  • Loading branch information
hoonahn authored Sep 4, 2023
2 parents 8404948 + 6f0c239 commit 9a828a1
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 20 deletions.
10 changes: 5 additions & 5 deletions helm/helm-chart-package.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ if [ -z $DIGEST_PATH ]; then

# Image repository is provided as a static value
if [ "$IMAGE_REPOSITORY" != "" ] && [ -n $IMAGE_REPOSITORY ]; then
{YQ_PATH} w -i {CHART_VALUES_PATH} {VALUES_REPO_YAML_PATH} $IMAGE_REPOSITORY
repo=$IMAGE_REPOSITORY {YQ_PATH} -i '.{VALUES_REPO_YAML_PATH} = env(repo)' {CHART_VALUES_PATH}
echo "Replaced image repository in chart values.yaml with: $IMAGE_REPOSITORY"
fi

# Image tag is provided as a static value
if [ "$IMAGE_TAG" != "" ] && [ -n $IMAGE_TAG ]; then
{YQ_PATH} w -i {CHART_VALUES_PATH} {VALUES_TAG_YAML_PATH} $IMAGE_TAG
tag=$IMAGE_TAG {YQ_PATH} -i '.{VALUES_TAG_YAML_PATH} = env(tag)' {CHART_VALUES_PATH}
echo "Replaced image tag in chart values.yaml with: $IMAGE_TAG"
fi

Expand All @@ -58,7 +58,7 @@ if [ -n $DIGEST_PATH ] && [ "$DIGEST_PATH" != "" ]; then
IFS=':' read -ra digest_split <<< "$DIGEST"
DIGEST_SHA=${digest_split[1]}

{YQ_PATH} w -i {CHART_VALUES_PATH} {VALUES_TAG_YAML_PATH} $DIGEST_SHA
sha=$DIGEST_PATH {YQ_PATH} -i '.{VALUES_TAG_YAML_PATH} = env(sha)' {CHART_VALUES_PATH}

echo "Replaced image tag in chart values.yaml with: $DIGEST_SHA"

Expand All @@ -68,12 +68,12 @@ if [ -n $DIGEST_PATH ] && [ "$DIGEST_PATH" != "" ]; then
REPO_URL="{IMAGE_REPOSITORY}"
else
# if image_repository attr is not provided, extract it from values.yaml
REPO_URL=$({YQ_PATH} r {CHART_VALUES_PATH} {VALUES_REPO_YAML_PATH})
REPO_URL=$({YQ_PATH} .{VALUES_REPO_YAML_PATH} {CHART_VALUES_PATH})
fi

# appends @sha256 suffix to image repo url value if the repository value does not already contains it
if ([ -n $REPO_URL ] || [ -n $REPO_SUFIX ]) && ([[ $REPO_URL != *"$REPO_SUFIX" ]] || [[ -z "$REPO_SUFIX" ]]); then
{YQ_PATH} w -i {CHART_VALUES_PATH} {VALUES_REPO_YAML_PATH} ${REPO_URL}${REPO_SUFIX}
repo=${REPO_URL}${REPO_SUFIX} {YQ_PATH} -i '.{VALUES_REPO_YAML_PATH} = env(repo)' {CHART_VALUES_PATH}
fi
fi

Expand Down
14 changes: 14 additions & 0 deletions repositories/helm_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,23 @@ def helm_repositories():
build_file = "@com_github_masmovil_bazel_rules//:helm.BUILD",
)

http_archive(
name = "helm_v3.12.2_darwin_arm64",
sha256 = "b60ee16847e28879ae298a20ba4672fc84f741410f438e645277205824ddbf55",
urls = ["https://get.helm.sh/helm-v3.12.2-darwin-arm64.tar.gz"],
build_file = "@com_github_masmovil_bazel_rules//:helm.BUILD",
)

http_archive(
name = "helm_v3.12.2_linux",
sha256 = "2b6efaa009891d3703869f4be80ab86faa33fa83d9d5ff2f6492a8aebe97b219",
urls = ["https://get.helm.sh/helm-v3.12.2-linux-amd64.tar.gz"],
build_file = "@com_github_masmovil_bazel_rules//:helm.BUILD",
)

http_archive(
name = "helm_v3.12.2_linux_arm64",
sha256 = "cfafbae85c31afde88c69f0e5053610c8c455826081c1b2d665d9b44c31b3759",
urls = ["https://get.helm.sh/helm-v3.12.2-linux-arm64.tar.gz"],
build_file = "@com_github_masmovil_bazel_rules//:helm.BUILD",
)
24 changes: 19 additions & 5 deletions repositories/kubectl_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
def kubectl_repositories():
http_file(
name = "kubectl_darwin",
sha256 = "9b45260bb16f251cf2bb4b4c5f90bc847ab752c9c936b784dc2bae892e10205a",
urls = ["https://storage.googleapis.com/kubernetes-release/release/v1.16.1/bin/darwin/amd64/kubectl"],
sha256 = "e74efd3f6998cb51da707cc2e04b23e04ab90bea585be94d487ac545c6393ef9",
urls = ["https://dl.k8s.io/v1.25.13/bin/darwin/amd64/kubectl"],
executable = True
)

http_file(
name = "kubectl_darwin_arm64",
sha256 = "41ed5aba120d3a078fc5086e866d02c42720f312f15836b29b1c77a7b8794119",
urls = ["https://dl.k8s.io/v1.25.13/bin/darwin/arm64/kubectl"],
executable = True
)

http_file(
name = "kubectl_linux",
sha256 = "69cfb3eeaa0b77cc4923428855acdfc9ca9786544eeaff9c21913be830869d29",
urls = ["https://storage.googleapis.com/kubernetes-release/release/v1.16.1/bin/linux/amd64/kubectl"],
sha256 = "22c5d5cb95b671ea7d7accd77e60e4a787b6d40a6b8ba4d6c364cb3ca818c29a",
urls = ["https://dl.k8s.io/v1.25.13/bin/linux/amd64/kubectl"],
executable = True
)
)

http_file(
name = "kubectl_linux_arm64",
sha256 = "90bb3c9126b64f5eee2bef5a584da8bf0a38334e341b427b6986261af5f0d49b",
urls = ["https://dl.k8s.io/v1.25.13/bin/linux/arm64/kubectl"],
executable = True
)
6 changes: 6 additions & 0 deletions repositories/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ def repositories():
# Register the default docker toolchain that expects the 'docker'
# executable to be in the PATH
"@com_github_masmovil_bazel_rules//toolchains/yq:yq_linux_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/yq:yq_linux_arm64_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/yq:yq_osx_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/yq:yq_osx_arm64_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/yq:yq_windows_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/helm:helm_v2.17.0_linux_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/helm:helm_v2.17.0_osx_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/helm-3:helm_v3.12.2_linux_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/helm-3:helm_v3.12.2_linux_arm64_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/helm-3:helm_v3.12.2_osx_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/helm-3:helm_v3.12.2_osx_arm64_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/kubectl:kubectl_linux_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/kubectl:kubectl_linux_arm64_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/kubectl:kubectl_osx_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/kubectl:kubectl_osx_arm64_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/sops:sops_linux_amd64_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/sops:sops_linux_arm64_toolchain",
"@com_github_masmovil_bazel_rules//toolchains/sops:sops_osx_amd64_toolchain",
Expand Down
26 changes: 20 additions & 6 deletions repositories/yq_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,29 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")

def yq_repositories():
http_file(
name = "yq_v2.4.1_linux",
urls = ["https://github.com/mikefarah/yq/releases/download/2.4.1/yq_linux_amd64"],
sha256 = "754c6e6a7ef92b00ef73b8b0bb1d76d651e04d26aa6c6625e272201afa889f8b",
name = "yq_v4.35.1_linux",
urls = ["https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64"],
sha256 = "bd695a6513f1196aeda17b174a15e9c351843fb1cef5f9be0af170f2dd744f08",
executable = True
)

http_file(
name = "yq_v2.4.1_darwin",
urls = ["https://github.com/mikefarah/yq/releases/download/2.4.1/yq_darwin_amd64"],
sha256 = "06732685917646c0bbba8cc17386cd2a39b214ad3cd128fb4b8b410ed069101c",
name = "yq_v4.35.1_linux_arm64",
urls = ["https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_arm64"],
sha256 = "1d830254fe5cc2fb046479e6c781032976f5cf88f9d01a6385898c29182f9bed",
executable = True
)

http_file(
name = "yq_v4.35.1_darwin",
urls = ["https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_darwin_amd64"],
sha256 = "b2ff70e295d02695b284755b2a41bd889cfb37454e1fa71abc3a6ec13b2676cf",
executable = True
)

http_file(
name = "yq_v4.35.1_darwin_arm64",
urls = ["https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_darwin_arm64"],
sha256 = "e9fc15db977875de982e0174ba5dc2cf5ae4a644e18432a4262c96d4439b1686",
executable = True
)
24 changes: 24 additions & 0 deletions toolchains/helm-3/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ toolchain(
toolchain_type = ":toolchain_type",
)

toolchain(
name = "helm_v3.12.2_linux_arm64_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
toolchain = "@helm_toolchain_configure//:helm_v3.12.2_linux_arm64",
toolchain_type = ":toolchain_type",
)

toolchain(
name = "helm_v3.12.2_osx_toolchain",
target_compatible_with = [
Expand All @@ -26,3 +40,13 @@ toolchain(
toolchain = "@helm_toolchain_configure//:helm_v3.12.2_darwin",
toolchain_type = ":toolchain_type",
)

toolchain(
name = "helm_v3.12.2_osx_arm64_toolchain",
target_compatible_with = [
"@platforms//os:osx",
"@platforms//cpu:arm64",
],
toolchain = "@helm_toolchain_configure//:helm_v3.12.2_darwin_arm64",
toolchain_type = ":toolchain_type",
)
24 changes: 22 additions & 2 deletions toolchains/helm-3/BUILD.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ load("@com_github_masmovil_bazel_rules//toolchains/helm-3:toolchain.bzl", "helm_
helm_toolchain(
name = "helm_v3.12.2_darwin",
tool = "@helm_v3.12.2_darwin//:helm",
helm_version = "3.4.1",
helm_version = "3.12.2",
helm_xdg_data_home = "%{HOME}/Library",
helm_xdg_config_home = "%{HOME}/Library/Preferences",
helm_xdg_cache_home = "%{HOME}/Library/Caches",
visibility = ["//visibility:public"],
)

helm_toolchain(
name = "helm_v3.12.2_darwin_arm64",
tool = "@helm_v3.12.2_darwin_arm64//:helm",
helm_version = "3.12.2",
helm_xdg_data_home = "%{HOME}/Library",
helm_xdg_config_home = "%{HOME}/Library/Preferences",
helm_xdg_cache_home = "%{HOME}/Library/Caches",
Expand All @@ -18,7 +28,17 @@ helm_toolchain(
helm_toolchain(
name = "helm_v3.12.2_linux",
tool = "@helm_v3.12.2_linux//:helm",
helm_version = "3.4.1",
helm_version = "3.12.2",
helm_xdg_data_home = "%{HOME}/.local/share",
helm_xdg_config_home = "%{HOME}/.config",
helm_xdg_cache_home = "%{HOME}/.cache",
visibility = ["//visibility:public"],
)

helm_toolchain(
name = "helm_v3.12.2_linux_arm64",
tool = "@helm_v3.12.2_linux_arm64//:helm",
helm_version = "3.12.2",
helm_xdg_data_home = "%{HOME}/.local/share",
helm_xdg_config_home = "%{HOME}/.config",
helm_xdg_cache_home = "%{HOME}/.cache",
Expand Down
24 changes: 24 additions & 0 deletions toolchains/kubectl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ toolchain(
toolchain_type = ":toolchain_type",
)

toolchain(
name = "kubectl_linux_arm64_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
toolchain = ":kubectl_linux_arm64",
toolchain_type = ":toolchain_type",
)

toolchain(
name = "kubectl_osx_toolchain",
target_compatible_with = [
Expand All @@ -39,3 +53,13 @@ toolchain(
toolchain = ":kubectl_darwin",
toolchain_type = ":toolchain_type",
)

toolchain(
name = "kubectl_osx_arm64_toolchain",
target_compatible_with = [
"@platforms//os:osx",
"@platforms//cpu:arm64",
],
toolchain = ":kubectl_darwin_arm64",
toolchain_type = ":toolchain_type",
)
41 changes: 39 additions & 2 deletions toolchains/yq/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,25 @@ toolchain_type(name = "toolchain_type")
# to be in the PATH.
yq_toolchain(
name = "yq_linux",
tool = "@yq_v2.4.1_linux//file",
tool = "@yq_v4.35.1_linux//file",
visibility = ["//visibility:public"],
)

yq_toolchain(
name = "yq_linux_arm64",
tool = "@yq_v4.35.1_linux_arm64//file",
visibility = ["//visibility:public"],
)

yq_toolchain(
name = "yq_osx",
tool = "@yq_v2.4.1_darwin//file",
tool = "@yq_v4.35.1_darwin//file",
visibility = ["//visibility:public"],
)

yq_toolchain(
name = "yq_osx_arm64",
tool = "@yq_v4.35.1_darwin_arm64//file",
visibility = ["//visibility:public"],
)

Expand All @@ -38,15 +50,40 @@ toolchain(
toolchain_type = ":toolchain_type",
)

toolchain(
name = "yq_linux_arm64_toolchain",
exec_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
target_compatible_with = [
"@platforms//os:linux",
"@platforms//cpu:arm64",
],
toolchain = ":yq_linux_arm64",
toolchain_type = ":toolchain_type",
)

toolchain(
name = "yq_osx_toolchain",
target_compatible_with = [
"@platforms//os:osx",
"@platforms//cpu:x86_64",
],
toolchain = ":yq_osx",
toolchain_type = ":toolchain_type",
)

toolchain(
name = "yq_osx_arm64_toolchain",
target_compatible_with = [
"@platforms//os:osx",
"@platforms//cpu:arm64",
],
toolchain = ":yq_osx_arm64",
toolchain_type = ":toolchain_type",
)

toolchain(
name = "yq_windows_toolchain",
exec_compatible_with = [
Expand Down

0 comments on commit 9a828a1

Please sign in to comment.