Skip to content

Commit

Permalink
feat!: Petname resolution and synchronization in spheres and gateways (
Browse files Browse the repository at this point in the history
  • Loading branch information
cdata committed Mar 10, 2023
1 parent a80db01 commit f7ddfa7
Show file tree
Hide file tree
Showing 124 changed files with 4,347 additions and 2,585 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/container_images.yaml
Expand Up @@ -16,6 +16,7 @@ jobs:
name: 'Determine image tags'
outputs:
tags: ${{ steps.determine-image-tags.outputs.tags }}
concurrency: ${{ steps.determine-image-tags.outputs.concurrency }}
runs-on: ubuntu-latest
steps:
- id: determine-image-tags
Expand All @@ -24,14 +25,18 @@ jobs:
PR_NUMBER: ${{ github.event.number }}
CUSTOM_TAG: ${{ inputs.image-tag }}
run: |
concurrency="docker-build"
tags=()
if [[ "$EVENT_NAME" == "pull_request" ]]; then
tags+=("pr-$PR_NUMBER")
concurrency="$concurrency-pr-$PR_NUMBER"
fi
if [[ "$IMAGE_TAG" != "" ]]; then
tags+=("$IMAGE_TAG")
concurrency="$concurrency-$IMAGE_TAG"
fi
tags_out=""
Expand All @@ -45,22 +50,24 @@ jobs:
done
echo "TAGS: $tags_out"
echo "CONCURRENCY: $concurrency"
echo -n "tags=[$tags_out]" >> $GITHUB_OUTPUT
echo "tags=[$tags_out]" >> $GITHUB_OUTPUT
echo "concurrency=\"$concurrency\"" >> $GITHUB_OUTPUT
build-and-push:
name: 'Build and push'
runs-on: ubuntu-latest
needs: ['determine-image-tags']
concurrency: 'docker-build'
concurrency: ${{ needs.determine-image-tags.outputs.concurrency }}
permissions:
contents: 'read'
id-token: 'write'
strategy:
matrix:
image:
- name: 'orb'
file: 'images/orb/Dockerfile'
file: 'images/orb/Dockerfile'
- name: 'orb-ns'
file: 'images/orb-ns/Dockerfile'
tag: ${{ fromJSON(needs.determine-image-tags.outputs.tags) }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yaml
Expand Up @@ -29,10 +29,11 @@ jobs:
steps.release.outputs['rust/noosphere-cli--release_created'] ||
steps.release.outputs['rust/noosphere-collections--release_created'] ||
steps.release.outputs['rust/noosphere-core--release_created'] ||
steps.release.outputs['rust/noosphere-fs--release_created'] ||
steps.release.outputs['rust/noosphere-gateway--release_created'] ||
steps.release.outputs['rust/noosphere-ipfs--release_created'] ||
steps.release.outputs['rust/noosphere-into--release_created'] ||
steps.release.outputs['rust/noosphere-ns--release_created'] ||
steps.release.outputs['rust/noosphere-sphere--release_created'] ||
steps.release.outputs['rust/noosphere-storage--release_created'] }}
steps:
- uses: chainguard-dev/actions/setup-gitsign@main
Expand Down
1 change: 0 additions & 1 deletion .release-please-manifest.json
Expand Up @@ -6,7 +6,6 @@
"rust/noosphere-into": "0.4.5",
"rust/noosphere-ns": "0.4.3",
"rust/noosphere-storage": "0.4.2",
"rust/noosphere-fs": "0.5.3",
"rust/noosphere": "0.6.3",
"rust/noosphere-ipfs": "0.1.2"
}
1 change: 1 addition & 0 deletions .vscode/settings.json
Expand Up @@ -7,3 +7,4 @@
"async-trait": ["async_trait"]
}
}

77 changes: 46 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
@@ -1,16 +1,16 @@
[workspace]
members = [
"rust/noosphere-storage",
"rust/noosphere",
"rust/noosphere-api",
"rust/noosphere-cli",
"rust/noosphere-collections",
"rust/noosphere-core",
"rust/noosphere-api",
"rust/noosphere-fs",
"rust/noosphere-gateway",
"rust/noosphere-into",
"rust/noosphere-ipfs",
"rust/noosphere-cli",
"rust/noosphere-ns",
"rust/noosphere"
"rust/noosphere-sphere",
"rust/noosphere-storage",
]

