Skip to content

Commit 830d31f

Browse files
committed
separate out resources and extensions
1 parent 55c52ef commit 830d31f

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

lib/dsc-lib/src/discovery/command_discovery.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,10 @@ static RESOURCES: LazyLock<RwLock<BTreeMap<String, Vec<DscResource>>>> = LazyLoc
3838
static EXTENSIONS: LazyLock<RwLock<BTreeMap<String, DscExtension>>> = LazyLock::new(|| RwLock::new(BTreeMap::new()));
3939
static ADAPTED_RESOURCES: LazyLock<RwLock<BTreeMap<String, Vec<DscResource>>>> = LazyLock::new(|| RwLock::new(BTreeMap::new()));
4040

41-
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]
42-
#[serde(untagged)]
43-
pub enum Manifest {
44-
Resource(Box<ResourceManifest>),
45-
Extension(Box<ExtensionManifest>),
46-
}
47-
4841
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema)]
4942
pub struct ManifestList {
50-
pub manifests: Vec<Manifest>,
43+
pub resources: Option<Vec<ResourceManifest>>,
44+
pub extensions: Option<Vec<ExtensionManifest>>,
5145
}
5246

5347
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
@@ -683,16 +677,16 @@ pub fn load_manifest(path: &Path) -> Result<Vec<ImportedManifest>, DscError> {
683677
}
684678
};
685679
let mut resources = vec![];
686-
for res_manifest in manifest_list.manifests {
687-
match res_manifest {
688-
Manifest::Extension(ext_manifest) => {
689-
let extension = load_extension_manifest(path, &ext_manifest)?;
690-
resources.push(ImportedManifest::Extension(extension));
691-
},
692-
Manifest::Resource(res_manifest) => {
693-
let resource = load_resource_manifest(path, &res_manifest)?;
694-
resources.push(ImportedManifest::Resource(resource));
695-
}
680+
if let Some(resource_manifests) = &manifest_list.resources {
681+
for res_manifest in resource_manifests {
682+
let resource = load_resource_manifest(path, res_manifest)?;
683+
resources.push(ImportedManifest::Resource(resource));
684+
}
685+
}
686+
if let Some(extension_manifests) = &manifest_list.extensions {
687+
for ext_manifest in extension_manifests {
688+
let extension = load_extension_manifest(path, ext_manifest)?;
689+
resources.push(ImportedManifest::Extension(extension));
696690
}
697691
}
698692
return Ok(resources);

tools/dsctest/dsctest.dsc.manifests.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"manifests": [
2+
"resources": [
33
{
44
"$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
55
"type": "Test/Delete",

0 commit comments

Comments
 (0)