PowerShell / DSC

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

Error when the variable referenced with `envvar()` doesn't exist #336

Closed michaeltlombardi closed 4 months ago

michaeltlombardi commented 4 months ago

Summary of the new feature / enhancement

As a user, I want my configuration to error when referencing an environment variable that doesn't exist instead of receiving an empty string and unpredictable behavior for my configuration.

Currently, the envvar() function returns an empty string when the referenced variable doesn't exist. This may be desirable, but it may also lead to other issues with the configuration.

Proposed technical implementation details (optional)

The envvar() function should either:

  1. Always error when the referenced variable doesn't exist, or
  2. Error by default, but have an optional second boolean parameter that indicates whether it should return an empty string if the variable doesn't exist.

In the latter case, this would enable some flexibility for users while defaulting to a stricter behavior.