Skip to content

Commit 10a3ef1

Browse files
committed
separate out resources and extensions
1 parent e783aa4 commit 10a3ef1

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
@@ -39,16 +39,10 @@ static RESOURCES: LazyLock<RwLock<BTreeMap<String, Vec<DscResource>>>> = LazyLoc
3939
static EXTENSIONS: LazyLock<RwLock<BTreeMap<String, DscExtension>>> = LazyLock::new(|| RwLock::new(BTreeMap::new()));
4040
static ADAPTED_RESOURCES: LazyLock<RwLock<BTreeMap<String, Vec<DscResource>>>> = LazyLock::new(|| RwLock::new(BTreeMap::new()));
4141

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

5448
#[derive(Clone, Serialize, Deserialize, JsonSchema)]
@@ -685,16 +679,16 @@ pub fn load_manifest(path: &Path) -> Result<Vec<ImportedManifest>, DscError> {
685679
}
686680
};
687681
let mut resources = vec![];
688-
for res_manifest in manifest_list.manifests {
689-
match res_manifest {
690-
Manifest::Extension(ext_manifest) => {
691-
let extension = load_extension_manifest(path, &ext_manifest)?;
692-
resources.push(ImportedManifest::Extension(extension));
693-
},
694-
Manifest::Resource(res_manifest) => {
695-
let resource = load_resource_manifest(path, &res_manifest)?;
696-
resources.push(ImportedManifest::Resource(resource));
697-
}
682+
if let Some(resource_manifests) = &manifest_list.resources {
683+
for res_manifest in resource_manifests {
684+
let resource = load_resource_manifest(path, res_manifest)?;
685+
resources.push(ImportedManifest::Resource(resource));
686+
}
687+
}
688+
if let Some(extension_manifests) = &manifest_list.extensions {
689+
for ext_manifest in extension_manifests {
690+
let extension = load_extension_manifest(path, ext_manifest)?;
691+
resources.push(ImportedManifest::Extension(extension));
698692
}
699693
}
700694
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)