Skip to content

Commit

Permalink
Merge pull request #1921 from itowlson/templates-more-manifest-v2
Browse files Browse the repository at this point in the history
Update redis-* and http-go templates
  • Loading branch information
itowlson authored Oct 20, 2023
2 parents e1e6e7f + a683056 commit fef2ab9
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 45 deletions.
9 changes: 3 additions & 6 deletions crates/templates/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,12 +869,9 @@ mod tests {
{
let template = manager.get("http-empty").unwrap().unwrap();

let values = [
("project-description".to_owned(), "my desc".to_owned()),
("http-base".to_owned(), "/".to_owned()),
]
.into_iter()
.collect();
let values = [("project-description".to_owned(), "my desc".to_owned())]
.into_iter()
.collect();
let options = RunOptions {
variant: crate::template::TemplateVariantInfo::NewApplication,
output_path: application_dir.clone(),
Expand Down
9 changes: 5 additions & 4 deletions templates/http-empty/content/spin.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
spin_manifest_version = "1"
authors = ["{{authors}}"]
description = "{{project-description}}"
spin_manifest_version = 2

[application]
name = "{{project-name}}"
trigger = { type = "http", base = "{{http-base}}" }
version = "0.1.0"
authors = ["{{authors}}"]
description = "{{project-description}}"
1 change: 0 additions & 1 deletion templates/http-empty/metadata/spin-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ tags = ["http"]

[parameters]
project-description = { type = "string", prompt = "Description", default = "" }
http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" }
20 changes: 11 additions & 9 deletions templates/http-go/content/spin.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
spin_manifest_version = "1"
authors = ["{{authors}}"]
description = "{{project-description}}"
spin_manifest_version = 2

[application]
name = "{{project-name}}"
trigger = { type = "http", base = "{{http-base}}" }
version = "0.1.0"
authors = ["{{authors}}"]
description = "{{project-description}}"

[[trigger.http]]
route = "{{http-path}}"
component = "{{project-name | kebab_case}}"

[[component]]
id = "{{project-name | kebab_case}}"
[component.{{project-name | kebab_case}}]
source = "main.wasm"
allowed_http_hosts = []
[component.trigger]
route = "{{http-path}}"
[component.build]
[component.{{project-name | kebab_case}}.build]
command = "tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go"
watch = ["**/*.go", "go.mod"]
11 changes: 6 additions & 5 deletions templates/http-go/metadata/snippets/component.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[[component]]
id = "{{project-name | kebab_case}}"
[[trigger.http]]
route = "{{http-path}}"
component = "{{project-name | kebab_case}}"

[component.{{project-name | kebab_case}}]
source = "{{ output-path }}/main.wasm"
allowed_http_hosts = []
[component.trigger]
route = "{{http-path}}"
[component.build]
[component.{{project-name | kebab_case}}.build]
command = "tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go"
workdir = "{{ output-path }}"
watch = ["**/*.go", "go.mod"]
2 changes: 0 additions & 2 deletions templates/http-go/metadata/spin-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ tags = ["http", "go"]

[add_component]
skip_files = ["spin.toml"]
skip_parameters = ["http-base"]
[add_component.snippets]
component = "component.txt"

[parameters]
project-description = { type = "string", prompt = "Description", default = "" }
http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" }
http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" }
23 changes: 14 additions & 9 deletions templates/redis-go/content/spin.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
spin_manifest_version = "1"
authors = ["{{authors}}"]
description = "{{project-description}}"
spin_manifest_version = 2

[application]
name = "{{project-name}}"
trigger = { type = "redis", address = "{{redis-address}}" }
version = "0.1.0"
authors = ["{{authors}}"]
description = "{{project-description}}"

[[component]]
id = "{{project-name | kebab_case}}"
[application.trigger.redis]
address = "{{redis-address}}"

[[trigger.redis]]
channel = "{{redis-channel}}"
component = "{{project-name | kebab_case}}"

[component.{{project-name | kebab_case}}]
source = "main.wasm"
allowed_http_hosts = []
[component.trigger]
channel = "{{redis-channel}}"
[component.build]
[component.{{project-name | kebab_case}}.build]
command = "tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go"
23 changes: 14 additions & 9 deletions templates/redis-rust/content/spin.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
spin_manifest_version = "1"
authors = ["{{authors}}"]
description = "{{project-description}}"
spin_manifest_version = 2

[application]
name = "{{project-name}}"
trigger = { type = "redis", address = "{{redis-address}}" }
version = "0.1.0"
authors = ["{{authors}}"]
description = "{{project-description}}"

[[component]]
id = "{{project-name | kebab_case}}"
[application.trigger.redis]
address = "{{redis-address}}"

[[trigger.redis]]
channel = "{{redis-channel}}"
component = "{{project-name | kebab_case}}"

[component.{{project-name | kebab_case}}]
source = "target/wasm32-wasi/release/{{project-name | snake_case}}.wasm"
allowed_http_hosts = []
[component.trigger]
channel = "{{redis-channel}}"
[component.build]
[component.{{project-name | kebab_case}}.build]
command = "cargo build --target wasm32-wasi --release"

0 comments on commit fef2ab9

Please sign in to comment.