fix: align Repository access DCDL fields
This commit is contained in:
@@ -30,8 +30,8 @@ const REPOSITORY_ACCESS_SCHEMA_SOURCE: &str = r#"{
|
|||||||
repository_access = {
|
repository_access = {
|
||||||
...{
|
...{
|
||||||
ssh = {
|
ssh = {
|
||||||
credential_id = String;
|
credential = String;
|
||||||
host_trust_id = String;
|
host_trust = String;
|
||||||
access = String;
|
access = String;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -74,8 +74,8 @@ struct VirtualRepositoryAccess {
|
|||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
struct VirtualRepositorySshAccess {
|
struct VirtualRepositorySshAccess {
|
||||||
credential_id: String,
|
credential: String,
|
||||||
host_trust_id: String,
|
host_trust: String,
|
||||||
access: RepositoryAccessMode,
|
access: RepositoryAccessMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,8 +149,8 @@ fn project_repository_access_evaluation(
|
|||||||
let mut bindings = Vec::with_capacity(config.repository_access.len());
|
let mut bindings = Vec::with_capacity(config.repository_access.len());
|
||||||
for (repository_id, access) in config.repository_access {
|
for (repository_id, access) in config.repository_access {
|
||||||
validate_identifier("repository_id", &repository_id)?;
|
validate_identifier("repository_id", &repository_id)?;
|
||||||
validate_identifier("credential_id", &access.ssh.credential_id)?;
|
validate_identifier("credential_id", &access.ssh.credential)?;
|
||||||
validate_identifier("host_trust_id", &access.ssh.host_trust_id)?;
|
validate_identifier("host_trust_id", &access.ssh.host_trust)?;
|
||||||
let repository = store
|
let repository = store
|
||||||
.get_repository(workspace_id, &repository_id)?
|
.get_repository(workspace_id, &repository_id)?
|
||||||
.ok_or_else(|| Error::InvalidInput(format!("unknown Repository `{repository_id}`")))?;
|
.ok_or_else(|| Error::InvalidInput(format!("unknown Repository `{repository_id}`")))?;
|
||||||
@@ -160,25 +160,25 @@ fn project_repository_access_evaluation(
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
let credential = secrets
|
let credential = secrets
|
||||||
.get_credential(workspace_id, &access.ssh.credential_id, &[])?
|
.get_credential(workspace_id, &access.ssh.credential, &[])?
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
Error::InvalidInput(format!(
|
Error::InvalidInput(format!(
|
||||||
"unknown Repository SSH credential `{}`",
|
"unknown Repository SSH credential `{}`",
|
||||||
access.ssh.credential_id
|
access.ssh.credential
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
if credential.status != "active" {
|
if credential.status != "active" {
|
||||||
return Err(Error::InvalidInput(format!(
|
return Err(Error::InvalidInput(format!(
|
||||||
"Repository SSH credential `{}` is not active",
|
"Repository SSH credential `{}` is not active",
|
||||||
access.ssh.credential_id
|
access.ssh.credential
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
let host_trust = secrets
|
let host_trust = secrets
|
||||||
.get_host_trust(workspace_id, &access.ssh.host_trust_id, &[])?
|
.get_host_trust(workspace_id, &access.ssh.host_trust, &[])?
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
Error::InvalidInput(format!(
|
Error::InvalidInput(format!(
|
||||||
"unknown Repository SSH host trust `{}`",
|
"unknown Repository SSH host trust `{}`",
|
||||||
access.ssh.host_trust_id
|
access.ssh.host_trust
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
let uri = url::Url::parse(&repository.source.uri).map_err(|_| {
|
let uri = url::Url::parse(&repository.source.uri).map_err(|_| {
|
||||||
@@ -200,13 +200,13 @@ fn project_repository_access_evaluation(
|
|||||||
if hostname != host_trust.hostname || port != host_trust.port {
|
if hostname != host_trust.hostname || port != host_trust.port {
|
||||||
return Err(Error::InvalidInput(format!(
|
return Err(Error::InvalidInput(format!(
|
||||||
"Repository `{repository_id}` SSH host does not match host trust `{}`",
|
"Repository `{repository_id}` SSH host does not match host trust `{}`",
|
||||||
access.ssh.host_trust_id
|
access.ssh.host_trust
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
bindings.push(RepositorySshAccessBinding {
|
bindings.push(RepositorySshAccessBinding {
|
||||||
repository_id,
|
repository_id,
|
||||||
credential_id: access.ssh.credential_id,
|
credential_id: access.ssh.credential,
|
||||||
host_trust_id: access.ssh.host_trust_id,
|
host_trust_id: access.ssh.host_trust,
|
||||||
access: access.ssh.access,
|
access: access.ssh.access,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1675,8 +1675,8 @@ mod tests {
|
|||||||
repository_access = {
|
repository_access = {
|
||||||
remote = {
|
remote = {
|
||||||
ssh = {
|
ssh = {
|
||||||
credential_id = "deploy";
|
credential = "deploy";
|
||||||
host_trust_id = "example";
|
host_trust = "example";
|
||||||
access = "read_only";
|
access = "read_only";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1697,8 +1697,8 @@ mod tests {
|
|||||||
repository_access = {
|
repository_access = {
|
||||||
remote = {
|
remote = {
|
||||||
ssh = {
|
ssh = {
|
||||||
credential_id = "missing";
|
credential = "missing";
|
||||||
host_trust_id = "example";
|
host_trust = "example";
|
||||||
access = "read_only";
|
access = "read_only";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user