Skip to content

Commit

Permalink
feat(common): add template definition schema (#1655)
Browse files Browse the repository at this point in the history
jonaro00 authored Mar 4, 2024
1 parent 3080c93 commit c386702
Showing 2 changed files with 43 additions and 2 deletions.
5 changes: 3 additions & 2 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ pub mod deployment;
pub type DeploymentId = uuid::Uuid;
#[cfg(feature = "extract_propagation")]
pub mod extract_propagation;
#[cfg(feature = "claims")]
pub mod limits;
#[cfg(feature = "service")]
pub mod log;
#[cfg(feature = "service")]
@@ -19,8 +21,7 @@ pub mod models;
pub mod resource;
pub mod secrets;
pub use secrets::{Secret, SecretStore};
#[cfg(feature = "claims")]
pub mod limits;
pub mod templates;
#[cfg(feature = "tracing")]
pub mod tracing;
#[cfg(feature = "wasm")]
40 changes: 40 additions & 0 deletions common/src/templates.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use serde::{Deserialize, Serialize};

/// Schema used in `examples/templates.toml` and services that parses it
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct TemplateDefinition {
/// Title of the template
title: String,
/// A short description of the template
description: Option<String>,
/// Path relative to the repo root
path: Option<String>,
/// "starter" OR "template" (default) OR "tutorial"
#[serde(default)]
r#type: TemplateType,
/// List of areas where this template is useful. Examples: "Web app", "Discord bot", "Monitoring", "Automation", "Utility"
use_cases: Vec<String>,
/// List of keywords that describe the template. Examples: "axum", "serenity", "typescript", "saas", "fullstack", "database"
tags: Vec<String>,
/// URL to a live instance of the template (if relevant)
live_demo: Option<String>,

/// If this template is available in the `cargo shuttle init --template` short-hand options, add that name here
template: Option<String>,

/// Set this to true if this is a community template outside of the shuttle-examples repo
community: Option<bool>,
/// GitHub username of the author of the community template
author: Option<String>,
/// URL to the repo of the community template
repo: Option<String>,
}

#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum TemplateType {
Starter,
#[default]
Template,
Tutorial,
}

0 comments on commit c386702

Please sign in to comment.