Skip to content

Commit

Permalink
wip: restore registry crate
Browse files Browse the repository at this point in the history
  • Loading branch information
cilki committed Mar 19, 2024
1 parent 3f1a909 commit 1e91a4b
Show file tree
Hide file tree
Showing 22 changed files with 187 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
# https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
strategy:
matrix:
msrv: ["1.70.0"]
msrv: ["1.74.0"]
name: ubuntu / ${{ matrix.msrv }}
steps:
- uses: actions/checkout@v4
Expand Down
15 changes: 15 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ members = [
"goldboot",
"goldboot-image",
"goldboot-macros",
"goldboot-registry",
]
10 changes: 5 additions & 5 deletions goldboot-image/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "goldboot-image"
authors = ["Tyler Cook"]
description = "Defines the goldboot image format"
version = "0.0.1"
edition = "2021"
license = "AGPL-3.0-only"
authors = ["Tyler Cook"]
homepage = "https://goldboot.fossable.org"
license = "AGPL-3.0-only"
name = "goldboot-image"
repository = "https://github.com/fossable/goldboot"
rust-version = "1.70"
rust-version = "1.74"
version = "0.0.1"

[dependencies]
aes-gcm = { version = "0.10.3", features = ["std"] }
Expand Down
10 changes: 5 additions & 5 deletions goldboot-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "goldboot-macros"
version = "0.0.1"
edition = "2021"
rust-version = "1.70"
authors = ["Tyler Cook"]
description = "Supporting macros for goldboot"
edition = "2021"
license = "AGPL-3.0-only"
authors = ["Tyler Cook"]
name = "goldboot-macros"
rust-version = "1.74"
version = "0.0.1"

[lib]
proc-macro = true
Expand Down
22 changes: 22 additions & 0 deletions goldboot-registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "goldboot-registry"
description = "A web service for hosting goldboot images"
version = "0.0.1"
edition = "2021"
license = "AGPL-3.0-only"
authors = ["Tyler Cook"]
readme = "README.md"
homepage = "https://goldboot.org"
repository = "https://github.com/fossable/goldboot/"
rust-version = "1.74"

[dependencies]
anyhow = "1.0.76"
axum = "0.7.4"
clap = { version = "4.4.7", features = ["derive", "string"] }
goldboot = { path="../goldboot", version = "0.0.2" }
goldboot-image = { path="../goldboot-image", version = "0.0.1" }
reqwest = { version = "0.11.22", features = ["stream"] }
tokio = { version = "1.34.0", features = ["full"] }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
13 changes: 13 additions & 0 deletions goldboot-registry/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:latest

ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

RUN apk add --no-cache qemu-system-aarch64 qemu-system-arm qemu-system-x86_64

COPY ${TARGETOS}-${TARGETARCH}${TARGETVARIANT}/goldboot-registry /usr/bin/goldboot-registry
RUN chmod +x /usr/bin/goldboot-registry

WORKDIR /root
ENTRYPOINT ["/usr/bin/goldboot-registry"]
File renamed without changes.
40 changes: 40 additions & 0 deletions goldboot-registry/src/api/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use crate::extract::ImageHandle;
use axum::{
extract::{Path, State},
http::StatusCode,
Json,
};
use goldboot::registry::api::image::ImageInfoResponse;

/// Get image info
pub async fn info(image: ImageHandle) -> Json<ImageInfoResponse> {
Json(image.0.into())
}

/// Get image list
pub async fn list() {}

// Push an image
/*
pub async fn push(id: web::Path<String>, rq: actix_web::HttpRequest) -> Result<HttpResponse> {
let path = match ImageLibrary::find_by_id(&id) {
Ok(image) => {
// Delete if the image already exists
if Path::new(&image.path).exists() {
std::fs::remove_file(&image.path)?;
}
image.path
},
_ => format!("{}.gb", id),
};
let mut file = File::create(&path)?;
std::io::copy(&mut rq, &mut file)?;
""
}*/

/// Get cluster data
pub async fn clusters(Path(_id): Path<String>, Path(_range): Path<String>) {}

