Skip to content

Commit 2b72deb

Browse files
authored
Merge branch 'main' into date_fix
2 parents 1d661e5 + 2ef6308 commit 2b72deb

File tree

7 files changed

+107
-96
lines changed

7 files changed

+107
-96
lines changed

.pipelines/DSC-Official.yml

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extends:
3636
WindowsHostVersion:
3737
Disk: Large
3838
Version: 2022
39-
Network: KS3 # this retricts network access to public upstream repositories
39+
Network: KS1 # note that this property is sticky so commenting out will use the previous set one
4040
# Currently can't be used as some NPM pkgs like tree-sitter-cli reach out to GitHub to get the actual zip pkg
4141
# Network: NetLock
4242
customTags: 'ES365AIMigrationTooling'
@@ -201,16 +201,20 @@ extends:
201201
dependsOn: BuildWin
202202
variables:
203203
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
204+
ob_sdl_tsa_configFile: '$(Build.SourcesDirectory)\DSC\.config\tsaoptions.json'
205+
ob_sdl_sbom_enabled: true
206+
ob_signing_setup_enabled: true
207+
ob_sdl_codeql_compiled_enabled: true
204208
pool:
205209
type: windows
206210
steps:
211+
- checkout: self
207212
- download: current
208213
artifact: drop_BuildAndSign_BuildWinx64
209214
patterns: '*.msix'
210215
- download: current
211216
artifact: drop_BuildAndSign_BuildWinarm64
212217
patterns: '*.msix'
213-
- checkout: self
214218
- pwsh: |
215219
Set-Location "$(Build.SourcesDirectory)/DSC"
216220
$null = New-Item -ItemType Directory -Path "./bin/msix" -Force -ErrorAction Ignore
@@ -221,25 +225,6 @@ extends:
221225
displayName: 'Create msixbundle'
222226
condition: succeeded()
223227
224-
- job: PublishSigned
225-
dependsOn: BuildWin
226-
variables:
227-
signOutPath: $[ dependencies.BuildWin.outputs['signOutPath.signOutPath'] ]
228-
ob_sdl_tsa_configFile: $(Build.SourcesDirectory)\DSC\.config\tsaoptions.json
229-
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
230-
ob_sdl_sbom_enabled: false
231-
ob_signing_setup_enabled: false
232-
ob_sdl_codeql_compiled_enabled: false
233-
pool:
234-
type: windows
235-
steps:
236-
- task: CopyFiles@2
237-
displayName: "Copy Files for 'PublishPipelineArtifact@1' publish task"
238-
inputs:
239-
SourceFolder: $(signOutPath)
240-
Contents: '**'
241-
TargetFolder: $(Build.ArtifactStagingDirectory)/signed
242-
243228
- job: BuildLinux
244229
dependsOn: SetPackageVersion
245230
variables:
@@ -382,12 +367,9 @@ extends:
382367
383368
- stage: Release
384369
dependsOn: BuildAndSign
370+
condition: ne(variables['Build.Reason'], 'Schedule')
385371
variables:
386372
PackageVersion: $[ dependencies.SetPackageVersion.outputs['Package.Version'] ]
387-
ob_sdl_sbom_enabled: false
388-
ob_signing_setup_enabled: false
389-
ob_sdl_codeql_compiled_enabled: false
390-
drop: $(Pipeline.Workspace)/drop_build_main
391373
jobs:
392374
- job: Validation
393375
displayName: Manual validation
@@ -407,10 +389,17 @@ extends:
407389
pool:
408390
type: windows
409391
variables:
410-
ob_outputDirectory: '$(Build.SourcesDirectory)'
392+
ob_outputDirectory: '$(Build.ArtifactStagingDirectory)'
393+
ob_sdl_sbom_enabled: false
394+
ob_signing_setup_enabled: false
395+
ob_sdl_codeql_compiled_enabled: false
396+
drop: $(Pipeline.Workspace)/drop_build_main
411397
steps:
412398
- download: current
413399
displayName: Download artifacts
400+
patterns: |
401+
'**/*.zip'
402+
'**/*.tar.gz'
414403
- task: GitHubRelease@1
415404
displayName: Create GitHub release
416405
inputs:

