Skip to content

Commit

Permalink
refactor: remove registry references (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed May 30, 2024
1 parent 638ca10 commit 75b8be6
Show file tree
Hide file tree
Showing 51 changed files with 137 additions and 1,050 deletions.
2 changes: 1 addition & 1 deletion .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bcr_test_module:
module_path: "e2e/crane_as_registry"
module_path: "e2e/smoke"
matrix:
bazel: ["6.x", "7.x"]
# TODO(#97): add windows
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,15 @@ jobs:
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }}
folder:
- .
- e2e/custom_registry
- e2e/wasm
- e2e/smoke
- e2e/crane_as_registry
- e2e/pull

bzlmodEnabled: [true, false]
exclude:
# macos is expensive (billed at 10X) so don't test these
- os: macos-latest
folder: e2e/custom_registry
- os: macos-latest
folder: e2e/wasm
- os: macos-latest
folder: e2e/crane_as_registry
- os: macos-latest
folder: e2e/pull
- os: macos-latest
Expand All @@ -84,9 +78,6 @@ jobs:
- folder: e2e/pull
bzlmodEnabled: false
# TODO: fix
- folder: e2e/custom_registry
bzlmodEnabled: true
# TODO: fix
- folder: e2e/wasm
bzlmodEnabled: true
# Steps represent a sequence of tasks that will be executed as part of the job
Expand Down
5 changes: 3 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "platforms", version = "0.0.5")

oci = use_extension("//oci:extensions.bzl", "oci")
oci.toolchains(crane_version = "v0.18.0")
oci.toolchains()
use_repo(oci, "oci_crane_registry_toolchains", "oci_crane_toolchains")

register_toolchains("@oci_crane_toolchains//:all", "@oci_crane_registry_toolchains//:all")

# Dev dependencies
bazel_lib = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains")
bazel_lib.jq()
use_repo(bazel_lib, "jq_toolchains")
bazel_lib.tar()
use_repo(bazel_lib, "bsd_tar_toolchains", "jq_toolchains")

bazel_dep(name = "rules_go", version = "0.46.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_pkg", version = "0.7.0", dev_dependency = True)
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ rules_oci does not contain language-specific rules, but we do have limited docum
There are some generic examples of usage in the [examples](https://github.com/bazel-contrib/rules_oci/tree/main/examples) folder.
Note that these examples rely on the setup code in the `/WORKSPACE` file in the root of this repo.

### Choosing between zot or crane as the local registry

rules_oci supports two different registry implementation for the temporary storage within actions spawned by bazel.

1. By default we recommend using `zot` as it stores blobs on disk, however it doesn't support `Docker`-format images.
2. `crane` is a better alternative as it supports both `OCI` and `Docker` formats which is required to make images with `Docker` media types work. However, it might not support everything that zot does.

## Public API Docs

### Install system packages
Expand Down
7 changes: 2 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ load("//oci:dependencies.bzl", "rules_oci_dependencies")

rules_oci_dependencies()

load("//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains")
load("//oci:repositories.bzl", "oci_register_toolchains")

oci_register_toolchains(
name = "oci",
crane_version = LATEST_CRANE_VERSION,
)
oci_register_toolchains(name = "oci")

## Setup bazel-lib
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains")
Expand Down
2 changes: 1 addition & 1 deletion docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rules_oci ought to be tested against runtimes such as podman to diversify the co
Just copy-paste this command into the terminal to run the tests

```bash
for dir in "." "e2e/smoke" "e2e/custom_registry" "e2e/crane_as_registry" "e2e/platforms"; do
for dir in "." "e2e/smoke" "e2e/platforms" "e2e/pull"; do
(cd "$dir" && bazel test //... || (echo "tests failed." && exit 1))
done
echo "ALL TESTS PASSED"
Expand Down
11 changes: 3 additions & 8 deletions docs/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ See more details in the [`oci_pull` docs](/docs/pull.md)
- Switch to `musl`

For example, if you wanted to use a base image with a newer glibc, you could use the Debian 12 `distroless/cc` image like so:

```
load("@rules_oci//oci:pull.bzl", "oci_pull")
Expand Down Expand Up @@ -94,15 +95,9 @@ load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")
rules_oci_dependencies()
load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains")
load("@rules_oci//oci:repositories.bzl", "oci_register_toolchains")
oci_register_toolchains(
name = "oci",
crane_version = LATEST_CRANE_VERSION,
# Uncommenting the zot toolchain will cause it to be used instead of crane for some tasks.
# Note that it does not support docker-format images.
# zot_version = LATEST_ZOT_VERSION,
)
oci_register_toolchains(name = "oci")
# Pull distroless image
Expand Down
3 changes: 0 additions & 3 deletions e2e/convert_docker_tarball/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ sh_binary(
name = "convert",
srcs = ["convert.bash"],
data = [
"@oci_crane_registry_toolchains//:current_toolchain",
"@oci_crane_toolchains//:current_toolchain",
],
)
Expand All @@ -20,13 +19,11 @@ run_binary(
"$@",
"$(location :image.tar)",
"$(CRANE_BIN)",
"$(LAUNCHER_WRAPPER)",
],
out_dirs = ["oci"],
tool = ":convert",
toolchains = [
"@oci_crane_toolchains//:current_toolchain",
"@oci_crane_registry_toolchains//:current_toolchain",
],
)

