Skip to content

Commit

Permalink
Allow templating for hello world and kvcounter
Browse files Browse the repository at this point in the history
Signed-off-by: aish-where-ya <[email protected]>
  • Loading branch information
aish-where-ya committed Aug 31, 2023
1 parent 4ed4b63 commit df39872
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 24 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/release-hello-world.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
paths:
- "hello-world/**"
tags:
- "hello-world-v*"
- "v*"
env:
# For the release action, you'll have to set the following variables
WASH_ISSUER_KEY: ${{ secrets.COSMONIC_ACCOUNT_OFFICIAL }}
Expand All @@ -29,9 +29,7 @@ jobs:
env:
WASH_ISSUER_KEY: ${{ env.WASH_ISSUER_KEY }}
WASH_SUBJECT_KEY: ${{ env.WASH_SUBJECT_KEY }}
run: |
wash new actor --path rust hello
cd hello && wash build
run: make
shell: bash
working-directory: ${{ env.working-directory }}
- name: Upload signed actor to GH Actions
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/release-kvcounter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
paths:
- "kvcounter/**"
tags:
- "kvcounter-v*"
- "v*"
env:
# For the release action, you'll have to set the following variables
WASH_ISSUER_KEY: ${{ secrets.COSMONIC_ACCOUNT_OFFICIAL }}
Expand All @@ -29,9 +29,7 @@ jobs:
env:
WASH_ISSUER_KEY: ${{ env.WASH_ISSUER_KEY }}
WASH_SUBJECT_KEY: ${{ env.WASH_SUBJECT_KEY }}
run: |
wash new actor --path rust kvcounter
wash build -p kvcounter
run: make
shell: bash
working-directory: ${{ env.working-directory }}
- name: Upload signed actor to GH Actions
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-multichannelchat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ jobs:
run: rustup target add wasm32-unknown-unknown

- name: Set wash subject key (api-gateway)
if: ${{ matrix.working-directory == 'multi-channel-chat/api-gateway' }}
if: ${{ matrix.artifact-name == 'api-gateway' }}
run: echo "WASH_SUBJECT_KEY=${{ secrets.AWESOME_COSMONIC_MCC_APIGATEWAY_KEY }}" > $GITHUB_ENV
- name: Set wash subject key (chatlog)
if: ${{ matrix.working-directory == 'multi-channel-chat/chatlog' }}
if: ${{ matrix.artifact-name == 'chatlog' }}
run: echo "WASH_SUBJECT_KEY=${{ secrets.AWESOME_COSMONIC_MCC_CHATLOG_KEY }}" > $GITHUB_ENV
- name: Set wash subject key (http-channel)
if: ${{ matrix.working-directory == 'multi-channel-chat/http-channel' }}
if: ${{ matrix.artifact-name == 'http-channel' }}
run: echo "WASH_SUBJECT_KEY=${{ secrets.AWESOME_COSMONIC_MCC_HTTPCHANNEL_KEY }}" > $GITHUB_ENV
- name: Set wash subject key (nats-channel)
if: ${{ matrix.working-directory == 'multi-channel-chat/nats-channel' }}
if: ${{ matrix.artifact-name == 'nats-channel' }}
run: echo "WASH_SUBJECT_KEY=${{ secrets.AWESOME_COSMONIC_MCC_NATSCHANNEL_KEY }}" > $GITHUB_ENV

- name: Build and sign wasmCloud actor
Expand Down
2 changes: 1 addition & 1 deletion hello-world/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "helloworld"
name = "{{project-name}}"
version = "0.1.0"
authors = [ "" ]
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion hello-world/rust/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# HelloWorldActor
# {{ project-name }} Actor

This application is an implementation of the HTTP server capability in Rust that returns "Hello, World!" in response to an HTTP request.
4 changes: 2 additions & 2 deletions hello-world/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use wasmcloud_interface_httpserver::{HttpRequest, HttpResponse, HttpServer, Http

#[derive(Debug, Default, Actor, HealthResponder)]
#[services(Actor, HttpServer)]
struct HelloWorldActor {}
struct {{to_pascal_case project-name}}Actor {}

/// Implementation of the HTTP server capability
#[async_trait]
impl HttpServer for HelloWorldActor {
impl HttpServer for {{to_pascal_case project-name}}Actor {
async fn handle_request(&self, _ctx: &Context, _req: &HttpRequest) -> RpcResult<HttpResponse> {
let message: &str = r#"Hello, World, from Cosmonic!
Expand Down
2 changes: 1 addition & 1 deletion hello-world/rust/wasmcloud.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "helloworld"
name = "{{project-name}}"
language = "rust"
type = "actor"
version = "0.1.0"
Expand Down
4 changes: 2 additions & 2 deletions kvcounter/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "kvcounter"
name = "{{project-name}}"
version = "0.1.0"
authors = [ "" ]
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]
name = "kvcounter"
name = "{{to_snake_case project-name}}"

[dependencies]
async-trait = "0.1"
Expand Down
4 changes: 2 additions & 2 deletions kvcounter/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use ui::get_asset;

#[derive(Debug, Default, Actor, HealthResponder)]
#[services(Actor, HttpServer)]
struct KvCounterActor {}
struct {{to_pascal_case project-name}}Actor {}

/// Implementation of HttpServer trait methods
#[async_trait]
impl HttpServer for KvCounterActor {
impl HttpServer for {{to_pascal_case project-name}}Actor {
async fn handle_request(&self, ctx: &Context, req: &HttpRequest) -> RpcResult<HttpResponse> {
let trimmed_path: Vec<&str> = req.path.trim_matches('/').split('/').collect();

Expand Down
4 changes: 2 additions & 2 deletions kvcounter/rust/wadm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: kvcounter
name: {{project-name}}
annotations:
version: v0.0.1
description: "wasmCloud Key Value Counter Example"
Expand All @@ -18,7 +18,7 @@ spec:
- name: kvcounter
type: actor
properties:
image: ghcr.io/{{github.REPOSITORY}}:kvcounter:0.1.0
image: ghcr.io/{{github.REPOSITORY}}:{{project-name}}:0.1.0
traits:
- type: spreadscaler
properties:
Expand Down
2 changes: 1 addition & 1 deletion kvcounter/rust/wasmcloud.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "kvcounter"
name = "{{project-name}}"
language = "rust"
type = "actor"
version = "0.1.0"
Expand Down

0 comments on commit df39872

Please sign in to comment.