Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --system-root parameter, systemRoot() and path() functions to dsc #589

Merged
merged 17 commits into from
Nov 17, 2024

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Oct 29, 2024

PR Summary

To enable offline configuration management, add --system-root parameter and systemRoot() function (takes no arguments) to DSC. The provided path must exist. Supported resources would need to accept the path to use rather than the current running OS.
If --system-root is not specified, then systemRoot() will default to $env:SYSTEMDRIVE on Windows and / on Linux/macOS.
Also added path() function that takes any number of strings and concatenates it with the OS directory separator char.

PR Context

Fix #534

@SteveL-MSFT SteveL-MSFT marked this pull request as ready for review October 29, 2024 04:27
@michaeltlombardi michaeltlombardi added the Schema-Impact Change requires updating a canonical schema for configs or manifests label Oct 29, 2024
@SteveL-MSFT
Copy link
Member Author

SteveL-MSFT commented Oct 29, 2024

Thinking about this further, I'm going to propose a few changes:

  • rename parameter --mounted-path to --target-path to make it more general
  • validate value of --target-path as existing otherwise error
  • don't have targetPath() accept any arguments
  • add new path(a, b, c) function that takes arbitrary number of parameters and just concatenates them with directory separator appropriate to the OS it's running on in between

The use of targetPath() should indicate that the configuration can work offline and online where it's an empty string if not provided via --target-path. The new path() function would enable use like [path(env('HOME'), '.data')] or [path(targetPath(), 'Windows', 'System32')].

Although for the latter case to work online, targetPath() would need to return the current OS drive on Windows like C: and I suppose on non-Windows it would simply be /.

@SteveL-MSFT SteveL-MSFT changed the title Add --mounted-path parameter to dsc Add --target-path parameter, targetPath() and path() functions to dsc Oct 30, 2024
@tgauth
Copy link
Collaborator

tgauth commented Oct 30, 2024

Would it be helpful to have some sort of info logging (maybe in the parser?) in the case of --target-path being provided without TargetPath() or is it obvious that --target-path would be ignored?

@SteveL-MSFT
Copy link
Member Author

SteveL-MSFT commented Oct 30, 2024

Would it be helpful to have some sort of info logging (maybe in the parser?) in the case of --target-path being provided without TargetPath() or is it obvious that --target-path would be ignored?

That could be useful as a warning message if the user provided --target-path but the configuration doesn't use it. The challenge is that expressions are parsed at runtime, so the warning would only happen at the end after configuration was run. I think this is ok.

Creatd #591 for future static linting work

@SteveL-MSFT SteveL-MSFT changed the title Add --target-path parameter, targetPath() and path() functions to dsc Add --system-root parameter, systemRoot() and path() functions to dsc Nov 2, 2024
@SteveL-MSFT
Copy link
Member Author

Decided to rename to systemRoot instead of targetPath as it more accurately describes what it does

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Nov 17, 2024
Merged via the queue into PowerShell:main with commit 51ebbe3 Nov 17, 2024
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the mounted-path branch November 17, 2024 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Doc-Impact Schema-Impact Change requires updating a canonical schema for configs or manifests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offline image configuration
3 participants