# See: https://github.com/rust-lang/rust/issues/90148#issuecomment-949194352
Expand Down
2 changes: 1 addition & 1 deletion release-please-config.json
Expand Up @@ -11,11 +11,11 @@
},
"rust/noosphere-collections": {},
"rust/noosphere-core": {},
"rust/noosphere-fs": {},
"rust/noosphere-gateway": {},
"rust/noosphere-ipfs": {},
"rust/noosphere-into": {},
"rust/noosphere-ns": {},
"rust/noosphere-sphere": {},
"rust/noosphere-storage": {},
"rust/noosphere": {
"draft": true
Expand Down
1 change: 1 addition & 0 deletions rust/noosphere-api/Cargo.toml
Expand Up @@ -20,6 +20,7 @@ readme = "README.md"

[dependencies]
anyhow = "^1"
thiserror = "1.0.38"
cid = "~0.9"
url = "^2"
serde = "^1"
Expand Down
40 changes: 38 additions & 2 deletions rust/noosphere-api/src/data.rs
Expand Up @@ -4,10 +4,12 @@ use anyhow::{anyhow, Result};
use cid::Cid;
use noosphere_core::{
authority::{SphereAction, SphereReference, SPHERE_SEMANTICS},
data::{Bundle, Did},
data::{Bundle, Did, Jwt},
};
use noosphere_storage::{base64_decode, base64_encode};
use reqwest::StatusCode;
use serde::{Deserialize, Deserializer, Serialize};
use thiserror::Error;
use ucan::{
capability::{Capability, Resource, With},
chain::ProofChain,
Expand Down Expand Up @@ -81,7 +83,7 @@ pub enum FetchResponse {
#[derive(Debug, Serialize, Deserialize)]
pub struct PushBody {
/// The DID of the local sphere whose revisions are being pushed
pub sphere: String,
pub sphere: Did,
/// The base revision represented by the payload being pushed; if the
/// entire history is being pushed, then this should be None
pub base: Option<Cid>,
Expand All @@ -90,6 +92,8 @@ pub struct PushBody {
/// A bundle of all the blocks needed to hydrate the revisions from the
/// base to the tip of history as represented by this payload
pub blocks: Bundle,
/// An optional name record to publish to the Noosphere Name System
pub name_record: Option<Jwt>,
}

/// The possible responses from the "push" API route
Expand All @@ -111,6 +115,38 @@ pub enum PushResponse {
NoChange,
}

#[derive(Error, Debug)]
pub enum PushError {
#[error("Pushed history conflicts with canonical history")]
Conflict,
#[error("Missing some implied history")]
MissingHistory,
#[error("Replica is up to date")]
UpToDate,
#[error("Internal error")]
Internal(anyhow::Error),
}

impl From<anyhow::Error> for PushError {
fn from(value: anyhow::Error) -> Self {
PushError::Internal(value)
}
}

impl From<PushError> for StatusCode {
fn from(error: PushError) -> Self {
match error {
PushError::Conflict => StatusCode::CONFLICT,
PushError::MissingHistory => StatusCode::UNPROCESSABLE_ENTITY,
PushError::UpToDate => StatusCode::BAD_REQUEST,
PushError::Internal(error) => {
error!("Internal: {:?}", error);
StatusCode::INTERNAL_SERVER_ERROR
}
}
}
}

/// The response from the "identify" API route; this is a signed response that
/// allows the client to verify the authority of the API host
#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
3 changes: 2 additions & 1 deletion rust/noosphere-cli/Cargo.toml
Expand Up @@ -20,6 +20,7 @@ readme = "README.md"

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
reqwest = { version = "~0.11", default-features = false, features = ["json", "rustls-tls"] }
noosphere-ns = { version = "0.4.3", path = "../noosphere-ns" }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tempfile = "^3"
Expand Down Expand Up @@ -50,7 +51,7 @@ globset = "~0.4"

noosphere-ipfs = { version = "0.1.2", path = "../noosphere-ipfs" }
noosphere-core = { version = "0.6.3", path = "../noosphere-core" }
noosphere-fs = { version = "0.5.3", path = "../noosphere-fs" }
noosphere-sphere = { version = "0.1.0", path = "../noosphere-sphere" }
noosphere-storage = { version = "0.4.2", path = "../noosphere-storage" }
noosphere-api = { version = "0.5.6", path = "../noosphere-api" }
noosphere-gateway = { version = "0.1.0", path = "../noosphere-gateway" }
Expand Down

0 comments on commit f7ddfa7

Please sign in to comment.