diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e4ea8f6a..bd272ab6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,9 +9,10 @@ default_stages: [commit] repos: # Check formatting and lint for starlark code - repo: https://github.com/keith/pre-commit-buildifier - rev: 4.0.1.1 + rev: 6.3.3 hooks: - id: buildifier + args: ["-mode=fix", "-lint=fix"] - id: buildifier-lint # Enforce that commit messages allow for later changelog generation - repo: https://github.com/commitizen-tools/commitizen diff --git a/BUILD.bazel b/BUILD.bazel index afe4464d..5ac2bb89 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,5 @@ -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary") +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") gazelle_binary( name = "gazelle_bin", diff --git a/MODULE.bazel b/MODULE.bazel index e02f6ea1..181a28ea 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -2,8 +2,8 @@ module( name = "rules_oci", - compatibility_level = 1, version = "0.0.0", + compatibility_level = 1, ) bazel_dep(name = "aspect_bazel_lib", version = "1.32.0") @@ -12,10 +12,10 @@ bazel_dep(name = "platforms", version = "0.0.5") oci = use_extension("//oci:extensions.bzl", "oci") oci.toolchains(crane_version = "v0.14.0") -use_repo(oci, "oci_crane_toolchains", "oci_crane_registry_toolchains", "oci_auth_config") +use_repo(oci, "oci_auth_config", "oci_crane_registry_toolchains", "oci_crane_toolchains") register_toolchains("@oci_crane_toolchains//:all", "@oci_crane_registry_toolchains//:all") bazel_dep(name = "rules_pkg", version = "0.7.0", dev_dependency = True) -bazel_dep(name = "gazelle", version = "0.29.0", repo_name = "bazel_gazelle", dev_dependency = True) +bazel_dep(name = "gazelle", version = "0.29.0", dev_dependency = True, repo_name = "bazel_gazelle") bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependency = True) diff --git a/WORKSPACE b/WORKSPACE index aaf57198..3b3602ad 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -33,10 +33,11 @@ load("@container_structure_test//:repositories.bzl", "container_structure_test_r container_structure_test_register_toolchain(name = "container_structure_test") +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") + ############################################ # Gazelle, for generating bzl_library targets load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") -load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") go_rules_dependencies() diff --git a/cosign/defs.bzl b/cosign/defs.bzl index 01663d69..fc9ebf0d 100644 --- a/cosign/defs.bzl +++ b/cosign/defs.bzl @@ -1,7 +1,7 @@ "Public API" -load("//cosign/private:sign.bzl", _cosign_sign = "cosign_sign") load("//cosign/private:attest.bzl", _cosign_attest = "cosign_attest") +load("//cosign/private:sign.bzl", _cosign_sign = "cosign_sign") cosign_sign = _cosign_sign cosign_attest = _cosign_attest diff --git a/e2e/auth/BUILD.bazel b/e2e/auth/BUILD.bazel index 32e6eacf..7953351c 100644 --- a/e2e/auth/BUILD.bazel +++ b/e2e/auth/BUILD.bazel @@ -1,5 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") load("@bazel_gazelle//:def.bzl", "gazelle") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push") # gazelle:prefix example.com/auth diff --git a/e2e/auth/MODULE.bazel b/e2e/auth/MODULE.bazel index 0548f199..293401f5 100644 --- a/e2e/auth/MODULE.bazel +++ b/e2e/auth/MODULE.bazel @@ -1,5 +1,7 @@ "Bazel dependencies" -bazel_dep(name = "rules_oci", dev_dependency = True, version = "0.0.0") + +bazel_dep(name = "rules_oci", version = "0.0.0", dev_dependency = True) + bazel_dep(name = "platforms", version = "0.0.5") local_path_override( @@ -7,13 +9,10 @@ local_path_override( path = "../..", ) - oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") - oci.pull( name = "empty_image", digest = "sha256:2d4595bbc0fabeb1489b1071f56c26f44a2f495afaa9386ad7d24e7b3d8dfd3e", - image = "http://localhost:1447/empty_image" + image = "http://localhost:1447/empty_image", ) - -use_repo(oci, "empty_image") \ No newline at end of file +use_repo(oci, "empty_image") diff --git a/e2e/crane_as_registry/BUILD.bazel b/e2e/crane_as_registry/BUILD.bazel index 44a9e7d6..189c4a21 100644 --- a/e2e/crane_as_registry/BUILD.bazel +++ b/e2e/crane_as_registry/BUILD.bazel @@ -1,5 +1,5 @@ -load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") load("@container_structure_test//:defs.bzl", "container_structure_test") +load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") oci_image( name = "image", diff --git a/e2e/crane_as_registry/MODULE.bazel b/e2e/crane_as_registry/MODULE.bazel index db1d6763..d9582ad9 100644 --- a/e2e/crane_as_registry/MODULE.bazel +++ b/e2e/crane_as_registry/MODULE.bazel @@ -1,6 +1,8 @@ "Bazel dependencies" -bazel_dep(name = "container_structure_test", dev_dependency = True, version = "1.15.0") -bazel_dep(name = "rules_oci", dev_dependency = True, version = "0.0.0") + +bazel_dep(name = "container_structure_test", version = "1.15.0", dev_dependency = True) +bazel_dep(name = "rules_oci", version = "0.0.0", dev_dependency = True) + bazel_dep(name = "platforms", version = "0.0.5") local_path_override( diff --git a/e2e/custom_registry/BUILD.bazel b/e2e/custom_registry/BUILD.bazel index d550e90e..eff87d11 100644 --- a/e2e/custom_registry/BUILD.bazel +++ b/e2e/custom_registry/BUILD.bazel @@ -1,5 +1,5 @@ -load("@rules_oci//oci:defs.bzl", "oci_image") load("@container_structure_test//:defs.bzl", "container_structure_test") +load("@rules_oci//oci:defs.bzl", "oci_image") oci_image( name = "image", diff --git a/e2e/custom_registry/registry/BUILD.bazel b/e2e/custom_registry/registry/BUILD.bazel index ac920396..e30e472b 100644 --- a/e2e/custom_registry/registry/BUILD.bazel +++ b/e2e/custom_registry/registry/BUILD.bazel @@ -1,6 +1,6 @@ +load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") load("@rules_oci//oci:toolchain.bzl", "registry_toolchain") -load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") copy_file( name = "launcher", diff --git a/e2e/smoke/BUILD.bazel b/e2e/smoke/BUILD.bazel index cfa9836c..03671eef 100644 --- a/e2e/smoke/BUILD.bazel +++ b/e2e/smoke/BUILD.bazel @@ -1,7 +1,7 @@ load("@aspect_bazel_lib//lib:testing.bzl", "assert_json_matches") load("@bazel_skylib//rules:write_file.bzl", "write_file") -load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") load("@container_structure_test//:defs.bzl", "container_structure_test") +load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") oci_image( name = "image", diff --git a/e2e/smoke/MODULE.bazel b/e2e/smoke/MODULE.bazel index df87ed95..a4605a1b 100644 --- a/e2e/smoke/MODULE.bazel +++ b/e2e/smoke/MODULE.bazel @@ -1,6 +1,8 @@ "Bazel dependencies" -bazel_dep(name = "container_structure_test", dev_dependency = True, version = "1.15.0") -bazel_dep(name = "rules_oci", dev_dependency = True, version = "0.0.0") + +bazel_dep(name = "container_structure_test", version = "1.15.0", dev_dependency = True) +bazel_dep(name = "rules_oci", version = "0.0.0", dev_dependency = True) + bazel_dep(name = "platforms", version = "0.0.5") bazel_dep(name = "aspect_bazel_lib", version = "1.32.0") bazel_dep(name = "bazel_skylib", version = "1.1.1") @@ -11,7 +13,6 @@ local_path_override( ) oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") - oci.pull( name = "distroless_base", digest = "sha256:ccaef5ee2f1850270d453fdf700a5392534f8d1a8ca2acda391fbb6a06b81c86", @@ -21,5 +22,4 @@ oci.pull( "linux/arm64", ], ) - use_repo(oci, "distroless_base") diff --git a/e2e/smoke/WORKSPACE.bazel b/e2e/smoke/WORKSPACE.bazel index 8ca5da43..4aa22688 100644 --- a/e2e/smoke/WORKSPACE.bazel +++ b/e2e/smoke/WORKSPACE.bazel @@ -24,7 +24,7 @@ load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies") rules_oci_dependencies() -load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "LATEST_ZOT_VERSION", "oci_register_toolchains") +load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains") oci_register_toolchains( name = "oci", @@ -45,4 +45,4 @@ oci_pull( "linux/amd64", "linux/arm64", ], -) \ No newline at end of file +) diff --git a/e2e/wasm/BUILD.bazel b/e2e/wasm/BUILD.bazel index d0ee23d2..ea8270d3 100644 --- a/e2e/wasm/BUILD.bazel +++ b/e2e/wasm/BUILD.bazel @@ -1,8 +1,8 @@ -load("@rules_rust//rust:defs.bzl", "rust_binary") load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") -load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball") load("@rules_pkg//pkg:tar.bzl", "pkg_tar") +load("@rules_rust//rust:defs.bzl", "rust_binary") package(default_visibility = ["//visibility:public"]) diff --git a/examples/attest/BUILD.bazel b/examples/attest/BUILD.bazel index 1fc37999..7a136c14 100644 --- a/examples/attest/BUILD.bazel +++ b/examples/attest/BUILD.bazel @@ -1,6 +1,6 @@ +load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") load("//cosign:defs.bzl", "cosign_attest") load("//oci:defs.bzl", "oci_image") -load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") copy_file( name = "sbom", diff --git a/examples/attest_external/BUILD.template b/examples/attest_external/BUILD.template index 07119059..9a8a0caa 100644 --- a/examples/attest_external/BUILD.template +++ b/examples/attest_external/BUILD.template @@ -2,7 +2,7 @@ load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") copy_file( name = "example_sbom", - visibility = ["//visibility:public"], src = "sbom.spdx", out = "sbom_generated.spdx", -) \ No newline at end of file + visibility = ["//visibility:public"], +) diff --git a/examples/empty_base/BUILD.bazel b/examples/empty_base/BUILD.bazel index 0036a83a..411d6879 100644 --- a/examples/empty_base/BUILD.bazel +++ b/examples/empty_base/BUILD.bazel @@ -1,7 +1,7 @@ -load("//oci:defs.bzl", "oci_image", "oci_tarball") load("@aspect_bazel_lib//lib:testing.bzl", "assert_json_matches") load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@container_structure_test//:defs.bzl", "container_structure_test") +load("//oci:defs.bzl", "oci_image", "oci_tarball") oci_image( name = "image", diff --git a/examples/env/BUILD.bazel b/examples/env/BUILD.bazel index f66de7bc..f09ca7b5 100644 --- a/examples/env/BUILD.bazel +++ b/examples/env/BUILD.bazel @@ -1,8 +1,8 @@ -load("//oci:defs.bzl", "oci_image") -load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template") -load("@rules_pkg//pkg:tar.bzl", "pkg_tar") +load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@container_structure_test//:defs.bzl", "container_structure_test") +load("@rules_pkg//pkg:tar.bzl", "pkg_tar") +load("//oci:defs.bzl", "oci_image") pkg_tar( name = "app", diff --git a/examples/env_inheritance/BUILD.bazel b/examples/env_inheritance/BUILD.bazel index f21f5de3..27290c43 100644 --- a/examples/env_inheritance/BUILD.bazel +++ b/examples/env_inheritance/BUILD.bazel @@ -1,7 +1,7 @@ -load("//oci:defs.bzl", "oci_image") +load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains") load("@container_structure_test//:defs.bzl", "container_structure_test") load("@rules_pkg//pkg:tar.bzl", "pkg_tar") -load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains") +load("//oci:defs.bzl", "oci_image") pkg_tar( name = "app", diff --git a/examples/labels/BUILD.bazel b/examples/labels/BUILD.bazel index 29aec3cc..080ad0a5 100644 --- a/examples/labels/BUILD.bazel +++ b/examples/labels/BUILD.bazel @@ -1,8 +1,8 @@ -load("//oci:defs.bzl", "oci_image") -load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template") -load("@rules_pkg//pkg:tar.bzl", "pkg_tar") +load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@container_structure_test//:defs.bzl", "container_structure_test") +load("@rules_pkg//pkg:tar.bzl", "pkg_tar") +load("//oci:defs.bzl", "oci_image") pkg_tar( name = "app", diff --git a/examples/location_expansion/BUILD.bazel b/examples/location_expansion/BUILD.bazel index 6b7619e5..d19bcad2 100644 --- a/examples/location_expansion/BUILD.bazel +++ b/examples/location_expansion/BUILD.bazel @@ -1,6 +1,6 @@ -load("//oci:defs.bzl", "oci_image") load("@container_structure_test//:defs.bzl", "container_structure_test") load("@rules_pkg//:pkg.bzl", "pkg_tar") +load("//oci:defs.bzl", "oci_image") sh_binary( name = "test_sh", diff --git a/examples/multi_arch/BUILD.bazel b/examples/multi_arch/BUILD.bazel index 6b6f8649..c99cb725 100644 --- a/examples/multi_arch/BUILD.bazel +++ b/examples/multi_arch/BUILD.bazel @@ -1,6 +1,6 @@ -load("//oci:defs.bzl", "oci_image", "oci_image_index") -load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains") +load("@rules_pkg//pkg:tar.bzl", "pkg_tar") +load("//oci:defs.bzl", "oci_image", "oci_image_index") load(":transition.bzl", "multi_arch") pkg_tar( diff --git a/examples/push/BUILD.bazel b/examples/push/BUILD.bazel index 2a91d541..5e1eb8d5 100644 --- a/examples/push/BUILD.bazel +++ b/examples/push/BUILD.bazel @@ -1,6 +1,6 @@ -load("//oci:defs.bzl", "oci_image", "oci_image_index", "oci_push") -load("@bazel_skylib//rules:write_file.bzl", "write_file") load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template") +load("@bazel_skylib//rules:write_file.bzl", "write_file") +load("//oci:defs.bzl", "oci_image", "oci_image_index", "oci_push") oci_image( name = "image", diff --git a/examples/repo_tags/BUILD.bazel b/examples/repo_tags/BUILD.bazel index 182f7b3b..732b2d6f 100644 --- a/examples/repo_tags/BUILD.bazel +++ b/examples/repo_tags/BUILD.bazel @@ -1,6 +1,6 @@ -load("//oci:defs.bzl", "oci_image", "oci_tarball") load("@aspect_bazel_lib//lib:testing.bzl", "assert_json_matches") load("@bazel_skylib//rules:write_file.bzl", "write_file") +load("//oci:defs.bzl", "oci_image", "oci_tarball") oci_image( name = "image", diff --git a/examples/sign/BUILD.bazel b/examples/sign/BUILD.bazel index 3eb329b0..a9139c4c 100644 --- a/examples/sign/BUILD.bazel +++ b/examples/sign/BUILD.bazel @@ -1,6 +1,6 @@ +load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("//cosign:defs.bzl", "cosign_sign") load("//oci:defs.bzl", "oci_image") -load("@rules_pkg//pkg:tar.bzl", "pkg_tar") pkg_tar( name = "app", diff --git a/examples/sign_external/BUILD.template b/examples/sign_external/BUILD.template index d36acf3e..db6954d7 100644 --- a/examples/sign_external/BUILD.template +++ b/examples/sign_external/BUILD.template @@ -2,7 +2,7 @@ load("@rules_oci//oci:defs.bzl", "oci_image") oci_image( name = "empty_image", - visibility = ["//visibility:public"], + architecture = "arm64", os = "linux", - architecture = "arm64" -) \ No newline at end of file + visibility = ["//visibility:public"], +) diff --git a/examples/various/BUILD.bazel b/examples/various/BUILD.bazel index 157c6772..9f047bf6 100644 --- a/examples/various/BUILD.bazel +++ b/examples/various/BUILD.bazel @@ -1,5 +1,5 @@ -load("//oci:defs.bzl", "oci_image") load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("//oci:defs.bzl", "oci_image") oci_image( name = "imagE", @@ -8,10 +8,9 @@ oci_image( os = "linux", ) - build_test( name = "test", targets = [ ":imagE", ], -) \ No newline at end of file +) diff --git a/oci/defs.bzl b/oci/defs.bzl index da01399d..e5e4cc1c 100644 --- a/oci/defs.bzl +++ b/oci/defs.bzl @@ -6,15 +6,15 @@ load("@rules_oci//oci:defs.bzl", ...) ``` """ -load("//oci/private:tarball.bzl", _oci_tarball = "oci_tarball") -load("//oci/private:image.bzl", _oci_image = "oci_image") -load("//oci/private:image_index.bzl", _oci_image_index = "oci_image_index") -load("//oci/private:push.bzl", _oci_push = "oci_push") load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path") load("@aspect_bazel_lib//lib:jq.bzl", "jq") load("@bazel_skylib//lib:types.bzl", "types") load("@bazel_skylib//rules:write_file.bzl", "write_file") +load("//oci/private:image.bzl", _oci_image = "oci_image") +load("//oci/private:image_index.bzl", _oci_image_index = "oci_image_index") +load("//oci/private:push.bzl", _oci_push = "oci_push") +load("//oci/private:tarball.bzl", _oci_tarball = "oci_tarball") oci_tarball_rule = _oci_tarball oci_image_rule = _oci_image diff --git a/oci/extensions.bzl b/oci/extensions.bzl index 5d0dd365..02e0cd9e 100644 --- a/oci/extensions.bzl +++ b/oci/extensions.bzl @@ -1,7 +1,7 @@ "extensions for bzlmod" -load(":repositories.bzl", "oci_register_toolchains") load(":pull.bzl", "oci_pull") +load(":repositories.bzl", "oci_register_toolchains") # TODO: it sucks that the API of the oci_pull macro has to be repeated here. pull = tag_class(attrs = { diff --git a/oci/private/pull.bzl b/oci/private/pull.bzl index a45c5841..23d00c61 100644 --- a/oci/private/pull.bzl +++ b/oci/private/pull.bzl @@ -292,7 +292,7 @@ Falling back to using `curl`. See https://github.com/bazelbuild/bazel/issues/178 ) bytes = rctx.read(output) manifest = json.decode(bytes) - digest = "sha256:{}".format(util.sha256(rctx, output)) + digest = "sha256:{}".format(util.sha256(rctx, output)) return manifest, len(bytes), digest diff --git a/oci/private/util.bzl b/oci/private/util.bzl index 0662c30f..fd7d3689 100644 --- a/oci/private/util.bzl +++ b/oci/private/util.bzl @@ -112,16 +112,14 @@ if defined args ( return win_launcher - def _file_exists(rctx, path): result = rctx.execute(["stat", path]) return result.return_code == 0 - util = struct( parse_image = _parse_image, sha256 = _sha256, warning = _warning, maybe_wrap_launcher_for_windows = _maybe_wrap_launcher_for_windows, - file_exists = _file_exists + file_exists = _file_exists, ) diff --git a/oci/repositories.bzl b/oci/repositories.bzl index f916a54c..6ce3e414 100644 --- a/oci/repositories.bzl +++ b/oci/repositories.bzl @@ -1,9 +1,9 @@ """Repository rules for fetching external tools""" load("@aspect_bazel_lib//lib:repositories.bzl", "register_copy_to_directory_toolchains", "register_coreutils_toolchains", "register_jq_toolchains", "register_yq_toolchains") +load("//oci/private:auth_config_locator.bzl", "oci_auth_config_locator") load("//oci/private:toolchains_repo.bzl", "PLATFORMS", "toolchains_repo") load("//oci/private:versions.bzl", "CRANE_VERSIONS", "ZOT_VERSIONS") -load("//oci/private:auth_config_locator.bzl", "oci_auth_config_locator") LATEST_CRANE_VERSION = CRANE_VERSIONS.keys()[0] LATEST_ZOT_VERSION = ZOT_VERSIONS.keys()[0]