Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorganize file layout #72

Open
wants to merge 1 commit into
base: brian.myers/241230/misc4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ go_deps.module_override(
path = "github.com/containerd/containerd",
)

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

oci_pull(
name = "ubuntu_noble",
Expand Down
12 changes: 7 additions & 5 deletions bin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
load("//oci:toolchain.bzl", "create_compiled_oci_toolchains")

exports_files(glob(["*"]))

filegroup(
name = "bin-files",
create_compiled_oci_toolchains(name = "oci_toolchain")

pkg_files(
name = "files",
srcs = glob([
"*.bzl",
"*.bazel",
]),
visibility = ["//visibility:public"],
prefix = "bin",
visibility = ["//release:__subpackages__"],
)

create_compiled_oci_toolchains(name = "oci_toolchain")
16 changes: 11 additions & 5 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test", "update_docs")

exports_files(["docs.md"])

# Sourced from https://github.com/bazelbuild/rules_go/pull/3000
# For each doc file, generate MD from bzl_library, then perform diff test
stardoc_with_diff_test(
name = "docs",
name = "defs",
bzl_library_target = "//oci:defs",
)

stardoc_with_diff_test(
name = "providers",
bzl_library_target = "//oci:providers",
)

stardoc_with_diff_test(
name = "repositories",
bzl_library_target = "//oci:repositories",
)

update_docs()
29 changes: 1 addition & 28 deletions docs/docs.md → docs/defs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->

public API
public rules

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

Expand Down Expand Up @@ -122,30 +122,3 @@ Pushes a manifest or a list of manifests to an OCI registry.
| <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 | `{}` |


<a id="oci_pull"></a>

## oci_pull

<pre>
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>)
</pre>

**ATTRIBUTES**


| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <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 | |
| <a id="oci_pull-debug"></a>debug | Enable ocitool debug output | Boolean | optional | `False` |
| <a id="oci_pull-digest"></a>digest | - | String | required | |
| <a id="oci_pull-registry"></a>registry | - | String | required | |
| <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 | |
| <a id="oci_pull-repository"></a>repository | - | String | required | |
| <a id="oci_pull-shallow"></a>shallow | - | Boolean | optional | `True` |

**ENVIRONMENT VARIABLES**

This repository rule depends on the following environment variables:
* `OCI_CACHE_DIR`


126 changes: 126 additions & 0 deletions docs/providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->

public providers

<a id="OCIDescriptor"></a>

## OCIDescriptor

<pre>
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>)
</pre>



**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="OCIDescriptor-file"></a>file | A file object of the content this descriptor describes |
| <a id="OCIDescriptor-descriptor_file"></a>descriptor_file | A file object with the information in this provider |
| <a id="OCIDescriptor-media_type"></a>media_type | The MIME media type of the file |
| <a id="OCIDescriptor-size"></a>size | The size in bytes of the file |
| <a id="OCIDescriptor-urls"></a>urls | Additional URLs where you can find the content of file |
| <a id="OCIDescriptor-digest"></a>digest | A digest, including the algorithm, of the file |
| <a id="OCIDescriptor-annotations"></a>annotations | String map of aribtrary metadata |


<a id="OCIImageIndexManifest"></a>

## OCIImageIndexManifest

<pre>
OCIImageIndexManifest(<a href="#OCIImageIndexManifest-manifests">manifests</a>, <a href="#OCIImageIndexManifest-annotations">annotations</a>)
</pre>



**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="OCIImageIndexManifest-manifests"></a>manifests | List of descriptors |
| <a id="OCIImageIndexManifest-annotations"></a>annotations | String map of arbitrary metadata |


<a id="OCIImageManifest"></a>

## OCIImageManifest

<pre>
OCIImageManifest(<a href="#OCIImageManifest-config">config</a>, <a href="#OCIImageManifest-layers">layers</a>, <a href="#OCIImageManifest-annotations">annotations</a>)
</pre>



**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="OCIImageManifest-config"></a>config | Descriptor that points to a configuration object |
| <a id="OCIImageManifest-layers"></a>layers | List of descriptors |
| <a id="OCIImageManifest-annotations"></a>annotations | String map of arbitrary metadata |


<a id="OCILayout"></a>

## OCILayout

<pre>
OCILayout(<a href="#OCILayout-blob_index">blob_index</a>, <a href="#OCILayout-files">files</a>)
</pre>

OCI Layout

**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="OCILayout-blob_index"></a>blob_index | - |
| <a id="OCILayout-files"></a>files | - |


<a id="OCIReferenceInfo"></a>

## OCIReferenceInfo

<pre>
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>)
</pre>

Refers to any artifact represented by an OCI-like reference URI

**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="OCIReferenceInfo-registry"></a>registry | the URI where the artifact is stored |
| <a id="OCIReferenceInfo-repository"></a>repository | a namespace for an artifact |
| <a id="OCIReferenceInfo-tag"></a>tag | a organizational reference within a repository |
| <a id="OCIReferenceInfo-tag_file"></a>tag_file | a file containing the organizational reference within a repository |
| <a id="OCIReferenceInfo-digest"></a>digest | a file containing the digest of the artifact |


<a id="OCISDK"></a>

## OCISDK

<pre>
OCISDK(<a href="#OCISDK-ocitool">ocitool</a>)
</pre>

The OCI SDK

**FIELDS**


| Name | Description |
| :------------- | :------------- |
| <a id="OCISDK-ocitool"></a>ocitool | - |


31 changes: 31 additions & 0 deletions docs/repositories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->

public repository rules

<a id="oci_pull"></a>

## oci_pull

<pre>
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>)
</pre>

**ATTRIBUTES**


| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <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 | |
| <a id="oci_pull-debug"></a>debug | Enable ocitool debug output | Boolean | optional | `False` |
| <a id="oci_pull-digest"></a>digest | - | String | required | |
| <a id="oci_pull-registry"></a>registry | - | String | required | |
| <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 | |
| <a id="oci_pull-repository"></a>repository | - | String | required | |
| <a id="oci_pull-shallow"></a>shallow | - | Boolean | optional | `True` |

**ENVIRONMENT VARIABLES**

This repository rule depends on the following environment variables:
* `OCI_CACHE_DIR`


Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@com_github_datadog_rules_oci//oci:defs.bzl", "oci_push")
load("@rules_go//go:def.bzl", "go_binary", "go_library")
load(":go.bzl", "go_multiarch_image")
Expand Down Expand Up @@ -33,13 +32,3 @@ oci_push(
registry = "ghcr.io",
repository = "datadog/rules_oci/hello-world",
)

bzl_library(
name = "go",
srcs = ["go.bzl"],
visibility = ["//visibility:public"],
deps = [
"@com_github_datadog_rules_oci//oci:defs",
"@rules_go//go:def",
],
)
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions go/pkg/ociutil/bazel.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func GenerateBuildFilesHandler(handler images.HandlerFunc, layoutRoot string, pr
blobBuildFiles[digest.SHA256] = rule.EmptyFile(algoBUILDPath(layoutRoot, digest.SHA256), "")

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

ldManifest := rule.NewLoad("@com_github_datadog_rules_oci//oci:manifests.bzl")
ldManifest := rule.NewLoad("@com_github_datadog_rules_oci//oci/private/repositories:manifests.bzl")
ldManifest.Add("oci_image_index_manifest")
ldManifest.Add("oci_image_manifest")

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

ldLayout := rule.NewLoad("@com_github_datadog_rules_oci//oci:layout.bzl")
ldLayout := rule.NewLoad("@com_github_datadog_rules_oci//oci/private/repositories:layout.bzl")
ldLayout.Add("oci_layout_index")
ldLayout.Insert(layoutBuild, 0)

Expand Down
Loading
Loading