Skip to content

Commit

Permalink
Upgrade to bazel 7.2.1 (#60)
Browse files Browse the repository at this point in the history
* Remove suggestion to use rules_oci as a library (we don't want to support that usage)
* Define AnnotationArtifactDescription ourselves, as it's been removed from ocispec
* Remove unused post_push_hooks
* Migrate to bazel 7.2.1, updating dependencies too
* bzl run //docs:update
* Use bzlmod names instead of legacy workspace names
* Update github.com/docker/docker to resolve CVE
  • Loading branch information
guyboltonking authored Aug 19, 2024
1 parent 461b15b commit b1d616f
Show file tree
Hide file tree
Showing 34 changed files with 2,680 additions and 2,688 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.0
7.2.1
25 changes: 3 additions & 22 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//oci:toolchain.bzl", "oci_local_toolchain")
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("//oci:toolchain.bzl", "oci_local_toolchain")

# gazelle:prefix github.com/DataDog/rules_oci
# gazelle:go_naming_convention go_default_library
# gazelle:lang go

bzl_library(
name = "repositories",
srcs = ["repositories.bzl"],
visibility = ["//visibility:public"],
deps = ["@bazel_gazelle//:deps"],
)

oci_local_toolchain(
name = "oci_local_toolchain",
)
Expand All @@ -30,20 +22,9 @@ gazelle_binary(
],
)

gazelle(
name = "gazelle-update-repos",
args = [
"-from_file=go.work",
"-to_macro=repositories.bzl%go_repositories",
"-prune=true",
"-build_file_proto_mode=disable",
],
command = "update-repos",
)

alias(
name = "go",
actual = "@go_sdk//:bin/go",
actual = "@rules_go//go",
)

write_source_files(
Expand Down
52 changes: 52 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module(
name = "rules_oci",
repo_name = "com_github_datadog_rules_oci",
)

bazel_dep(name = "aspect_bazel_lib", version = "2.7.3")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "bazel_skylib_gazelle_plugin", dev_dependency = True, version = "1.6.1")
bazel_dep(name = "gazelle", version = "0.36.0")
bazel_dep(name = "rules_go", version = "0.47.1")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "stardoc", version = "0.6.2")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")

go_sdk.download(version = "1.22.5")

go_sdk.host()

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")

go_deps.from_file(go_mod = "//:go.mod")

use_repo(
go_deps,
#"com_github_bazelbuild_bazel_gazelle",
"com_github_blakesmith_ar",
"com_github_containerd_containerd",
"com_github_docker_docker_credential_helpers",
"com_github_mitchellh_go_homedir",
"com_github_opencontainers_go_digest",
"com_github_opencontainers_image_spec",
"com_github_sirupsen_logrus",
"com_github_stretchr_testify",
"com_github_urfave_cli_v2",
"land_oras_oras_go",
"org_golang_x_sync",
)

oci_pull = use_repo_rule("//oci:defs.bzl", "oci_pull")

oci_pull(
name = "ubuntu_focal",
# Latest at "focal" tag
digest = "sha256:9d6a8699fb5c9c39cf08a0871bd6219f0400981c570894cd8cbea30d3424a31f",
registry = "ghcr.io",
repository = "datadog/rules_oci/ubuntu",
)

register_toolchains(
"@com_github_datadog_rules_oci//:oci_local_toolchain",
)
2,160 changes: 2,160 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ manifests, image indexes (multi-arch images) and custom artifacts

In addition to Bazel rules, we offer many helpers for interacting with OCI
artifacts under the `go/pkg` directory and a CLI tool for creating new OCI
artifacts. You can add the Go library as a dependency by running `go get github.com/DataDog/rules_oci/go@latest`.
artifacts.

`rules_oci` makes an effort to support Docker media types, but there is no
guarantee of long-term support. Most CRI support the OCI types or there are
Expand Down Expand Up @@ -93,7 +93,7 @@ dependencies.

#### Updating dependencies

Run `bazel run :go -- get DEPENDENCY && bazel run :gazelle-update-repos`
Run `bzl run //:go -- get DEPENDENCY`

#### Tests

Expand Down
150 changes: 0 additions & 150 deletions WORKSPACE

This file was deleted.

6 changes: 1 addition & 5 deletions bin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("//oci:toolchain.bzl", "create_compiled_oci_toolchains")
load("@oci_push_hooks//:defs.bzl", "POST_PUSH_HOOKS")

exports_files(glob(["*"]))

Expand All @@ -12,7 +11,4 @@ filegroup(
visibility = ["//visibility:public"],
)

create_compiled_oci_toolchains(
name = "oci_toolchain",
post_push_hooks = POST_PUSH_HOOKS,
)
create_compiled_oci_toolchains(name = "oci_toolchain")
Loading

0 comments on commit b1d616f

Please sign in to comment.