Skip to content

Commit e48bbc7

Browse files
authored
Add buildifier target and buildifier tests (#64)
1 parent 7fcb47e commit e48bbc7

17 files changed

+223
-17
lines changed

BUILD.bazel

+16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
2+
load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
23
load("@gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
34
load("//oci:toolchain.bzl", "oci_local_toolchain")
45

@@ -10,6 +11,21 @@ oci_local_toolchain(
1011
name = "oci_local_toolchain",
1112
)
1213

14+
buildifier(
15+
name = "buildifier",
16+
exclude_patterns = ["./.git/*"],
17+
lint_mode = "warn",
18+
mode = "fix",
19+
)
20+
21+
buildifier_test(
22+
name = "buildifier_test",
23+
exclude_patterns = ["./.git/*"],
24+
lint_mode = "warn",
25+
no_sandbox = True,
26+
workspace = "//:WORKSPACE",
27+
)
28+
1329
gazelle(
1430
name = "gazelle",
1531
gazelle = ":default_gazelle_binary",

MODULE.bazel

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,20 @@ module(
55

66
bazel_dep(name = "aspect_bazel_lib", version = "2.7.3")
77
bazel_dep(name = "bazel_skylib", version = "1.6.1")
8-
bazel_dep(name = "bazel_skylib_gazelle_plugin", dev_dependency = True, version = "1.6.1")
98
bazel_dep(name = "gazelle", version = "0.38.0")
109
bazel_dep(name = "rules_go", version = "0.47.1")
1110
bazel_dep(name = "rules_pkg", version = "0.10.1")
1211
bazel_dep(name = "stardoc", version = "0.6.2")
1312

14-
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
13+
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.6.1", dev_dependency = True)
14+
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True)
1515

16+
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
1617
go_sdk.download(version = "1.22.5")
17-
1818
go_sdk.host()
1919

2020
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
21-
2221
go_deps.from_file(go_mod = "//:go.mod")
23-
2422
use_repo(
2523
go_deps,
2624
"com_github_blakesmith_ar",
@@ -49,7 +47,6 @@ use_repo(
4947
"org_golang_x_sync",
5048
"org_golang_x_sys",
5149
)
52-
5350
go_deps.module_override(
5451
patch_strip = 1,
5552
patches = [

MODULE.bazel.lock

+152
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORKSPACE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
workspace(name = "com_github_datadog_rules_oci")

docs/docs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
22

3-
3+
public API
44

55
<a id="oci_image"></a>
66

oci/blob.bzl

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
""" blob """
2+
13
load("@com_github_datadog_rules_oci//oci:providers.bzl", "OCIDescriptor")
24

35
def _oci_blob_impl(ctx):

oci/debug_flag.bzl

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
DebugInfo = provider(fields = ["debug"])
1+
""" debug_flag """
2+
3+
DebugInfo = provider(
4+
"DebugInfo",
5+
fields = ["debug"],
6+
)
27

38
def _debug_flag_impl(ctx):
49
return [DebugInfo(debug = ctx.build_setting_value)]

oci/defs.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
""" public API """
2+
3+
load(":image.bzl", _oci_image = "oci_image", _oci_image_index = "oci_image_index", _oci_image_layer = "oci_image_layer")
14
load(":pull.bzl", _oci_pull = "oci_pull")
25
load(":push.bzl", _oci_push = "oci_push")
3-
load(":image.bzl", _oci_image = "oci_image", _oci_image_index = "oci_image_index", _oci_image_layer = "oci_image_layer")
46

57
oci_pull = _oci_pull
68
oci_push = _oci_push

oci/image.bzl

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
""" image """
2+
13
load("@com_github_datadog_rules_oci//oci:providers.bzl", "OCIDescriptor", "OCILayout")
24

5+
# buildifier: disable=function-docstring
36
def get_descriptor_file(ctx, desc):
47
if hasattr(desc, "descriptor_file"):
58
return desc.descriptor_file
@@ -249,7 +252,7 @@ oci_image = rule(
249252
doc = "Used to extract a manifest from base if base is an index",
250253
),
251254
"env": attr.string_list(
252-
doc = """Entries are in the format of `VARNAME=VARVALUE`. These values act as defaults and
255+
doc = """Entries are in the format of `VARNAME=VARVALUE`. These values act as defaults and
253256
are merged with any specified when creating a container.""",
254257
),
255258
"layers": attr.label_list(

oci/layout.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
load("@com_github_datadog_rules_oci//oci:providers.bzl", "OCIDescriptor", "OCIImageIndexManifest", "OCILayout")
1+
""" layout """
2+
3+
load("@com_github_datadog_rules_oci//oci:providers.bzl", "OCIDescriptor", "OCILayout")
24

35
def _oci_layout_index_impl(ctx):
46
blobs_map = {}

oci/manifests.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
""" manifests """
2+
13
load("@com_github_datadog_rules_oci//oci:providers.bzl", "OCIDescriptor", "OCIImageIndexManifest", "OCIImageManifest", "OCILayout")
24

35
def _oci_image_manifest_impl(ctx):
46
return [OCIImageManifest(
57
config = ctx.attr.config[OCIDescriptor],
6-
layers = [l[OCIDescriptor] for l in ctx.attr.layers],
8+
layers = [layer[OCIDescriptor] for layer in ctx.attr.layers],
79
annotations = ctx.attr.annotations,
810
), ctx.attr.layout[OCILayout], ctx.attr.descriptor[OCIDescriptor]]
911

oci/providers.bzl

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
""" providers """
2+
13
OCIReferenceInfo = provider(
24
doc = "Refers to any artifact represented by an OCI-like reference URI",
35
fields = {
@@ -9,13 +11,16 @@ OCIReferenceInfo = provider(
911
},
1012
)
1113

14+
# buildifier: disable=name-conventions
1215
OCILayout = provider(
16+
"OCI Layout",
1317
fields = {
1418
"blob_index": "",
1519
"files": "",
1620
},
1721
)
1822

23+
# buildifier: disable=name-conventions
1924
OCIDescriptor = provider(
2025
doc = "",
2126
fields = {
@@ -29,6 +34,7 @@ OCIDescriptor = provider(
2934
},
3035
)
3136

37+
# buildifier: disable=name-conventions
3238
OCIImageManifest = provider(
3339
doc = "",
3440
fields = {
@@ -38,6 +44,7 @@ OCIImageManifest = provider(
3844
},
3945
)
4046

47+
# buildifier: disable=name-conventions
4148
OCIImageIndexManifest = provider(
4249
doc = "",
4350
fields = {
@@ -46,6 +53,7 @@ OCIImageIndexManifest = provider(
4653
},
4754
)
4855

56+
# buildifier: disable=name-conventions
4957
OCIPlatform = provider(
5058
doc = "Platform describes the platform which the image in the manifest runs on",
5159
fields = {

oci/pull.bzl

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
""" pull """
2+
13
# A directory to store cached OCI artifacts
24
# TODO(griffin) currently not used, but going to start depending on this for
35
# integration into the bzl wrapper.
@@ -12,6 +14,7 @@ def failout(msg, cmd_result):
1214
.format(msg = msg, stdout = cmd_result.stdout, stderr = cmd_result.stderr),
1315
)
1416

17+
# buildifier: disable=function-docstring
1518
def pull(rctx, layout_root, repository, digest, registry = "", shallow = False, debug = False):
1619
cmd = [
1720
rctx.path(_repo_toolchain(rctx, "ocitool")),

oci/push.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
""" push """
2+
13
load("@aspect_bazel_lib//lib:stamping.bzl", "STAMP_ATTRS", "maybe_stamp")
2-
load("@com_github_datadog_rules_oci//oci:providers.bzl", "OCIDescriptor", "OCILayout", "OCIReferenceInfo")
34
load("@com_github_datadog_rules_oci//oci:debug_flag.bzl", "DebugInfo")
5+
load("@com_github_datadog_rules_oci//oci:providers.bzl", "OCIDescriptor", "OCILayout", "OCIReferenceInfo")
46

57
def _oci_push_impl(ctx):
68
toolchain = ctx.toolchains["@com_github_datadog_rules_oci//oci:toolchain"]

0 commit comments

Comments
 (0)