-
Notifications
You must be signed in to change notification settings - Fork 13
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 #5 from kate-goldenring/manifest-module
Add `manifest` module and update `deploy.rs`
- Loading branch information
Showing
4 changed files
with
64 additions
and
29 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod commands; | ||
mod manifest; | ||
mod opts; | ||
use anyhow::{anyhow, Error, Result}; | ||
use clap::{Parser, Subcommand}; | ||
|
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,32 @@ | ||
use anyhow::anyhow; | ||
use std::path::{Path, PathBuf}; | ||
|
||
use crate::opts::DEFAULT_MANIFEST_FILE; | ||
|
||
/// Resolves a manifest path provided by a user, which may be a file or | ||
/// directory, to a path to a manifest file. | ||
pub(crate) fn resolve_file_path(provided_path: impl AsRef<Path>) -> anyhow::Result<PathBuf> { | ||
let path = provided_path.as_ref(); | ||
|
||
if path.is_file() { | ||
Ok(path.to_owned()) | ||
} else if path.is_dir() { | ||
let file_path = path.join(DEFAULT_MANIFEST_FILE); | ||
if file_path.is_file() { | ||
Ok(file_path) | ||
} else { | ||
Err(anyhow!( | ||
"Directory {} does not contain a file named 'spin.toml'", | ||
path.display() | ||
)) | ||
} | ||
} else { | ||
let pd = path.display(); | ||
let err = match path.try_exists() { | ||
Err(e) => anyhow!("Error accessing path {pd}: {e:#}"), | ||
Ok(false) => anyhow!("No such file or directory '{pd}'"), | ||
Ok(true) => anyhow!("Path {pd} is neither a file nor a directory"), | ||
}; | ||
Err(err) | ||
} | ||
} |
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