PowerShell / DSC

This repo is for the DSC v3 project
MIT License
135 stars 22 forks source link

Rename `DSCConfigRoot` environment variable to `DSC_CONFIG_ROOT` and handle existing value #335

Closed michaeltlombardi closed 3 months ago

michaeltlombardi commented 4 months ago

Summary of the new feature / enhancement

As a user and integrator, I want the environment variables that DSC uses to follow a consistent naming standard and for DSC to warn if it's overriding an externally set value for the variable. This lowers cognitive load and helps users understand whether DSC is going to behave differently than they might otherwise expect.

Currently, DSC always sets the new DSCConfigRoot environment variable when a user specifies the --path option for a dsc config * command. This doesn't match the format of the existing DSC_RESOURCE_PATH environment variable, and non-Windows environment variables are typically uppercase.

Users, especially higher-order and integrating tools, may want to reference a root folder for the purposes of locating other files for the configuration to use, even when the configuration isn't saved to disk. In these cases, the user or tool would set the environment variable and call the dsc config * command with the --document option or by passing the document from stdin. This works as expected. However, if the environment variable has been manually set and the user calls the command with the --path option, DSC silently overrides the value of the existing environment variable instead of warning the user.

Proposed technical implementation details (optional)

  1. Rename the environment variable from DSCConfigRoot to DSC_CONFIG_ROOT.
  2. Check if the environment variable has already been set when the --path option is specified. If it has, write a warning message to the user indicating that the variable value is being overridden for the command with the parent folder of the specified document path.