Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions packages/toolchain/toolchain/src/config/build/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use serde::{Deserialize, Serialize};
use super::Compression;

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Build {
/// Directory to build the Docker image from.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none", alias = "build_path")]
pub build_path: Option<String>,
/// Existing image tag to upload.
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -18,10 +18,10 @@ pub struct Build {
#[serde(skip_serializing_if = "Option::is_none")]
pub dockerfile: Option<String>,
/// Build target to upload.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none", alias = "build_target")]
pub build_target: Option<String>,
/// Build arguments to pass to the build.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none", alias = "build_args")]
pub build_args: Option<HashMap<String, String>>,
/// Unstable features.
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -35,9 +35,11 @@ impl Build {
}

#[derive(Default, Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Unstable {
#[serde(alias = "allow_root")]
pub allow_root: Option<bool>,
#[serde(alias = "build_method")]
pub build_method: Option<BuildMethod>,
pub bundle: Option<BundleKind>,
pub compression: Option<Compression>,
Expand All @@ -58,7 +60,7 @@ impl Unstable {
}

#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, JsonSchema, clap::ValueEnum)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub enum BuildMethod {
/// Use the native Docker build command. Only used if Buildx is not available.
Buildx,
Expand All @@ -73,7 +75,7 @@ pub enum BuildMethod {
#[derive(
Debug, Copy, Clone, Serialize, Deserialize, strum::AsRefStr, JsonSchema, clap::ValueEnum,
)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub enum BundleKind {
/// Legacy option. Docker image archive output from `docker save`. Slower lobby start
/// times.
Expand Down
8 changes: 6 additions & 2 deletions packages/toolchain/toolchain/src/config/build/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ use super::Compression;

// TODO: Add back `deny_unknown_fields` after https://github.com/serde-rs/serde/issues/1600
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub struct Build {
pub script: String,
#[serde(default)]
pub unstable: Unstable,
}

#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Unstable {
pub minify: Option<bool>,
#[serde(alias = "analyze_result")]
pub analyze_result: Option<bool>,
#[serde(alias = "esbuild_log_level")]
pub esbuild_log_level: Option<String>,
pub compression: Option<Compression>,
#[serde(alias = "dump_build")]
pub dump_build: Option<bool>,
#[serde(alias = "no_bundler")]
pub no_bundler: Option<bool>,
}

Expand Down
4 changes: 2 additions & 2 deletions packages/toolchain/toolchain/src/config/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod docker;
pub mod javascript;

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", untagged)]
#[serde(rename_all = "camelCase", untagged)]
pub enum Runtime {
Docker(docker::Build),
#[serde(rename = "javascript")]
Expand All @@ -15,7 +15,7 @@ pub enum Runtime {
#[derive(
Debug, Copy, Clone, Serialize, Deserialize, strum::AsRefStr, JsonSchema, clap::ValueEnum,
)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub enum Compression {
/// No compression.
#[strum(serialize = "none")]
Expand Down
22 changes: 12 additions & 10 deletions packages/toolchain/toolchain/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Deref for Config {
}

#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Root {
#[serde(default, alias = "builds")]
pub actors: HashMap<String, Actor>,
Expand All @@ -67,25 +67,26 @@ pub struct Root {
#[serde(default)]
pub functions: HashMap<String, Function>,

#[serde(default)]
#[serde(default, alias = "rivetkit")]
pub rivetkit: Option<RivetKit>,
}

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub struct Actor {
#[serde(flatten)]
pub build: Build,
}

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub struct Function {
#[serde(flatten)]
pub build: Build,
pub path: Option<String>,
#[serde(alias = "route_subpaths")]
pub route_subpaths: Option<bool>,
#[serde(default)]
#[serde(default, alias = "strip_prefix")]
pub strip_prefix: Option<bool>,
#[serde(default)]
pub networking: FunctionNetworking,
Expand Down Expand Up @@ -117,8 +118,9 @@ impl Function {
}

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub struct FunctionNetworking {
#[serde(alias = "internal_port")]
pub internal_port: Option<u16>,
}

Expand All @@ -129,13 +131,13 @@ impl FunctionNetworking {
}

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Default)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub struct FunctionRuntime {
pub environment: Option<HashMap<String, String>>,
}

#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub struct RivetKit {
// TEMPORARY: We need to auto-generate a worker file using isoaltes, so we need to know the
// path to the registry
Expand All @@ -148,15 +150,15 @@ pub struct RivetKit {
}

#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub struct Resources {
pub cpu: u64,
pub memory: u64,
}

// TODO: Add back `deny_unknown_fields` after https://github.com/serde-rs/serde/issues/1600
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
#[serde(rename_all = "camelCase")]
pub struct Build {
pub tags: Option<HashMap<String, String>>,
#[serde(flatten)]
Expand Down
Loading