Skip to content

Commit 628605a

Browse files
committed
reorganize file layout
1 parent 031409e commit 628605a

28 files changed

+363
-247
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ go_deps.module_override(
4848
path = "github.com/containerd/containerd",
4949
)
5050

51-
oci_pull = use_repo_rule("//oci:defs.bzl", "oci_pull")
51+
oci_pull = use_repo_rule("//oci:repositories.bzl", "oci_pull")
5252

5353
oci_pull(
5454
name = "ubuntu_noble",

bin/BUILD.bazel

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
12
load("//oci:toolchain.bzl", "create_compiled_oci_toolchains")
23

34
exports_files(glob(["*"]))
45

5-
filegroup(
6-
name = "bin-files",
6+
create_compiled_oci_toolchains(name = "oci_toolchain")
7+
8+
pkg_files(
9+
name = "files",
710
srcs = glob([
811
"*.bzl",
912
"*.bazel",
1013
]),
11-
visibility = ["//visibility:public"],
14+
prefix = "bin",
15+
visibility = ["//release:__subpackages__"],
1216
)
13-
14-
create_compiled_oci_toolchains(name = "oci_toolchain")

docs/BUILD.bazel

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test", "update_docs")
22

3-
exports_files(["docs.md"])
4-
5-
# Sourced from https://github.com/bazelbuild/rules_go/pull/3000
6-
# For each doc file, generate MD from bzl_library, then perform diff test
73
stardoc_with_diff_test(
8-
name = "docs",
4+
name = "defs",
95
bzl_library_target = "//oci:defs",
106
)
117

8+
stardoc_with_diff_test(
9+
name = "providers",
10+
bzl_library_target = "//oci:providers",
11+
)
12+
13+
stardoc_with_diff_test(
14+
name = "repositories",
15+
bzl_library_target = "//oci:repositories",
16+
)
17+
1218
update_docs()

docs/docs.md renamed to docs/defs.md

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

3-
public API
3+
public rules
44

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

@@ -122,30 +122,3 @@ Pushes a manifest or a list of manifests to an OCI registry.
122122
| <a id="oci_push-x_meta_headers"></a>x_meta_headers | (optional) A list of key/values to to be sent to the registry as headers with an X-Meta- prefix. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` |
123123

124124

125-
<a id="oci_pull"></a>
126-
127-
## oci_pull
128-
129-
<pre>
130-
oci_pull(<a href="#oci_pull-name">name</a>, <a href="#oci_pull-debug">debug</a>, <a href="#oci_pull-digest">digest</a>, <a href="#oci_pull-registry">registry</a>, <a href="#oci_pull-repo_mapping">repo_mapping</a>, <a href="#oci_pull-repository">repository</a>, <a href="#oci_pull-shallow">shallow</a>)
131-
</pre>
132-
133-
**ATTRIBUTES**
134-
135-
136-
| Name | Description | Type | Mandatory | Default |
137-
| :------------- | :------------- | :------------- | :------------- | :------------- |
138-
| <a id="oci_pull-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
139-
| <a id="oci_pull-debug"></a>debug | Enable ocitool debug output | Boolean | optional | `False` |
140-
| <a id="oci_pull-digest"></a>digest | - | String | required | |
141-
| <a id="oci_pull-registry"></a>registry | - | String | required | |
142-
| <a id="oci_pull-repo_mapping"></a>repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<br><br>For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).<br><br>This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | |
143-
| <a id="oci_pull-repository"></a>repository | - | String | required | |
144-
| <a id="oci_pull-shallow"></a>shallow | - | Boolean | optional | `True` |
145-
146-
**ENVIRONMENT VARIABLES**
147-
148-
This repository rule depends on the following environment variables:
149-
* `OCI_CACHE_DIR`
150-
151-

docs/providers.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2+
3+
public providers
4+
5+
<a id="OCIDescriptor"></a>
6+
7+
## OCIDescriptor
8+
9+
<pre>
10+
OCIDescriptor(<a href="#OCIDescriptor-file">file</a>, <a href="#OCIDescriptor-descriptor_file">descriptor_file</a>, <a href="#OCIDescriptor-media_type">media_type</a>, <a href="#OCIDescriptor-size">size</a>, <a href="#OCIDescriptor-urls">urls</a>, <a href="#OCIDescriptor-digest">digest</a>, <a href="#OCIDescriptor-annotations">annotations</a>)
11+
</pre>
12+
13+
14+
15+
**FIELDS**
16+
17+
18+
| Name | Description |
19+
| :------------- | :------------- |
20+
| <a id="OCIDescriptor-file"></a>file | A file object of the content this descriptor describes |
21+
| <a id="OCIDescriptor-descriptor_file"></a>descriptor_file | A file object with the information in this provider |
22+
| <a id="OCIDescriptor-media_type"></a>media_type | The MIME media type of the file |
23+
| <a id="OCIDescriptor-size"></a>size | The size in bytes of the file |
24+
| <a id="OCIDescriptor-urls"></a>urls | Additional URLs where you can find the content of file |
25+
| <a id="OCIDescriptor-digest"></a>digest | A digest, including the algorithm, of the file |
26+
| <a id="OCIDescriptor-annotations"></a>annotations | String map of aribtrary metadata |
27+
28+
29+
<a id="OCIImageIndexManifest"></a>
30+
31+
## OCIImageIndexManifest
32+
33+
<pre>
34+
OCIImageIndexManifest(<a href="#OCIImageIndexManifest-manifests">manifests</a>, <a href="#OCIImageIndexManifest-annotations">annotations</a>)
35+
</pre>
36+
37+
38+
39+
**FIELDS**
40+
41+
42+
| Name | Description |
43+
| :------------- | :------------- |
44+
| <a id="OCIImageIndexManifest-manifests"></a>manifests | List of descriptors |
45+
| <a id="OCIImageIndexManifest-annotations"></a>annotations | String map of arbitrary metadata |
46+
47+
48+
<a id="OCIImageManifest"></a>
49+
50+
## OCIImageManifest
51+
52+
<pre>
53+
OCIImageManifest(<a href="#OCIImageManifest-config">config</a>, <a href="#OCIImageManifest-layers">layers</a>, <a href="#OCIImageManifest-annotations">annotations</a>)
54+
</pre>
55+
56+
57+
58+
**FIELDS**
59+
60+
61+
| Name | Description |
62+
| :------------- | :------------- |
63+
| <a id="OCIImageManifest-config"></a>config | Descriptor that points to a configuration object |
64+
| <a id="OCIImageManifest-layers"></a>layers | List of descriptors |
65+
| <a id="OCIImageManifest-annotations"></a>annotations | String map of arbitrary metadata |
66+
67+
68+
<a id="OCILayout"></a>
69+
70+
## OCILayout
71+
72+
<pre>
73+
OCILayout(<a href="#OCILayout-blob_index">blob_index</a>, <a href="#OCILayout-files">files</a>)
74+
</pre>
75+
76+
OCI Layout
77+
78+
**FIELDS**
79+
80+
81+
| Name | Description |
82+
| :------------- | :------------- |
83+
| <a id="OCILayout-blob_index"></a>blob_index | - |
84+
| <a id="OCILayout-files"></a>files | - |
85+
86+
87+
<a id="OCIReferenceInfo"></a>
88+
89+
## OCIReferenceInfo
90+
91+
<pre>
92+
OCIReferenceInfo(<a href="#OCIReferenceInfo-registry">registry</a>, <a href="#OCIReferenceInfo-repository">repository</a>, <a href="#OCIReferenceInfo-tag">tag</a>, <a href="#OCIReferenceInfo-tag_file">tag_file</a>, <a href="#OCIReferenceInfo-digest">digest</a>)
93+
</pre>
94+
95+
Refers to any artifact represented by an OCI-like reference URI
96+
97+
**FIELDS**
98+
99+
100+
| Name | Description |
101+
| :------------- | :------------- |
102+
| <a id="OCIReferenceInfo-registry"></a>registry | the URI where the artifact is stored |
103+
| <a id="OCIReferenceInfo-repository"></a>repository | a namespace for an artifact |
104+
| <a id="OCIReferenceInfo-tag"></a>tag | a organizational reference within a repository |
105+
| <a id="OCIReferenceInfo-tag_file"></a>tag_file | a file containing the organizational reference within a repository |
106+
| <a id="OCIReferenceInfo-digest"></a>digest | a file containing the digest of the artifact |
107+
108+
109+
<a id="OCISDK"></a>
110+
111+
## OCISDK
112+
113+
<pre>
114+
OCISDK(<a href="#OCISDK-ocitool">ocitool</a>)
115+
</pre>
116+
117+
The OCI SDK
118+
119+
**FIELDS**
120+
121+
122+
| Name | Description |
123+
| :------------- | :------------- |
124+
| <a id="OCISDK-ocitool"></a>ocitool | - |
125+
126+

docs/repositories.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2+
3+
public repository rules
4+
5+
<a id="oci_pull"></a>
6+
7+
## oci_pull
8+
9+
<pre>
10+
oci_pull(<a href="#oci_pull-name">name</a>, <a href="#oci_pull-debug">debug</a>, <a href="#oci_pull-digest">digest</a>, <a href="#oci_pull-registry">registry</a>, <a href="#oci_pull-repo_mapping">repo_mapping</a>, <a href="#oci_pull-repository">repository</a>, <a href="#oci_pull-shallow">shallow</a>)
11+
</pre>
12+
13+
**ATTRIBUTES**
14+
15+
16+
| Name | Description | Type | Mandatory | Default |
17+
| :------------- | :------------- | :------------- | :------------- | :------------- |
18+
| <a id="oci_pull-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
19+
| <a id="oci_pull-debug"></a>debug | Enable ocitool debug output | Boolean | optional | `False` |
20+
| <a id="oci_pull-digest"></a>digest | - | String | required | |
21+
| <a id="oci_pull-registry"></a>registry | - | String | required | |
22+
| <a id="oci_pull-repo_mapping"></a>repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<br><br>For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).<br><br>This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | |
23+
| <a id="oci_pull-repository"></a>repository | - | String | required | |
24+
| <a id="oci_pull-shallow"></a>shallow | - | Boolean | optional | `True` |
25+
26+
**ENVIRONMENT VARIABLES**
27+
28+
This repository rule depends on the following environment variables:
29+
* `OCI_CACHE_DIR`
30+
31+
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
21
load("@com_github_datadog_rules_oci//oci:defs.bzl", "oci_push")
32
load("@rules_go//go:def.bzl", "go_binary", "go_library")
43
load(":go.bzl", "go_multiarch_image")
@@ -33,13 +32,3 @@ oci_push(
3332
registry = "ghcr.io",
3433
repository = "datadog/rules_oci/hello-world",
3534
)
36-
37-
bzl_library(
38-
name = "go",
39-
srcs = ["go.bzl"],
40-
visibility = ["//visibility:public"],
41-
deps = [
42-
"@com_github_datadog_rules_oci//oci:defs",
43-
"@rules_go//go:def",
44-
],
45-
)

go/pkg/ociutil/bazel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ func GenerateBuildFilesHandler(handler images.HandlerFunc, layoutRoot string, pr
2626
blobBuildFiles[digest.SHA256] = rule.EmptyFile(algoBUILDPath(layoutRoot, digest.SHA256), "")
2727

2828
// Add load statements for all of the oci_* rules
29-
ldBlob := rule.NewLoad("@com_github_datadog_rules_oci//oci:blob.bzl")
29+
ldBlob := rule.NewLoad("@com_github_datadog_rules_oci//oci/private/repositories:blob.bzl")
3030
ldBlob.Add("oci_blob")
3131

32-
ldManifest := rule.NewLoad("@com_github_datadog_rules_oci//oci:manifests.bzl")
32+
ldManifest := rule.NewLoad("@com_github_datadog_rules_oci//oci/private/repositories:manifests.bzl")
3333
ldManifest.Add("oci_image_index_manifest")
3434
ldManifest.Add("oci_image_manifest")
3535

@@ -42,7 +42,7 @@ func GenerateBuildFilesHandler(handler images.HandlerFunc, layoutRoot string, pr
4242
// Top level build file for used as an index of the entire layout
4343
layoutBuild := rule.EmptyFile(filepath.Join(layoutRoot, "BUILD.bazel"), "")
4444

45-
ldLayout := rule.NewLoad("@com_github_datadog_rules_oci//oci:layout.bzl")
45+
ldLayout := rule.NewLoad("@com_github_datadog_rules_oci//oci/private/repositories:layout.bzl")
4646
ldLayout.Add("oci_layout_index")
4747
ldLayout.Insert(layoutBuild, 0)
4848

0 commit comments

Comments
 (0)