Closed LaurentDardenne closed 5 years ago
@LaurentDardenne Thanks for the feedback again.
The first issue is related to the rule not having a name i.e.
rule 'rulename' {
# conditions go here
}
Each rule must have a unique name.
The second exception is designed to fail. It's a unit test that is designed to raise an exception to make sure PSRule correctly returned the exception to the user.
To answer your questions:
For example, you can write a helper function such as here.
@LaurentDardenne hope that helps.
Yes Thanks.
Yes rule files can contain code outside of the rule block, there are a number of reasons why you might want to do this currently, although the long term plan is to provide alternatives.
In my opinion the fact that Get-PSrule executes the code of the rules found can have an edge effect in the caller. Am I wrong?
@LaurentDardenne Each call of Invoke-PSRule
or Get-PSRule
is executed in a separate runspace. So code included in rules can't contaminate the environment of the caller. Configuration and output is proxied in and out of the runspace by PSRule as required.
After execution is complete the runspace is cleaned up and a new runspace is used for the next execution.
So for all intents and purposes there isn't any edge effect on the caller, because they are isolated from each other.
Thank you, I was wrong :-)
Powershell version 5.1 , Windows 10 1803 PSRule version 0.7.0
With this wrong rule file:
I get an exception (it is correct):
But as beginner I dont known if the error is raised by the cmdlet Get-PSRule or one rule file.
Same remark here:
The file 'FromFileWithException.Rule.ps1' raise this exception, But I do not know. May be add a specific exception with the rule file name into the error message.
I have two question related to this case