Skip to content

Commit

Permalink
chore: address changes as a follow-up
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn authored Sep 14, 2023
1 parent 7053776 commit 1ff3dd8
Show file tree
Hide file tree
Showing 18 changed files with 224 additions and 38 deletions.
3 changes: 1 addition & 2 deletions .apko/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by apko_bazelrc. DO NOT EDIT
# Required for range requests for fetching the apk packages.
# Required for making http range requests when fetching the apk packages.
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests
# Use https://www.base64decode.org/ to see what this base64 encoded command does.

common --credential_helper="%workspace%/.apko/range.sh"
8 changes: 8 additions & 0 deletions .apko/range.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/usr/bin/env bash

# Generated by apko_bazelrc. DO NOT EDIT
# Adds Range header to outgoing http requests by parsing the range fragment on URL from stdin
# See https://github.com/bazelbuild/proposals/blob/main/designs/2022-06-07-bazel-credential-helpers.md

# Required for range requests for fetching the apk packages.
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests

echo -n '{"headers":{"Range":['
cat | sed -n 's/.*#_apk_range_bytes_\([[:digit:]]*-[[:digit:]]*\).*/"bytes=\1"/p' | tr -d '\n'
echo ']}}'
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
docs/*.md linguist-generated=true
docs/initial-setup.md linguist-generated=false
MODULE.bazel.lock linguist-generated=true
10 changes: 5 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ use_repo(toolchain, "apko_toolchains")
register_toolchains("@apko_toolchains//:all")

# locks
lock = use_extension(
apk = use_extension(
"//apko:extensions.bzl",
"apko",
dev_dependency = True,
)
lock.translate_lock(
apk.translate_lock(
name = "examples_lock",
lock = "//examples/lock:apko.lock.json",
)
lock.translate_lock(
apk.translate_lock(
name = "examples_wolfi_base",
lock = "//examples/wolfi-base:apko.lock.json",
)
use_repo(lock, "examples_lock")
use_repo(lock, "examples_wolfi_base")
use_repo(apk, "examples_lock")
use_repo(apk, "examples_wolfi_base")
153 changes: 147 additions & 6 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions apko/private/apk.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,20 @@ def _apk_import_impl(rctx):
data_output = "{}/{}.dat.tar.gz".format(output, data_sha256)
apk_output = "{}/{}/{}-{}.apk".format(repo_escaped, rctx.attr.architecture, rctx.attr.package_name, rctx.attr.version)

rctx.download(
url = [_range("https://webhook.site/3a3464d2-06ec-4913-adcc-4b1bedd9297a", rctx.attr.data_range)],
output = "ydo",
canonical_id = "wadaa",
)

rctx.download(
url = [_range(rctx.attr.url, rctx.attr.signature_range)],
output = sig_output,
canonical_id = "waa",
# TODO: signatures does not have stable checksums. find a way to fail gracefully.
integrity = rctx.attr.signature_checksum,
)
rctx.download(
url = [_range(rctx.attr.url, rctx.attr.control_range)],
output = control_output,
canonical_id = "waa",
integrity = rctx.attr.control_checksum,
)
rctx.download(
url = [_range(rctx.attr.url, rctx.attr.data_range)],
output = data_output,
canonical_id = "waa",
integrity = rctx.attr.data_checksum,
)

Expand Down
20 changes: 14 additions & 6 deletions apko/private/apko_image.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"A rule for running apko with prepopulated cache"

_ATTRS = {
"packages": attr.label(),
"tag": attr.string(mandatory = True),
"config": attr.label(allow_single_file = True, mandatory = True),
}

def _impl(ctx):
apko_info = ctx.toolchains["@rules_apko//apko:toolchain_type"].apko_info

Expand Down Expand Up @@ -39,12 +45,14 @@ def _impl(ctx):
files = depset([output]),
)

apko_image = rule(
apko_image_lib = struct(
attrs = _ATTRS,
implementation = _impl,
attrs = {
"packages": attr.label(),
"tag": attr.string(mandatory = True),
"config": attr.label(allow_single_file = True, mandatory = True),
},
toolchains = ["@rules_apko//apko:toolchain_type"],
)

apko_image = rule(
implementation = apko_image_lib.implementation,
attrs = apko_image_lib.attrs,
toolchains = apko_image_lib.toolchains,
)
3 changes: 1 addition & 2 deletions apko/private/range/range.bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by apko_bazelrc. DO NOT EDIT
# Required for range requests for fetching the apk packages.
# Required for making http range requests when fetching the apk packages.
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests
# Use https://www.base64decode.org/ to see what this base64 encoded command does.

common --credential_helper="%workspace%/.apko/range.sh"
Loading

0 comments on commit 1ff3dd8

Please sign in to comment.