Skip to content

Commit

Permalink
README example update (#181)
Browse files Browse the repository at this point in the history
- Update fruit example
- Read me updates
  • Loading branch information
BernieWhite authored Jun 15, 2019
1 parent f140054 commit 5afcea6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The following example shows basic PSRule usage. For specific use cases see [scen

### Define a rule

To define a rule use the `Rule` keyword.
To define a rule, use a `Rule` block saved to a file with the `.Rule.ps1` extension.

```powershell
Rule 'NameOfRule' {
Expand All @@ -45,25 +45,26 @@ Within the body of the rule provide one or more conditions. A condition is valid
For example:

```powershell
# Saved to isFruit.Rule.ps1
Rule 'isFruit' {
# Condition to determine if the object is fruit
$TargetObject.Name -in 'Apple', 'Orange', 'Pear'
}
```

An optional result message can be added to by using the `Hint` keyword.
An optional result message can be added to by using the `Recommend` keyword.

```powershell
Rule 'isFruit' {
# An additional message to display in output
Hint 'Fruit is only Apple, Orange and Pear'
Recommend 'Fruit is only Apple, Orange and Pear'
# Condition to determine if the object is fruit
$TargetObject.Name -in 'Apple', 'Orange', 'Pear'
}
```

The rule above is saved to the [`isFruit.Rule.ps1`](docs/scenarios/fruit/isFruit.Rule.ps1) file. One or more rules can be defined within a single file.

### Execute a rule

To execute the rule use `Invoke-PSRule`.
Expand Down
12 changes: 6 additions & 6 deletions docs/scenarios/azure-tags/azure-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,24 +244,24 @@ Our output looked like this:
```text
TargetName: storage
RuleName Outcome Message
-------- ------- -------
RuleName Outcome Recommendation
-------- ------- --------------
costCentreTag Fail Resource must have costCentre tag
businessUnitTag Fail Resource must have businessUnit tag
TargetName: web-app
RuleName Outcome Message
-------- ------- -------
RuleName Outcome Recommendation
-------- ------- --------------
environmentTag Fail Resource must have environment tag
costCentreTag Fail Resource must have costCentre tag
TargetName: web-app/staging
RuleName Outcome Message
-------- ------- -------
RuleName Outcome Recommendation
-------- ------- --------------
environmentTag Fail Resource must have environment tag
costCentreTag Fail Resource must have costCentre tag
```
Expand Down
3 changes: 2 additions & 1 deletion docs/scenarios/fruit/isFruit.Rule.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

# Synopsis: An example rule
Rule 'isFruit' {
# An additional message to display in output
Hint 'Fruit is only Apple, Orange and Pear'
Recommend 'Fruit is only Apple, Orange and Pear'

# Condition to determine if the object is fruit
$TargetObject.Name -in 'Apple', 'Orange', 'Pear'
Expand Down
12 changes: 6 additions & 6 deletions docs/scenarios/kubernetes-resources/kubernetes-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,26 @@ The resulting output is:
```text
TargetName: app1-cache
RuleName Outcome Message
-------- ------- -------
RuleName Outcome Recommendation
-------- ------- --------------
deployment.HasMinimumReplicas Fail Deployments use a minimum of 2 replicas
deployment.NotLatestImage Fail Deployments use specific tags
deployment.ResourcesSet Fail Resource requirements are set for each container
TargetName: app1-cache-service
RuleName Outcome Message
-------- ------- -------
RuleName Outcome Recommendation
-------- ------- --------------
metadata.Name Fail Must have the app.kubernetes.io/name label
metadata.Version Fail Must have the app.kubernetes.io/version label
metadata.Component Fail Must have the app.kubernetes.io/component label
TargetName: app1-ui
RuleName Outcome Message
-------- ------- -------
RuleName Outcome Recommendation
-------- ------- --------------
metadata.Version Fail Must have the app.kubernetes.io/version label
```

Expand Down
8 changes: 4 additions & 4 deletions docs/scenarios/validation-pipeline/validation-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ if ($Null -eq (Get-PackageProvider -Name NuGet -ErrorAction Ignore)) {
$Null = Install-PackageProvider -Name NuGet -Scope CurrentUser -Force;
}
if ($Null -eq (Get-InstalledModule -Name PSRule -MinimumVersion '0.5.0' -ErrorAction Ignore)) {
$Null = Install-Module -Name PSRule -Scope CurrentUser -MinimumVersion '0.5.0' -Force;
if ($Null -eq (Get-InstalledModule -Name PSRule -MinimumVersion '0.6.0' -ErrorAction Ignore)) {
$Null = Install-Module -Name PSRule -Scope CurrentUser -MinimumVersion '0.6.0' -Force;
}
```

Expand All @@ -57,8 +57,8 @@ task InstallNuGet {
# Synopsis: Install PSRule
task InstallPSRule InstallNuGet, {
if ($Null -eq (Get-InstalledModule -Name PSRule -MinimumVersion '0.5.0' -ErrorAction Ignore)) {
$Null = Install-Module -Name PSRule -Scope CurrentUser -MinimumVersion '0.5.0' -Force;
if ($Null -eq (Get-InstalledModule -Name PSRule -MinimumVersion '0.6.0' -ErrorAction Ignore)) {
$Null = Install-Module -Name PSRule -Scope CurrentUser -MinimumVersion '0.6.0' -Force;
}
}
```
Expand Down

0 comments on commit 5afcea6

Please sign in to comment.