fix: treat legacy Runtime config as unconfigured
This commit is contained in:
@@ -44,23 +44,22 @@ pub fn project_runtime_from_workspace_config(
|
|||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
state: &WorkspaceConfigState,
|
state: &WorkspaceConfigState,
|
||||||
) -> Result<RuntimeConfigProjection> {
|
) -> Result<RuntimeConfigProjection> {
|
||||||
let bundle = if state.contract.schema_bundle.contributions.is_empty() {
|
let has_runtime_schema = state
|
||||||
config_source::WorkspaceConfigSchemaBundle::compose([
|
.contract
|
||||||
RuntimeConfigSchemaProvider.contribution()?
|
.schema_bundle
|
||||||
])
|
.contributions
|
||||||
.map_err(|error| Error::Config(error.to_string()))?
|
.iter()
|
||||||
} else {
|
.any(|entry| entry.provider_id == "builtin:runtime");
|
||||||
state.contract.schema_bundle.clone()
|
if !has_runtime_schema {
|
||||||
};
|
return Ok(RuntimeConfigProjection {
|
||||||
let evaluation = evaluate_workspace_config_state(state, bundle)?;
|
config_revision: state.snapshot.revision,
|
||||||
if evaluation.projection_digest != state.projection_digest
|
projection_digest: state.projection_digest.clone(),
|
||||||
&& state
|
default_runtime_id: None,
|
||||||
.contract
|
});
|
||||||
.schema_bundle
|
}
|
||||||
.contributions
|
|
||||||
.iter()
|
let evaluation = evaluate_workspace_config_state(state, state.contract.schema_bundle.clone())?;
|
||||||
.any(|entry| entry.provider_id == "builtin:runtime")
|
if evaluation.projection_digest != state.projection_digest {
|
||||||
{
|
|
||||||
return Err(Error::RegistryInconsistency(format!(
|
return Err(Error::RegistryInconsistency(format!(
|
||||||
"Runtime projection digest mismatch for Workspace {workspace_id}"
|
"Runtime projection digest mismatch for Workspace {workspace_id}"
|
||||||
)));
|
)));
|
||||||
@@ -155,6 +154,49 @@ mod tests {
|
|||||||
assert_eq!(projection.default_runtime_id, None);
|
assert_eq!(projection.default_runtime_id, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn runtime_projection_treats_pre_runtime_schema_bundle_as_unconfigured() {
|
||||||
|
let bundle =
|
||||||
|
config_source::WorkspaceConfigSchemaBundle::compose([ConfigSchemaContribution::new(
|
||||||
|
"builtin:legacy",
|
||||||
|
"legacy",
|
||||||
|
"1",
|
||||||
|
"{ legacy = { enabled = Bool default false; }; }",
|
||||||
|
)
|
||||||
|
.unwrap()])
|
||||||
|
.unwrap();
|
||||||
|
let snapshot = ConfigTreeSnapshot::from_entries(
|
||||||
|
6,
|
||||||
|
[ConfigEntry::new(
|
||||||
|
VirtualPath::parse("main.dcdl").unwrap(),
|
||||||
|
ConfigContentType::Decodal,
|
||||||
|
"{ legacy = { enabled = true; }; } as WorkspaceConfigSchema",
|
||||||
|
)
|
||||||
|
.unwrap()],
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let contract = config_source::ToolchainContract::with_schema_bundle(
|
||||||
|
config_source::DEFAULT_SCHEMA_VERSION,
|
||||||
|
vec![VirtualPath::parse("main.dcdl").unwrap()],
|
||||||
|
config_source::DEFAULT_IMPORT_POLICY_VERSION,
|
||||||
|
bundle,
|
||||||
|
);
|
||||||
|
let projection_digest = config_source::SnapshotEnvironment::new(snapshot.clone())
|
||||||
|
.evaluate_contract(&contract)
|
||||||
|
.unwrap()
|
||||||
|
.projection_digest;
|
||||||
|
let state = WorkspaceConfigState {
|
||||||
|
snapshot,
|
||||||
|
contract,
|
||||||
|
projection_digest: projection_digest.clone(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let projection = project_runtime_from_workspace_config("workspace", &state).unwrap();
|
||||||
|
assert_eq!(projection.default_runtime_id, None);
|
||||||
|
assert_eq!(projection.config_revision, 6);
|
||||||
|
assert_eq!(projection.projection_digest, projection_digest);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn runtime_schema_rejects_non_string_default() {
|
fn runtime_schema_rejects_non_string_default() {
|
||||||
let bundle =
|
let bundle =
|
||||||
|
|||||||
Reference in New Issue
Block a user