/// Get cluster hashes
pub async fn hashes(Path(_id): Path<String>, Path(_range): Path<String>) {}
2 changes: 2 additions & 0 deletions goldboot-registry/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod build;
pub mod image;
5 changes: 5 additions & 0 deletions goldboot-registry/src/cmd/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[derive(clap::Subcommand, Debug)]
pub enum Commands {
/// Run the registry server
Start {},
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ use std::collections::HashMap;

use axum::{
async_trait,
extract::{rejection::JsonRejection, FromRequest, MatchedPath, Path, Request},
extract::{FromRequest, Path, Request},
http::StatusCode,
response::IntoResponse,
RequestPartsExt,
};
use tracing::error;

use crate::library::ImageLibrary;
use goldboot::library::ImageLibrary;

use super::RegistryState;

Expand Down
36 changes: 36 additions & 0 deletions goldboot-registry/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use crate::cmd::Commands;
use axum::{routing::get, Router};
use clap::Parser;
use std::{env, process::ExitCode};

pub mod api;
pub mod cmd;
pub mod extract;

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct CommandLine {
#[clap(subcommand)]
command: Option<Commands>,
}

#[derive(Clone)]
pub struct RegistryState {}

#[tokio::main]
async fn main() {
let command_line = CommandLine::parse();
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();

let state = RegistryState {};

let app = Router::new()
.route("/image/list", get(api::image::list))
.route("/image/info/:image_id", get(api::image::info))
.with_state(state);

let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
2 changes: 1 addition & 1 deletion goldboot-uefi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
name = "goldboot-uefi"
version = "0.1.0"
edition = "2021"
rust-version = "1.70"
rust-version = "1.74"

[dependencies]
24 changes: 12 additions & 12 deletions goldboot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[package]
name = "goldboot"
authors = ["Tyler Cook"]
description = "A command-line application for building goldboot images"
version = "0.0.2"
edition = "2021"
homepage = "https://goldboot.org"
license = "AGPL-3.0-only"
authors = ["Tyler Cook"]
name = "goldboot"
readme = "README.md"
homepage = "https://goldboot.org"
repository = "https://github.com/goldboot/goldboot/"
rust-version = "1.70"
rust-version = "1.74"
version = "0.0.2"

[dependencies]
anyhow = "1.0.76"
# It seems the next LTS will have a clang version new enough for bindgen
# aws-lc-rs = { version = "1", features = ["bindgen"]}
axum = { version = "0.7.4" }
axum = { version = "0.7.4", optional = true }
block-utils = { version = "0.11.1", optional = true }
built = { version = "0.7", features = ["chrono", "semver"] }
byte-unit = "5.1.2"
Expand All @@ -23,10 +23,10 @@ clap = { version = "4.4.7", features = ["derive", "string"] }
console = "0.15.7"
dialoguer = "0.11.0"
enum_dispatch = "0.3.12"
fatfs = "0.3.6"
fatfs = { version = "0.3.6", optional = true }
flate2 = "1.0.28"
fossable = "0.1.2"
fscommon = "0.1.1"
fscommon = { version = "0.1.1", optional = true }
gdk4 = { version = "0.8.1", optional = true }
gdk-pixbuf = { version = "0.19.2", optional = true }
glib-macros = { version = "0.19.2", optional = true }
Expand All @@ -37,15 +37,15 @@ glib = { version = "0.19.2", optional = true }
hex = "0.4.3"
indicatif = "0.17.7"
openssl = { version = "0.10", features = ["vendored"] }
png = "0.17.10"
png = { version = "0.17.10", optional = true }
rand = "0.8.5"
regex = "1.10.2"
reqwest = { version = "0.11.22", features = ["stream", "blocking", "json"] }
ron = "0.8.1"
rustls = { version = "0.22.2" }
serde_json = "1.0.108"
serde = { version = "1.0.190", features = ["derive"] }
serde_win_unattend = "0.1.0"
serde_win_unattend = { version = "0.1.0", optional = true }
serde_yaml = "0.9.27"
sha1 = "0.10.6"
sha2 = "0.10.8"
Expand All @@ -61,7 +61,7 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
ubyte = "0.10.4"
url = { version = "2.4.1", features = ["serde"] }
validator = { version = "0.17.0", features = ["derive"] }
vnc = "0.4.0"
vnc = { version = "0.4.0", optional = true }
whoami = "1.4.1"
zstd = "0.13.0"
uuid = { version = "1.7.0", features = ["v4"] }
Expand All @@ -82,7 +82,7 @@ registry = []
gui = ["dep:gtk4", "dep:glib-macros", "dep:gdk4", "dep:gdk-pixbuf", "dep:block-utils", "dep:glib"]

# Support for casting images
cast = []
cast = ["dep:fatfs", "dep:fscommon", "dep:png", "dep:vnc", "dep:serde_win_unattend", "dep:axum"]

# Bundled OVMF firmware
include_ovmf = []
42 changes: 3 additions & 39 deletions goldboot/src/registry/api/image.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
use crate::registry::extract;
use axum::{
extract::{Path, State},
http::StatusCode,
Json,
};
use goldboot_image::{ImageArch, ImageHandle};
use serde::{Deserialize, Serialize};

use crate::library::ImageLibrary;

#[derive(Serialize, Deserialize)]
pub struct ImageInfoResponse {
pub version: u8,
Expand Down Expand Up @@ -38,35 +30,7 @@ impl From<ImageHandle> for ImageInfoResponse {
}
}

/// Get image info
pub async fn info(image: extract::ImageHandle) -> Json<ImageInfoResponse> {
Json(image.0.into())
#[derive(Serialize, Deserialize)]
pub struct ImageListResponse {
pub results: Vec<ImageInfoResponse>,
}

/// Get image list
pub async fn list() {}

// Push an image
/*
pub async fn push(id: web::Path<String>, rq: actix_web::HttpRequest) -> Result<HttpResponse> {
let path = match ImageLibrary::find_by_id(&id) {
Ok(image) => {
// Delete if the image already exists
if Path::new(&image.path).exists() {
std::fs::remove_file(&image.path)?;
}
image.path
},
_ => format!("{}.gb", id),
};
let mut file = File::create(&path)?;
std::io::copy(&mut rq, &mut file)?;
""
}*/

/// Get cluster data
pub async fn clusters(Path(_id): Path<String>, Path(_range): Path<String>) {}

/// Get cluster hashes
pub async fn hashes(Path(_id): Path<String>, Path(_range): Path<String>) {}
11 changes: 0 additions & 11 deletions goldboot/src/registry/api/media.rs

This file was deleted.

24 changes: 24 additions & 0 deletions goldboot/src/registry/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
pub mod image;

pub struct RegistryTokenPermissions {
// TODO
}

pub struct RegistryToken {
/// The token value
pub token: String,

/// Whether the token value has been hashed with PBKDF2
pub hashed: bool,

/// Whether the token value has been encrypted with AES256
pub encrypted: bool,

/// A time-based second factor secret URL associated with the token
pub totp_secret_url: Option<String>,

/// The expiration timestamp
pub expiration: Option<u64>,

/// The token's associated permissions
pub permissions: RegistryTokenPermissions,
}
Empty file removed goldboot/src/registry/image.rs
Empty file.
Loading

0 comments on commit 1e91a4b

Please sign in to comment.