Skip to content

Changes for making the release fetcher script public #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ Currently this tests for:
New-ALZEnvironment -o <output_directory>
```

## Additonal Cmdlets

### Update an existing Azure Landing Zone Environment

#### Downloads and pulls down the specified release version from the remote GitHub repository to a local directory


```powershell
Get-ALZGithubRelease -githubRepoUrl "https://github.com/Azure/ALZ-Bicep" -releases "v0.13.0" -directoryForReleases "C:\Repos\ALZ\accelerator\upstream-releases\"
```

## Development

### Development Prerequisites
Expand All @@ -69,7 +80,7 @@ Import-Module .\src\Artifacts\ALZ.psd1 -Force
## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

Expand Down
1 change: 1 addition & 0 deletions src/ALZ/ALZ.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'Get-ALZGithubRelease'
'New-ALZEnvironment'
'Test-ALZRequirement'
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
####################################
# Get-GithubRelease.ps1 #
# Get-ALZGithubRelease.ps1 #
####################################
# Version: 0.1.0
# Based on Invoke-GitHubReleaseFetcher by Jack Tracey:
Expand All @@ -19,7 +19,7 @@ Checks for the releases of a GitHub repository and downloads the latest release
#>


function Get-GithubRelease {
function Get-ALZGithubRelease {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, Position = 1, HelpMessage = "Please the provide the full URL of the GitHub repository you wish to check for the latest release.")]
Expand Down
4 changes: 3 additions & 1 deletion src/ALZ/Public/New-ALZEnvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function New-ALZEnvironment {
New-ALZDirectoryEnvironment -alzEnvironmentDestination $alzEnvironmentDestination | Out-String | Write-Verbose

$alzEnvironmentDestinationInternalCode = Join-Path $alzEnvironmentDestination "upstream-releases"
Get-GithubRelease -directoryForReleases $alzEnvironmentDestinationInternalCode -githubRepoUrl $bicepConfig.module_url -releases @($bicepConfig.version) | Out-String | Write-Verbose

Get-ALZGithubRelease -directoryForReleases $alzEnvironmentDestinationInternalCode -githubRepoUrl $bicepConfig.module_url -releases @($bicepConfig.version) | Out-String | Write-Verbose

Write-InformationColored "Copying ALZ-Bicep module to $alzEnvironmentDestinationInternalCode" -ForegroundColor Green -InformationAction Continue
Copy-ALZParametersFile -alzEnvironmentDestination $alzEnvironmentDestination -upstreamReleaseDirectory $(Join-Path $alzEnvironmentDestinationInternalCode $bicepConfig.version) -configFiles $bicepConfig.config_files | Out-String | Write-Verbose
Write-InformationColored "ALZ-Bicep source directory: $alzBicepSourceDirectory" -ForegroundColor Green -InformationAction Continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Import-Module $PathToManifest -Force
#-------------------------------------------------------------------------

InModuleScope 'ALZ' {
Describe 'Get-GithubRelease Function Tests' -Tag Unit {
Describe 'Get-ALZGithubRelease Function Tests' -Tag Unit {
BeforeAll {
$WarningPreference = 'SilentlyContinue'
$ErrorActionPreference = 'SilentlyContinue'
Expand Down Expand Up @@ -99,18 +99,18 @@ InModuleScope 'ALZ' {
}

It 'Should get the correct releases' {
Get-GithubRelease -githubRepoUrl "http://github.com/test/repo" -directoryAndFilesToKeep @('repo-1.0.0') -directoryForReleases "output"
Get-ALZGithubRelease -githubRepoUrl "http://github.com/test/repo" -directoryAndFilesToKeep @('repo-1.0.0') -directoryForReleases "output"
Should -Invoke Expand-Archive
Should -Not -Invoke Write-Warning
}

It 'Should warn when you ask for a release that does not exist' {
Get-GithubRelease -githubRepoUrl "http://github.com/test/repo" -releases @('v2.0.0') -directoryAndFilesToKeep @('repo-1.0.0') -directoryForReleases "output"
Get-ALZGithubRelease -githubRepoUrl "http://github.com/test/repo" -releases @('v2.0.0') -directoryAndFilesToKeep @('repo-1.0.0') -directoryForReleases "output"
Should -Invoke Write-Warning
}

It 'Should download all the releases with all' {
Get-GithubRelease -githubRepoUrl "http://github.com/test/repo" -releases @('all') -directoryAndFilesToKeep @('repo-1.0.0') -directoryForReleases "output"
Get-ALZGithubRelease -githubRepoUrl "http://github.com/test/repo" -releases @('all') -directoryAndFilesToKeep @('repo-1.0.0') -directoryForReleases "output"
Should -Invoke Expand-Archive -Times 2
Should -Not -Invoke Write-Warning
}
Expand Down
12 changes: 6 additions & 6 deletions src/Tests/Unit/Public/New-ALZEnvironment.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ InModuleScope 'ALZ' {

Mock -CommandName Get-ALZBicepConfig -MockWith {
@{
"module_url" = "test"
"version" = "v1.0.0"
"module_url" = "test"
"version" = "v1.0.0"
"config_files" = @(
@{
"source" = "a"
"source" = "a"
"destination" = "b"
}
)
"parameters" = @{
"parameters" = @{
"test" = @{
"type" = "string"
}
}
}
}
}

Mock -CommandName Get-GithubRelease -MockWith { }
Mock -CommandName Get-ALZGithubRelease -MockWith { }

Mock -CommandName Test-ALZGitRepository -MockWith { $false }

Expand Down