Skip to content

Commit

Permalink
Code Review Updates (#8)
Browse files Browse the repository at this point in the history
* Code Review Fixes (#7)

* Initial Commit

* Code Review Adjustments

---------

Co-authored-by: Michael Zanatta <[email protected]>

* Replace comment with amended version

* Adding Install-Module and Install-PSResource commands.

* Bug Fixes

* Big Fixes with Unit Tests

---------

Co-authored-by: Michael Zanatta <[email protected]>
  • Loading branch information
ZanattaMichael and Michael Zanatta authored Jan 8, 2025
1 parent 5f3d038 commit c4e2c1d
Show file tree
Hide file tree
Showing 51 changed files with 142 additions and 153 deletions.
30 changes: 30 additions & 0 deletions .build/tasks/1.PreLoad.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
task PreLoad {

# Write a script to check the PSModule Path and add the output/
# folder to the PSModule Path

# Get the output directory
$RepositoryRoot = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$outputDir = Join-Path -Path $RepositoryRoot -ChildPath 'output'
$supportingModules = Join-Path -Path $RepositoryRoot -ChildPath 'output/AzureDevOpsDsc/0.0.1/Modules'

# Test if the output and supporting modules directories exist in the PSModulePath
if (-not $IsWindows) {
$modulelist = ($env:PSModulePath -split ":")
$delimiter = ":"
} else {
$modulelist = ($env:PSModulePath -split ";")
$delimiter = ";"
}

# Check if the output directory is in the moduleList
if ($moduleList -notcontains $outputDir) {
$env:PSModulePath = "{0}{1}{2}" -f $env:PSModulePath, $delimiter, $outputDir
Write-Host "Adding $outputDir to PSModulePath"
}
if ($moduleList -notcontains $supportingModules) {
$env:PSModulePath = "{0}{1}{2}" -f $env:PSModulePath, $delimiter, $supportingModules
Write-Host "Adding $supportingModules to PSModulePath"
}

}
50 changes: 50 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,56 @@ Ensure you have the following prerequisites before proceeding:
- `Sampler`
- `xDSCResourceDesigner`

__Using Install-Module__

``` PowerShell
# Run as Administrator
Install-Module -Scope AllUsers -Name @(
'ChangelogManagement'
'Configuration'
'DscResource.AnalyzerRules'
'DscResource.Common'
'DscResource.DocGenerator'
'DscResource.Test'
'InvokeBuild'
'MarkdownLinkCheck'
'Metadata'
'ModuleBuilder'
'Pester'
'Plaster'
'PSDepend'
'PSDscResources'
'PSScriptAnalyzer'
'Sampler'
'xDSCResourceDesigner'
)
```

__Using Install-PSResource__

``` PowerShell
# Run as Administrator
Install-PSResource @(
'ChangelogManagement'
'Configuration'
'DscResource.AnalyzerRules'
'DscResource.Common'
'DscResource.DocGenerator'
'DscResource.Test'
'InvokeBuild'
'MarkdownLinkCheck'
'Metadata'
'ModuleBuilder'
'Pester'
'Plaster'
'PSDepend'
'PSDscResources'
'PSScriptAnalyzer'
'Sampler'
'xDSCResourceDesigner'
)
```

### *AZDODSC_CACHE_DIRECTORY* Environment Variable

The system environment variable `AZDODSC_CACHE_DIRECTORY` is used by the module
Expand Down
2 changes: 2 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ BuildWorkflow:
- test

build:
- PreLoad
- Clean
- Build_Module_ModuleBuilder
- Build_NestedModules_ModuleBuilder
Expand All @@ -46,6 +47,7 @@ BuildWorkflow:
- DscResource_Tests_Stop_On_Fail

test:
- PreLoad
- Pester_Tests_Stop_On_Fail
- Pester_if_Code_Coverage_Under_Threshold

Expand Down
5 changes: 4 additions & 1 deletion source/Classes/002.PersonalAccessToken.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class PersonalAccessToken : AuthenticationToken
}

[Bool]isExpired() {
# Personal Access Tokens do not expire.

# Personal Access Tokens don't contain expiry information. Without performing a global lookup of PAT tokens,
# we can't determine if a PAT is expired Therefore, we always return $false.

return $false
}

Expand Down
4 changes: 2 additions & 2 deletions source/Classes/009.AzDoGroupPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
The AzDoGroupPermission class is a DSC resource that allows you to manage permissions for a group in an Azure DevOps project.
.NOTES
Author: Your Name
Date: Current Date
Author: Michael Zanatta
Date: 2025-01-06
.LINK
GitHub Repository: <link to the GitHub repository>
Expand Down
2 changes: 1 addition & 1 deletion source/Classes/011.AzDoOrganizationGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.NOTES
Author: Michael Zanatta
Date: 04/19/2024
Date: 2025-01-06
.LINK
GitHub Repository: <link to the GitHub repository>
Expand Down
4 changes: 2 additions & 2 deletions source/Classes/020.AzDoProject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
The AzDoProject class is used to define and manage Azure DevOps projects. It inherits from the AzDevOpsDscResourceBase class.
.NOTES
Author: Your Name
Date: Current Date
Author: Michael Zanatta
Date: 2025-01-06
.LINK
GitHub Repository: <link to the GitHub repository>
Expand Down
2 changes: 1 addition & 1 deletion source/Classes/021.AzDoProjectServices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
.NOTES
Version: 1.0
Author: Your Name
Author: Michael Zanatta
Required Modules: xAzDevOpsDSC
#>

Expand Down
2 changes: 1 addition & 1 deletion source/Classes/022.AzDoProjectGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.NOTES
Author: Michael Zanatta
Date: 04/19/2024
Date: 2025-01-06
.LINK
GitHub Repository: <link to your GitHub repository>
Expand Down
4 changes: 2 additions & 2 deletions source/Classes/031.AzDoGroupMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
It inherits from the AzDevOpsDscResourceBase class.
.NOTES
Author: Your Name
Date: Current Date
Author: Michael Zanatta
Date: 2025-01-06
.LINK
GitHub Repository: <link to the GitHub repository>
Expand Down
4 changes: 2 additions & 2 deletions source/Classes/040.AzDoGitRepository.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
It inherits from the AzDevOpsDscResourceBase class.
.NOTES
Author: Your Name
Date: Current Date
Author: Michael Zanatta
Date: 2025-01-06
.LINK
GitHub Repository: <link to the GitHub repository>
Expand Down
2 changes: 1 addition & 1 deletion source/Classes/041.AzDoGitPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
This class is part of the AzureDevOpsDSC module.
.LINK
https://github.com/Azure/AzureDevOpsDSC
https://github.com/dsccommunity/AzureDevOpsDsc
.EXAMPLE
This example shows how to use the AzDoGitPermission class to manage Git permissions in Azure DevOps.
Expand Down
1 change: 0 additions & 1 deletion source/Enum/DescriptorType.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,4 @@ Enum DescriptorType {
DashboardsPrivileges
CSS
VersionControlItems

}
12 changes: 6 additions & 6 deletions source/Examples/Resources/AzDoGitPermission.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ AzDoGitPermission/Permissions/Permission

## Permission List

> Either 'Name' or 'DisplayName' can be used
> Either 'Name' or 'DisplayName' can be used, but we Strongly Recommend that you use 'Name' in your configuration.
| Name | DisplayName | Values | Note |
| ------------- | ------------- | - | - |
Expand Down Expand Up @@ -92,8 +92,8 @@ Configuration ExampleConfig {
Identity = '[ProjectName]\GroupName'
Permissions = @{
Read = 'Allow'
"Manage Notes" = 'Allow'
"Contribute" = 'Deny'
ManageNote = 'Allow'
Contribute = 'Deny'
}
}
)
Expand All @@ -120,8 +120,8 @@ $properties = @{
Identity = '[ProjectName]\GroupName'
Permissions = @{
Read = 'Allow'
"Manage Notes" = 'Allow'
"Contribute" = 'Deny'
ManageNote = 'Allow'
Contribute = 'Deny'
}
}
)
Expand Down Expand Up @@ -173,7 +173,7 @@ resources:
- Identity: '[$ProjectName]\SampleGroupReadAccess'
Permission:
Read: "Allow"
"Manage notes": "Allow"
ManageNote: "Allow"
```
LCM Initialization:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
This example shows how to update the Git Repository
#>

# Not Supported
# Not Currently Supported
2 changes: 1 addition & 1 deletion source/Examples/Resources/AzDoGroupPermission.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AzDoGroupPermission Resource Documentation (Currently Disabled)
# AzDoGroupPermission Resource Documentation (Not Currently Supported)

## Overview

Expand Down
2 changes: 0 additions & 2 deletions source/Examples/Resources/AzDoOrganizationGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ Configuration ExampleConfig {
}
}
OrgGroup
Start-DscConfiguration -Path ./ExampleConfig -Wait -Verbose
```

