-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9a8342
commit 2872fbd
Showing
12 changed files
with
137 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,10 @@ corpus | |
artifacts | ||
coverage | ||
|
||
# OCI | ||
junit.xml | ||
report.html | ||
|
||
# Nix | ||
result | ||
result-dev | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# `hyper` example | ||
|
||
This is a mini implementation of an [Open Container Initiative (OCI) Distribution Specification](https://github.com/opencontainers/distribution-spec/blob/main/spec.md) registry. | ||
|
||
## Inspirations: | ||
- https://github.com/mcronce/oci-registry | ||
- https://github.com/Trow-Registry/trow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#![allow(clippy::unused_async)] | ||
|
||
use bytes::Bytes; | ||
use http_body_util::combinators::BoxBody; | ||
use hyper::Response; | ||
use index::index_route; | ||
use std::{convert::Infallible, future::Future, pin::Pin, sync::Arc}; | ||
use wayfind::{errors::InsertError, Parameter, Router}; | ||
|
||
pub mod index; | ||
|
||
type BoxFuture<'a> = Pin< | ||
Box< | ||
dyn Future<Output = Result<Response<BoxBody<Bytes, Infallible>>, anyhow::Error>> | ||
+ Send | ||
+ 'a, | ||
>, | ||
>; | ||
|
||
type HandlerFn = | ||
Arc<dyn for<'a> Fn(&'a str, &'a [Parameter<'_, 'a>]) -> BoxFuture<'a> + Send + Sync>; | ||
|
||
pub fn router() -> Result<Router<HandlerFn>, InsertError> { | ||
let mut router: Router<HandlerFn> = Router::new(); | ||
|
||
router.insert( | ||
"/", | ||
Arc::new(move |path, parameters| Box::pin(index_route(path, parameters))), | ||
)?; | ||
|
||
Ok(router) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use bytes::Bytes; | ||
use http_body_util::{combinators::BoxBody, BodyExt, Full}; | ||
use hyper::{header, Response}; | ||
use std::convert::Infallible; | ||
use wayfind::Parameter; | ||
|
||
pub async fn index_route( | ||
_: &'_ str, | ||
_: &'_ [Parameter<'_, '_>], | ||
) -> Result<Response<BoxBody<Bytes, Infallible>>, anyhow::Error> { | ||
let json = serde_json::json!({ | ||
"hello": "world" | ||
}); | ||
|
||
let body = Full::new(Bytes::from(json.to_string())); | ||
let response = Response::builder() | ||
.header(header::CONTENT_TYPE, "application/json") | ||
.body(body.boxed())?; | ||
|
||
Ok(response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
lib, | ||
buildGoModule, | ||
fetchFromGitHub, | ||
}: | ||
buildGoModule rec { | ||
pname = "oci-distribution-spec-conformance"; | ||
version = "1.1.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "opencontainers"; | ||
repo = "distribution-spec"; | ||
rev = "v${version}"; | ||
hash = "sha256-GL28YUwDRicxS65E7SDR/Q3tJOWN4iwgq4AGBjwVPzA="; | ||
}; | ||
|
||
sourceRoot = "source/conformance"; | ||
vendorHash = "sha256-5gn9RpjCALZB/GFjlJHDqPs2fIHl7NJr5QjPmsLnnO4="; | ||
|
||
CGO_ENABLED = 0; | ||
|
||
postInstall = '' | ||
go test -c ./... -o oci-distribution-spec-conformance | ||
mkdir -p $out/bin | ||
mv oci-distribution-spec-conformance $out/bin | ||
''; | ||
|
||
doCheck = false; | ||
|
||
meta = with lib; { | ||
description = " OCI Distribution Specification Conformance Tests"; | ||
mainProgram = "oci-distribution-spec-conformance"; | ||
homepage = "https://opencontainers.org"; | ||
changelog = "https://github.com/opencontainers/distribution-spec/releases/tag/v${version}"; | ||
license = licenses.asl20; | ||
platforms = platforms.all; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters