-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1634 from fibonacci1729/share-app-info
Move AppInfo into spin-http
- Loading branch information
Showing
6 changed files
with
46 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use spin_app::{App, APP_NAME_KEY, APP_VERSION_KEY, BINDLE_VERSION_KEY, OCI_IMAGE_DIGEST_KEY}; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct AppInfo { | ||
pub name: String, | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub version: Option<String>, | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub bindle_version: Option<String>, | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub oci_image_digest: Option<String>, | ||
} | ||
|
||
impl AppInfo { | ||
pub fn new(app: &App) -> Self { | ||
let name = app | ||
.get_metadata(APP_NAME_KEY) | ||
.unwrap_or_default() | ||
.unwrap_or_default(); | ||
let version = app.get_metadata(APP_VERSION_KEY).unwrap_or_default(); | ||
let bindle_version = app.get_metadata(BINDLE_VERSION_KEY).unwrap_or_default(); | ||
let oci_image_digest = app.get_metadata(OCI_IMAGE_DIGEST_KEY).unwrap_or_default(); | ||
Self { | ||
name, | ||
version, | ||
bindle_version, | ||
oci_image_digest, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod app_info; | ||
pub mod config; | ||
pub mod routes; | ||
pub mod wagi; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters