Skip to content

Commit

Permalink
chore(fmt): pre-commit[buildifier]
Browse files Browse the repository at this point in the history
  • Loading branch information
hongwenchen committed Sep 25, 2023
1 parent 9708852 commit 3310a6a
Show file tree
Hide file tree
Showing 33 changed files with 63 additions and 63 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
3 changes: 2 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion cosign/defs.bzl
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion e2e/auth/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 5 additions & 6 deletions e2e/auth/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
"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(
module_name = "rules_oci",
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")
use_repo(oci, "empty_image")
2 changes: 1 addition & 1 deletion e2e/crane_as_registry/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions e2e/crane_as_registry/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
2 changes: 1 addition & 1 deletion e2e/custom_registry/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion e2e/custom_registry/registry/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion e2e/smoke/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -11,7 +13,6 @@ local_path_override(
)

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")

oci.pull(
name = "distroless_base",
digest = "sha256:ccaef5ee2f1850270d453fdf700a5392534f8d1a8ca2acda391fbb6a06b81c86",
Expand All @@ -21,5 +22,4 @@ oci.pull(
"linux/arm64",
],
)

use_repo(oci, "distroless_base")
4 changes: 2 additions & 2 deletions e2e/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -45,4 +45,4 @@ oci_pull(
"linux/amd64",
"linux/arm64",
],
)
)
4 changes: 2 additions & 2 deletions e2e/wasm/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"])

Expand Down
2 changes: 1 addition & 1 deletion examples/attest/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions examples/attest_external/BUILD.template
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion examples/empty_base/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions examples/env/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions examples/env_inheritance/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions examples/labels/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/location_expansion/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions examples/multi_arch/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
4 changes: 2 additions & 2 deletions examples/push/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/repo_tags/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/sign/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions examples/sign_external/BUILD.template
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
visibility = ["//visibility:public"],
)
5 changes: 2 additions & 3 deletions examples/various/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -8,10 +8,9 @@ oci_image(
os = "linux",
)


build_test(
name = "test",
targets = [
":imagE",
],
)
)
8 changes: 4 additions & 4 deletions oci/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion oci/extensions.bzl
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion oci/private/pull.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions oci/private/util.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
2 changes: 1 addition & 1 deletion oci/repositories.bzl
Original file line number Diff line number Diff line change
@@ -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]
Expand Down

0 comments on commit 3310a6a

Please sign in to comment.