dsc/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dsc/src/resource_command.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::args::OutputFormat;
55
use crate::util::{EXIT_DSC_ERROR, EXIT_INVALID_ARGS, EXIT_JSON_ERROR, add_type_name_to_json, write_output};
66
use dsc_lib::configure::config_doc::{Configuration, ExecutionKind};
77
use dsc_lib::configure::add_resource_export_results_to_configuration;
8-
use dsc_lib::dscresources::invoke_result::{GetResult, ResourceGetResponse};
8+
use dsc_lib::dscresources::{resource_manifest::Kind, invoke_result::{GetResult, ResourceGetResponse}};
99
use dsc_lib::dscerror::DscError;
1010
use tracing::{error, debug};
1111

@@ -22,6 +22,11 @@ pub fn get(dsc: &DscManager, resource_type: &str, mut input: String, format: &Op
2222
};
2323

2424
debug!("resource.type_name - {} implemented_as - {:?}", resource.type_name, resource.implemented_as);
25+
if resource.kind == Kind::Adapter {
26+
error!("Can not perform this operation on the adapter {} itself", resource.type_name);
27+
exit(EXIT_DSC_ERROR);
28+
}
29+
2530
if let Some(requires) = &resource.require_adapter {
2631
input = add_type_name_to_json(input, resource.type_name.clone());
2732
if let Some(pr) = get_resource(dsc, requires) {
@@ -59,6 +64,11 @@ pub fn get_all(dsc: &DscManager, resource_type: &str, format: &Option<OutputForm
5964
};
6065

6166
debug!("resource.type_name - {} implemented_as - {:?}", resource.type_name, resource.implemented_as);
67+
if resource.kind == Kind::Adapter {
68+
error!("Can not perform this operation on the adapter {} itself", resource.type_name);
69+
exit(EXIT_DSC_ERROR);
70+
}
71+
6272
if let Some(requires) = &resource.require_adapter {
6373
input = add_type_name_to_json(input, resource.type_name.clone());
6474
if let Some(pr) = get_resource(dsc, requires) {
@@ -106,6 +116,10 @@ pub fn set(dsc: &DscManager, resource_type: &str, mut input: String, format: &Op
106116
};
107117

108118
debug!("resource.type_name - {} implemented_as - {:?}", resource.type_name, resource.implemented_as);
119+
if resource.kind == Kind::Adapter {
120+
error!("Can not perform this operation on the adapter {} itself", resource.type_name);
121+
exit(EXIT_DSC_ERROR);
122+
}
109123

110124
if let Some(requires) = &resource.require_adapter {
111125
input = add_type_name_to_json(input, resource.type_name.clone());
@@ -148,6 +162,10 @@ pub fn test(dsc: &DscManager, resource_type: &str, mut input: String, format: &O
148162
};
149163

150164
debug!("resource.type_name - {} implemented_as - {:?}", resource.type_name, resource.implemented_as);
165+
if resource.kind == Kind::Adapter {
166+
error!("Can not perform this operation on the adapter {} itself", resource.type_name);
167+
exit(EXIT_DSC_ERROR);
168+
}
151169

152170
if let Some(requires) = &resource.require_adapter {
153171
input = add_type_name_to_json(input, resource.type_name.clone());
@@ -185,6 +203,10 @@ pub fn delete(dsc: &DscManager, resource_type: &str, mut input: String) {
185203
};
186204

187205
debug!("resource.type_name - {} implemented_as - {:?}", resource.type_name, resource.implemented_as);
206+
if resource.kind == Kind::Adapter {
207+
error!("Can not perform this operation on the adapter {} itself", resource.type_name);
208+
exit(EXIT_DSC_ERROR);
209+
}
188210

189211
if let Some(requires) = &resource.require_adapter {
190212
input = add_type_name_to_json(input, resource.type_name.clone());
@@ -210,6 +232,11 @@ pub fn schema(dsc: &DscManager, resource_type: &str, format: &Option<OutputForma
210232
error!("{}", DscError::ResourceNotFound(resource_type.to_string()).to_string());
211233
return
212234
};
235+
if resource.kind == Kind::Adapter {
236+
error!("Can not perform this operation on the adapter {} itself", resource.type_name);
237+
exit(EXIT_DSC_ERROR);
238+
}
239+
213240
match resource.schema() {
214241
Ok(json) => {
215242
// verify is json
@@ -236,6 +263,11 @@ pub fn export(dsc: &mut DscManager, resource_type: &str, format: &Option<OutputF
236263
return
237264
};
238265

266+
if dsc_resource.kind == Kind::Adapter {
267+
error!("Can not perform this operation on the adapter {} itself", dsc_resource.type_name);
268+
exit(EXIT_DSC_ERROR);
269+
}
270+
239271
let mut adapter_resource: Option<&DscResource> = None;
240272
if let Some(requires) = &dsc_resource.require_adapter {
241273
input = add_type_name_to_json(input, dsc_resource.type_name.clone());

dsc/tests/dsc_args.tests.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,40 @@ resources:
272272
$stderr = dsc config get -d $configFile 2>&1
273273
$stderr | Should -Match '.*?--path.*?'
274274
}
275+
276+
It 'Get operation on the adapter itself should fail' {
277+
dsc resource get -r Microsoft.DSC/PowerShell 2> $TestDrive/tracing.txt
278+
$LASTEXITCODE | Should -Be 2
279+
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Can not perform this operation on the adapter'
280+
}
281+
282+
It 'Get-all operation on the adapter itself should fail' {
283+
dsc resource get --all -r Microsoft.DSC/PowerShell 2> $TestDrive/tracing.txt
284+
$LASTEXITCODE | Should -Be 2
285+
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Can not perform this operation on the adapter'
286+
}
287+
288+
It 'Set operation on the adapter itself should fail' {
289+
'abc' | dsc resource set -r Microsoft.DSC/PowerShell 2> $TestDrive/tracing.txt
290+
$LASTEXITCODE | Should -Be 2
291+
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Can not perform this operation on the adapter'
292+
}
293+
294+
It 'Test operation on the adapter itself should fail' {
295+
'abc' | dsc resource test -r Microsoft.DSC/PowerShell 2> $TestDrive/tracing.txt
296+
$LASTEXITCODE | Should -Be 2
297+
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Can not perform this operation on the adapter'
298+
}
299+
300+
It 'Export operation on the adapter itself should fail' {
301+
dsc resource export -r Microsoft.DSC/PowerShell 2> $TestDrive/tracing.txt
302+
$LASTEXITCODE | Should -Be 2
303+
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Can not perform this operation on the adapter'
304+
}
305+
306+
It 'Delete operation on the adapter itself should fail' {
307+
dsc resource delete -r Microsoft.DSC/PowerShell 2> $TestDrive/tracing.txt
308+
$LASTEXITCODE | Should -Be 2
309+
"$TestDrive/tracing.txt" | Should -FileContentMatchExactly 'Can not perform this operation on the adapter'
310+
}
275311
}

tree-sitter-dscexpression/build.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if ($null -eq (Get-Command npm -ErrorAction Ignore)) {
2929
}
3030
}
3131

32-
npm install
32+
npm ci --omit:optional --force --registry https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/npm/registry/
3333

3434
#npm list tree-sitter-cli
3535
#if ($LASTEXITCODE -ne 0) {
@@ -46,10 +46,11 @@ if ($UpdatePackages) {
4646
rm ./package-lock.json
4747
rm -r ./node_modules
4848
npm cache clean --force
49-
npm logout
50-
vsts-npm-auth -config .npmrc -F -V
51-
npm install --force --verbose --registry https://pkgs.dev.azure.com/mseng/_packaging/OneESD-DevOps/npm/registry/
49+
# npm logout
50+
# vsts-npm-auth -config .npmrc -F -V
51+
npm install --omit:optional --force --verbose #--registry https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/npm/registry/
5252
}
5353

54+
Invoke-NativeCommand 'npx node-gyp configure'
5455
Invoke-NativeCommand 'npx tree-sitter generate --build'
5556
Invoke-NativeCommand 'npx tree-sitter test'

tree-sitter-dscexpression/package-lock.json

Lines changed: 11 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)