-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support using subcommand as Docker CLI plugin for tighter integration
See docker/cli#1534 for CLI plugin design.
- Loading branch information
Showing
3 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
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,46 @@ | ||
pub fn go() -> anyhow::Result<String> { | ||
let authors = env!("CARGO_PKG_AUTHORS"); | ||
let first_author_name = authors | ||
.split_once(" <") | ||
.ok_or(anyhow::anyhow!("{authors}"))? | ||
.0; | ||
Ok(serde_json::to_string_pretty(&Metadata { | ||
schema_version: "0.1.0".into(), | ||
short_description: env!("CARGO_PKG_DESCRIPTION").into(), | ||
url: env!("CARGO_PKG_HOMEPAGE").into(), | ||
vendor: first_author_name.into(), | ||
version: env!("CARGO_PKG_VERSION").into(), | ||
})?) | ||
} | ||
|
||
#[derive(serde::Serialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
struct Metadata { | ||
schema_version: String, | ||
short_description: String, | ||
#[serde(rename = "URL")] | ||
url: String, | ||
vendor: String, | ||
version: String, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn handles() -> anyhow::Result<()> { | ||
let metadata = go()?; | ||
assert_eq!( | ||
metadata, | ||
r#"{ | ||
"SchemaVersion": "0.1.0", | ||
"ShortDescription": "Zero-downtime deployments for Docker Compose", | ||
"URL": "https://github.com/evolutics/wheelsticks", | ||
"Vendor": "Benjamin Fischer", | ||
"Version": "1.0.0" | ||
}"#, | ||
); | ||
Ok(()) | ||
} | ||
} |
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