sigstore/registry/
mod.rs

1//
2// Copyright 2021 The Sigstore Authors.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16pub mod config;
17pub use config::*;
18
19#[cfg(feature = "cosign")]
20pub(crate) mod oci_client;
21#[cfg(feature = "cosign")]
22pub(crate) use oci_client::*;
23
24#[cfg(feature = "cosign")]
25pub mod oci_reference;
26#[cfg(feature = "cosign")]
27pub use oci_reference::OciReference;
28
29#[cfg(all(feature = "cosign", feature = "cached-client"))]
30pub(crate) mod oci_caching_client;
31#[cfg(all(feature = "cosign", feature = "cached-client"))]
32pub(crate) use oci_caching_client::*;
33
34use crate::errors::Result;
35
36use async_trait::async_trait;
37
38use ::oci_client as oci_client_dep;
39
40/// Workaround to ensure the `Send + Sync` supertraits are
41/// required by ClientCapabilities only when the target
42/// architecture is NOT wasm32.
43///
44/// This intermediate trait has been created to avoid
45/// to define ClientCapabilities twice (one with `#[cfg(target_arch = "wasm32")]`,
46/// the other with `#[cfg(not(target_arch = "wasm32"))]`
47#[cfg(not(target_arch = "wasm32"))]
48pub(crate) trait ClientCapabilitiesDeps: Send + Sync {}
49
50/// Workaround to ensure the `Send + Sync` supertraits are
51/// required by ClientCapabilities only when the target
52/// architecture is NOT wasm32.
53///
54/// This intermediate trait has been created to avoid
55/// to define ClientCapabilities twice (one with `#[cfg(target_arch = "wasm32")]`,
56/// the other with `#[cfg(not(target_arch = "wasm32"))]`
57#[cfg(target_arch = "wasm32")]
58pub(crate) trait ClientCapabilitiesDeps {}
59
60#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
61#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
62/// Capabilities that are expected to be provided by a registry client
63pub(crate) trait ClientCapabilities: ClientCapabilitiesDeps {
64    async fn fetch_manifest_digest(
65        &mut self,
66        image: &oci_client_dep::Reference,
67        auth: &oci_client_dep::secrets::RegistryAuth,
68    ) -> Result<String>;
69
70    async fn pull(
71        &mut self,
72        image: &oci_client_dep::Reference,
73        auth: &oci_client_dep::secrets::RegistryAuth,
74        accepted_media_types: Vec<&str>,
75    ) -> Result<oci_client_dep::client::ImageData>;
76
77    async fn pull_manifest(
78        &mut self,
79        image: &oci_client_dep::Reference,
80        auth: &oci_client_dep::secrets::RegistryAuth,
81    ) -> Result<(oci_client_dep::manifest::OciManifest, String)>;
82
83    async fn push(
84        &mut self,
85        image_ref: &oci_client_dep::Reference,
86        layers: &[oci_client_dep::client::ImageLayer],
87        config: oci_client_dep::client::Config,
88        auth: &oci_client_dep::secrets::RegistryAuth,
89        manifest: Option<oci_client_dep::manifest::OciImageManifest>,
90    ) -> Result<oci_client_dep::client::PushResponse>;
91}