-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds prototype registry storage (#168)
- Adds storage implementation - Adds CI workflow for registry - Addresses code review
- Loading branch information
Showing
28 changed files
with
1,203 additions
and
82 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: CI | ||
name: Buffrs CLI | ||
|
||
on: | ||
push: | ||
|
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,72 @@ | ||
name: Buffrs Registry | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
|
||
env: | ||
MINIMUM_LINE_COVERAGE_PERCENT: 5 | ||
|
||
jobs: | ||
fmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: rustup update && rustup component add rustfmt | ||
- run: cd registry && cargo fmt --check --all | ||
|
||
clippy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: rustup update && rustup component add clippy | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cd registry && cargo clippy --all-targets --workspace -- -D warnings -D clippy::all | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
lfs: "true" | ||
- uses: isbang/[email protected] | ||
with: | ||
compose-file: "./registry/docker-compose.yml" | ||
- run: rustup update | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cd registry && cargo test --workspace | ||
env: | ||
RUST_BACKTRACE: 1 | ||
|
||
deny: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: rustup update | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo install cargo-deny || true | ||
- run: cd registry && cargo deny --workspace check | ||
|
||
coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
lfs: 'true' | ||
- uses: isbang/[email protected] | ||
with: | ||
compose-file: "./registry/docker-compose.yml" | ||
- run: rustup update | ||
- run: rustup component add llvm-tools-preview | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo install cargo-llvm-cov || true | ||
- run: cd registry && cargo llvm-cov --workspace --fail-under-lines "$MINIMUM_LINE_COVERAGE_PERCENT" | ||
|
||
typos: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo install typos-cli || true | ||
- run: cd registry && typos |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[package] | ||
type = "api" | ||
name = "buffrs-registry" | ||
name = "buffrs" | ||
version = "0.0.1" |
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,13 @@ | ||
[licenses] | ||
unlicensed = "deny" | ||
allow = ["Apache-2.0", "BSD-3-Clause", "MIT", "Unicode-DFS-2016", "ISC"] | ||
default = "deny" | ||
|
||
[[licenses.clarify]] | ||
name = "ring" | ||
expression = "ISC" | ||
license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }] | ||
|
||
[bans] | ||
multiple-versions = "warn" | ||
wildcards = "deny" |
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 |
---|---|---|
@@ -1,18 +1,37 @@ | ||
CREATE TABLE users ( | ||
id SERIAL PRIMARY KEY, | ||
-- metadata | ||
name TEXT, | ||
email TEXT, | ||
avatar TEXT, | ||
-- static user token here | ||
token TEXT NOT NULL UNIQUE, | ||
-- timestamps | ||
created_at TIMESTAMPTZ NOT NULL, | ||
updated_at TIMESTAMPTZ NOT NULL, | ||
deleted_at TIMESTAMPTZ | ||
-- table of users. | ||
CREATE TABLE "users" ( | ||
"id" SERIAL PRIMARY KEY, | ||
"handle" TEXT NOT NULL UNIQUE, | ||
"created_at" TIMESTAMPTZ NOT NULL DEFAULT (now()), | ||
"updated_at" TIMESTAMPTZ NOT NULL DEFAULT (now()), | ||
-- when users are deleted, we keep the row, but set the deleted_at field. | ||
"deleted_at" TIMESTAMPTZ | ||
); | ||
|
||
CREATE TABLE user_tokens ( | ||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, | ||
token TEXT NOT NULL UNIQUE | ||
CREATE TABLE "user_tokens" ( | ||
"user" INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, | ||
"prefix" TEXT NOT NULL UNIQUE, | ||
"hash" TEXT NOT NULL UNIQUE, | ||
"allow_publish" BOOLEAN NOT NULL DEFAULT (false), | ||
"allow_update" BOOLEAN NOT NULL DEFAULT (false), | ||
"allow_yank" BOOLEAN NOT NULL DEFAULT (false), | ||
"created_at" TIMESTAMPTZ NOT NULL DEFAULT (now()), | ||
"expires_at" TIMESTAMPTZ NOT NULL, | ||
"deleted_at" TIMESTAMPTZ | ||
); | ||
|
||
-- view showing only active users | ||
CREATE VIEW "users_active" AS | ||
SELECT * | ||
FROM users | ||
WHERE deleted_at IS NULL; | ||
|
||
-- view showing only active tokens | ||
CREATE VIEW "user_tokens_active" AS | ||
SELECT | ||
tokens.*, | ||
users.handle | ||
FROM users_active users | ||
JOIN user_tokens tokens on tokens.user = users.id | ||
WHERE tokens.expires_at > now() | ||
AND tokens.deleted_at IS NULL; |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
syntax = "proto3"; | ||
|
||
package buffrs.version; | ||
|
||
message VersionCore { | ||
uint32 major = 1; | ||
uint32 minor = 2; | ||
uint32 patch = 3; | ||
} | ||
|
||
message SemanticVersion { | ||
VersionCore version = 1; | ||
optional string prerelease = 2; | ||
} |
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,47 @@ | ||
// Copyright 2023 Helsing GmbH | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use crate::{ | ||
context::Context, | ||
proto::buffrs::registry::{ | ||
registry_server::Registry, DownloadRequest, DownloadResponse, PublishRequest, | ||
PublishResponse, VersionsRequest, VersionsResponse, | ||
}, | ||
}; | ||
use async_trait::async_trait; | ||
use tonic::{Request, Response, Status}; | ||
|
||
#[async_trait] | ||
impl Registry for Context { | ||
async fn publish( | ||
&self, | ||
_request: Request<PublishRequest>, | ||
) -> Result<Response<PublishResponse>, Status> { | ||
todo!() | ||
} | ||
|
||
async fn download( | ||
&self, | ||
_request: Request<DownloadRequest>, | ||
) -> Result<Response<DownloadResponse>, Status> { | ||
todo!() | ||
} | ||
|
||
async fn versions( | ||
&self, | ||
_request: Request<VersionsRequest>, | ||
) -> Result<Response<VersionsResponse>, Status> { | ||
todo!() | ||
} | ||
} |
Oops, something went wrong.