Expand Down
10 changes: 3 additions & 7 deletions e2e/convert_docker_tarball/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
workspace(name = "custom_registry_example")
workspace(name = "tarball")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

Expand All @@ -11,13 +11,9 @@ load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")

rules_oci_dependencies()

load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains")

oci_register_toolchains(
name = "oci",
crane_version = LATEST_CRANE_VERSION,
)
load("@rules_oci//oci:repositories.bzl", "oci_register_toolchains")

oci_register_toolchains(name = "oci")

http_archive(
name = "container_structure_test",
Expand Down
25 changes: 13 additions & 12 deletions e2e/convert_docker_tarball/convert.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,25 @@ set -o pipefail -o errexit -o nounset
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
RUNFILES="$SCRIPT_DIR/$(basename $0).runfiles"

TMP=$(mktemp -d)
export HOME="$TMP"

readonly OUTPUT="${1}"
readonly TARBALL="${2}"
readonly CRANE="${RUNFILES}/${3#"external/"}"
readonly REGISTRY_LAUNCHER=${RUNFILES}/${4#"external/"}


# Launch a registry instance at a random port
source "${REGISTRY_LAUNCHER}"
REGISTRY=$(start_registry $TMP $TMP/output.log)
trap "stop_registry ${TMP}" EXIT

output=$(mktemp)
$CRANE registry serve --address=localhost:0 >> $output 2>&1 &
timeout=$((SECONDS+10))
while [ "${SECONDS}" -lt "${timeout}" ]; do
port="$(cat $output | sed -nr 's/.+serving on port ([0-9]+)/\1/p')"
if [ -n "${port}" ]; then
break
fi
done
REGISTRY="localhost:$port"
echo "Registry is running at ${REGISTRY}"
readonly REPOSITORY="${REGISTRY}/local"


REF=$(mktemp)
"${CRANE}" push "${TARBALL}" "${REPOSITORY}" --image-refs="${REF}"
REF=$("${CRANE}" push "${TARBALL}" "${REPOSITORY}")

"${CRANE}" pull "$(cat $REF)" "${OUTPUT}" --format=oci
"${CRANE}" pull "$REF" "${OUTPUT}" --format=oci
1 change: 0 additions & 1 deletion e2e/crane_as_registry/.bazelrc

This file was deleted.

30 changes: 0 additions & 30 deletions e2e/crane_as_registry/BUILD.bazel

This file was deleted.

15 changes: 0 additions & 15 deletions e2e/crane_as_registry/MODULE.bazel

This file was deleted.

43 changes: 0 additions & 43 deletions e2e/crane_as_registry/WORKSPACE.bazel

This file was deleted.

1 change: 0 additions & 1 deletion e2e/crane_as_registry/WORKSPACE.bzlmod

This file was deleted.

8 changes: 0 additions & 8 deletions e2e/crane_as_registry/test.yaml

This file was deleted.

1 change: 0 additions & 1 deletion e2e/custom_registry/.bazelrc

This file was deleted.

21 changes: 0 additions & 21 deletions e2e/custom_registry/BUILD.bazel

This file was deleted.

40 changes: 0 additions & 40 deletions e2e/custom_registry/MODULE.bazel

This file was deleted.

12 changes: 0 additions & 12 deletions e2e/custom_registry/README.md

This file was deleted.

Loading

0 comments on commit 75b8be6

Please sign in to comment.