-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rule: adminUsername-should-not-be-literal (#4702)
* rule: adminUsername-should-not-be-literal * Check compile errors in all linter tests * PR comments * Update test baselines * Fix file casing * Fix completion tests * Update test baselines Co-authored-by: Stephen Weatherford <stephen.weatherford@microsoft.com> Co-authored-by: Bicep Automation <bicep@noreply.github.com>
- Loading branch information
1 parent
1aa04b8
commit 4fc99de
Showing
24 changed files
with
955 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# AdminUserName should not be a literal | ||
|
||
**Code**: adminUsername-should-not-be-literal | ||
|
||
**Description**: When setting an adminUserName property, don't use a literal value or an expression which evaluates to a literal value. | ||
Create a parameter for the username and use an expression to reference the parameter's value. | ||
|
||
The following examples fail this test. | ||
|
||
```bicep | ||
resource vm 'Microsoft.Compute/virtualMachines@2020-12-01' = { | ||
name: 'name' | ||
location: location | ||
properties: { | ||
osProfile: { | ||
adminUsername: 'adminUsername' | ||
} | ||
} | ||
} | ||
``` | ||
|
||
```bicep | ||
var defaultAdmin = 'administrator' | ||
resource vm 'Microsoft.Compute/virtualMachines@2020-12-01' = { | ||
name: 'name' | ||
location: location | ||
properties: { | ||
osProfile: { | ||
adminUsername: defaultAdmin | ||
} | ||
``` | ||
|
||
The following example passes this test. | ||
|
||
```bicep | ||
@secure() | ||
param adminUsername string | ||
param location string | ||
resource vm 'Microsoft.Compute/virtualMachines@2020-12-01' = { | ||
name: 'name' | ||
location: location | ||
properties: { | ||
osProfile: { | ||
adminUsername: adminUsername | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.