sdk tweaks (#2791)

* sdk tweaks

* switch back to deeppartial
This commit is contained in:
Aiden McClelland
2024-11-25 11:49:11 -07:00
committed by GitHub
parent e4a2af6ae7
commit 504f1a8e97
18 changed files with 149 additions and 106 deletions

View File

@@ -354,7 +354,9 @@ pub enum ImageSource {
Packed,
#[serde(rename_all = "camelCase")]
DockerBuild {
#[ts(optional)]
workdir: Option<PathBuf>,
#[ts(optional)]
dockerfile: Option<PathBuf>,
#[serde(skip_serializing_if = "Option::is_none")]
#[ts(optional)]
@@ -366,8 +368,15 @@ impl ImageSource {
pub fn ingredients(&self) -> Vec<PathBuf> {
match self {
Self::Packed => Vec::new(),
Self::DockerBuild { dockerfile, .. } => {
vec![dockerfile.clone().unwrap_or_else(|| "Dockerfile".into())]
Self::DockerBuild {
dockerfile,
workdir,
..
} => {
vec![workdir
.as_deref()
.unwrap_or(Path::new("."))
.join(dockerfile.as_deref().unwrap_or(Path::new("Dockerfile")))]
}
Self::DockerTag(_) => Vec::new(),
}

View File

@@ -122,7 +122,8 @@ impl<'a> std::ops::DerefMut for ExtendedCommand<'a> {
}
impl<'a> Invoke<'a> for tokio::process::Command {
type Extended<'ext> = ExtendedCommand<'ext>
type Extended<'ext>
= ExtendedCommand<'ext>
where
Self: 'ext,
'ext: 'a;
@@ -162,7 +163,8 @@ impl<'a> Invoke<'a> for tokio::process::Command {
}
impl<'a> Invoke<'a> for ExtendedCommand<'a> {
type Extended<'ext> = &'ext mut ExtendedCommand<'ext>
type Extended<'ext>
= &'ext mut ExtendedCommand<'ext>
where
Self: 'ext,
'ext: 'a;
@@ -663,8 +665,8 @@ impl FromStr for PathOrUrl {
type Err = <PathBuf as FromStr>::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> {
if let Ok(url) = s.parse::<Url>() {
if url.scheme() == "file" {
Ok(Self::Path(url.path().parse()?))
if let Some(path) = s.strip_prefix("file://") {
Ok(Self::Path(path.parse()?))
} else {
Ok(Self::Url(url))
}