Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo authored Sep 6, 2023
2 parents a49b7cf + aa40bf5 commit 57d6942
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ clap = { version = "4.4.1", features = ["derive"] }
clap-verbosity-flag = "2.0.1"
derive_more = "0.99.17"
futures-util = "0.3.28"
golem-client = "0.0.32"
golem-client = "0.0.40"
golem-examples = "0.1.5"
http = "0.2.9"
indoc = "2.0.3"
Expand Down
9 changes: 4 additions & 5 deletions src/examples.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::model::GolemError;
use crate::model::{ExampleDescription, GolemError};
use crate::GolemResult;
use golem_examples::model::{
Example, ExampleName, ExampleParameters, GuestLanguage, GuestLanguageTier, PackageName,
TemplateName,
ExampleName, ExampleParameters, GuestLanguage, GuestLanguageTier, PackageName, TemplateName,
};
use golem_examples::*;
use std::env;
Expand Down Expand Up @@ -50,8 +49,8 @@ pub fn process_list_examples(
Some(min_tier) => example.language.tier() <= *min_tier,
None => true,
})
.cloned()
.collect::<Vec<Example>>();
.map(ExampleDescription::from_example)
.collect::<Vec<ExampleDescription>>();

Ok(GolemResult::Ok(Box::new(examples)))
}
20 changes: 20 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use golem_client::project::ProjectError;
use golem_client::project_grant::ProjectGrantError;
use golem_client::project_policy::ProjectPolicyError;
use golem_client::token::TokenError;
use golem_examples::model::{Example, ExampleName, GuestLanguage, GuestLanguageTier};
use indoc::indoc;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
Expand Down Expand Up @@ -702,3 +703,22 @@ impl TypedValueParser for JsonValueParser {
}
}
}

#[derive(Clone, PartialEq, Eq, Debug, Serialize)]
pub struct ExampleDescription {
pub name: ExampleName,
pub language: GuestLanguage,
pub description: String,
pub tier: GuestLanguageTier,
}

impl ExampleDescription {
pub fn from_example(example: &Example) -> Self {
Self {
name: example.name.clone(),
language: example.language.clone(),
description: example.description.clone(),
tier: example.language.tier(),
}
}
}

0 comments on commit 57d6942

Please sign in to comment.