## Example 2: Sample Configuration using Invoke-DSCResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $cacheItem = [CacheItem]::new("exampleKey", "exampleValue")
Creates a new CacheItem instance with the key "exampleKey" and the value "exampleValue".
.NOTES
Author: Your Name
Author: Michael Zanatta
#>

class CacheItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ function Update-DevOpsProject
$body = @{
name = $ProjectName
visibility = $Visibility
<#
TODO: ISSUE with updating the ProcessTemplateId.
capabilities = @{
processTemplate = @{
templateTypeId = $ProcessTemplateId
}
}
#>
}

# Add the description if provided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
Wait-DevOpsProject -OrganizationName "MyOrg" -ProjectURL "https://dev.azure.com/MyOrg/MyProject"
.NOTES
Author: Your Name
Date: Current Date
Author: Michael Zanatta
Date: 2025-01-06
#>

Function Wait-DevOpsProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ None.
None.
.NOTES
Author: [Author Name]
Date: [Date]
Author: Michael Zanatta
Date: 2025-01-06
#>

Function AzDoAPI_0_ProjectCache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ $filteredCacheItem
# Returns the CacheItem with the name 'MyCacheItem' from the list of cache items.
.NOTES
Author: Your Name
Date: Today's Date
Author: Michael Zanatta
Date: 2025-01-06
#>
Function Find-CacheItem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The cache object of the specified type.
This function is part of the AzureDevOpsDsc module.
.LINK
https://github.com/Azure/AzureDevOpsDsc
https://github.com/dsccommunity/AzureDevOpsDsc
#>
function Get-CacheObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ None.
None.
.NOTES
Author: Your Name
Date: MM/DD/YYYY
Author: Michael Zanatta
Date: 2025-01-06
#>

function Set-CacheObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ ConvertTo-ACEList -SecurityNamespace "Namespace" -Identity "User1" -Permissions
This example converts the permissions "Read" and "Write" for the identity "User1" in the specified security namespace and organization name to an ACE token.
.NOTES
Author: Your Name
Date: Today's Date
Author: Michael Zanatta
Date: 2025-01-06
#>

Function ConvertTo-ACEList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ System.Collections.Generic.List[HashTable]
A list of Access Control Lists (ACLs) created from the provided permissions.
.NOTES
Author: Your Name
Date: Today's Date
Author: Michael Zanatta
Date: 2025-01-06
#>
Function ConvertTo-ACL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ A list of formatted ACLs.
.NOTES
Author: Michael Zanatta
Date: 06/26/2024
Date: 2025-01-06
#>

Function ConvertTo-FormattedACL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# Output: 15
.NOTES
Author: Your Name
Date: Current Date
Author: Michael Zanatta
Date: 2025-01-06
#>
Function Get-BitwiseOrResult
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $base64String
.NOTES
Author: GitHub Copilot
Date: September 2021
Date: 2025-01-06
#>
function ConvertTo-Base64String
{
Expand Down
Loading

0 comments on commit c4e2c1d

Please sign in to comment.