diff --git a/src/OctoshiftCLI.Tests/Octoshift/Services/ArchiveUploadersTests.cs b/src/OctoshiftCLI.Tests/Octoshift/Services/ArchiveUploadersTests.cs index 0ed1eba7e..ebcd5904d 100644 --- a/src/OctoshiftCLI.Tests/Octoshift/Services/ArchiveUploadersTests.cs +++ b/src/OctoshiftCLI.Tests/Octoshift/Services/ArchiveUploadersTests.cs @@ -7,9 +7,10 @@ using Moq; using OctoshiftCLI.Extensions; using OctoshiftCLI.Services; -using OctoshiftCLI.Tests; using Xunit; +namespace OctoshiftCLI.Tests.Octoshift.Services; + public class ArchiveUploaderTests { private readonly Mock _githubClientMock; diff --git a/src/OctoshiftCLI.Tests/gei/Commands/GenerateScript/GenerateScriptCommandHandlerTests.cs b/src/OctoshiftCLI.Tests/gei/Commands/GenerateScript/GenerateScriptCommandHandlerTests.cs index f594c012f..b026dcceb 100644 --- a/src/OctoshiftCLI.Tests/gei/Commands/GenerateScript/GenerateScriptCommandHandlerTests.cs +++ b/src/OctoshiftCLI.Tests/gei/Commands/GenerateScript/GenerateScriptCommandHandlerTests.cs @@ -222,7 +222,7 @@ public async Task Sequential_Github_Ghes_Repo() _mockGithubApi .Setup(m => m.GetRepos(SOURCE_ORG)) .ReturnsAsync(new[] { (REPO, "private") }); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true); var expected = $"Exec {{ gh gei migrate-repo --github-source-org \"{SOURCE_ORG}\" --source-repo \"{REPO}\" --github-target-org \"{TARGET_ORG}\" --target-repo \"{REPO}\" --ghes-api-url \"{ghesApiUrl}\" --target-repo-visibility private }}"; @@ -333,7 +333,7 @@ public async Task Parallel_Github_Ghes_Single_Repo() .ReturnsAsync(new[] { (REPO, "private") }); _mockVersionProvider.Setup(m => m.GetCurrentVersion()).Returns("1.1.1"); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true); var expected = new StringBuilder(); expected.AppendLine("#!/usr/bin/env pwsh"); @@ -502,7 +502,7 @@ public async Task Parallel_Github_Ghes_Single_Repo_With_Download_Migration_Logs( .ReturnsAsync(new[] { (REPO, "private") }); _mockVersionProvider.Setup(m => m.GetCurrentVersion()).Returns("1.1.1"); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true); var expected = new StringBuilder(); expected.AppendLine("#!/usr/bin/env pwsh"); @@ -588,7 +588,7 @@ public async Task Parallel_Github_Ghes_Single_Repo_No_Ssl() .ReturnsAsync(new[] { (REPO, "private") }); _mockVersionProvider.Setup(m => m.GetCurrentVersion()).Returns("1.1.1"); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true); var expected = new StringBuilder(); expected.AppendLine("#!/usr/bin/env pwsh"); @@ -673,7 +673,7 @@ public async Task Parallel_Github_Ghes_Single_Repo_Keep_Archive() .ReturnsAsync(new[] { (REPO, "private") }); _mockVersionProvider.Setup(m => m.GetCurrentVersion()).Returns("1.1.1"); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(false); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(false); var expected = new StringBuilder(); expected.AppendLine("#!/usr/bin/env pwsh"); @@ -909,7 +909,7 @@ public async Task Sequential_Ghes_Single_Repo_Aws_S3() _mockGithubApi .Setup(m => m.GetRepos(SOURCE_ORG)) .ReturnsAsync(new[] { (REPO, "private") }); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true); var expected = $"Exec {{ gh gei migrate-repo --github-source-org \"{SOURCE_ORG}\" --source-repo \"{REPO}\" --github-target-org \"{TARGET_ORG}\" --target-repo \"{REPO}\" --ghes-api-url \"{ghesApiUrl}\" --aws-bucket-name \"{AWS_BUCKET_NAME}\" --aws-region \"{AWS_REGION}\" --target-repo-visibility private }}"; @@ -941,7 +941,7 @@ public async Task Sequential_Ghes_Single_Repo_Keep_Archive() _mockGithubApi .Setup(m => m.GetRepos(SOURCE_ORG)) .ReturnsAsync(new[] { (REPO, "private") }); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true); var expected = $"Exec {{ gh gei migrate-repo --github-source-org \"{SOURCE_ORG}\" --source-repo \"{REPO}\" --github-target-org \"{TARGET_ORG}\" --target-repo \"{REPO}\" --ghes-api-url \"{ghesApiUrl}\" --aws-bucket-name \"{AWS_BUCKET_NAME}\" --aws-region \"{AWS_REGION}\" --keep-archive --target-repo-visibility private }}"; @@ -974,7 +974,7 @@ public async Task Validates_Env_Vars() _mockGithubApi .Setup(m => m.GetRepos(SOURCE_ORG)) .ReturnsAsync(new[] { (REPO, "private") }); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true); var expected = @" if (-not $env:GH_PAT) { @@ -1019,7 +1019,7 @@ public async Task Validates_Env_Vars_AWS() _mockGithubApi .Setup(m => m.GetRepos(SOURCE_ORG)) .ReturnsAsync(new[] { (REPO, "private") }); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true); var expected = @" if (-not $env:GH_PAT) { @@ -1072,7 +1072,7 @@ public async Task Validates_Env_Vars_AZURE_STORAGE_CONNECTION_STRING_Not_Validat _mockGithubApi .Setup(m => m.GetRepos(SOURCE_ORG)) .ReturnsAsync(new[] { (REPO, "private") }); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(true); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(true); var expected = @" if (-not $env:AZURE_STORAGE_CONNECTION_STRING) { @@ -1173,7 +1173,7 @@ public async Task Validates_Env_Vars_Blob_Storage_Not_Validated_When_GHES_3_8() _mockGithubApi .Setup(m => m.GetRepos(SOURCE_ORG)) .ReturnsAsync(new[] { (REPO, "private") }); - _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl, false)).ReturnsAsync(false); + _mockGhesVersionCheckerService.Setup(m => m.AreBlobCredentialsRequired(ghesApiUrl)).ReturnsAsync(false); var expected = @" if (-not $env:GH_PAT) { diff --git a/src/OctoshiftCLI.Tests/gei/Commands/MigrateRepo/MigrateRepoCommandHandlerTests.cs b/src/OctoshiftCLI.Tests/gei/Commands/MigrateRepo/MigrateRepoCommandHandlerTests.cs index 8738b41c6..5f208f754 100644 --- a/src/OctoshiftCLI.Tests/gei/Commands/MigrateRepo/MigrateRepoCommandHandlerTests.cs +++ b/src/OctoshiftCLI.Tests/gei/Commands/MigrateRepo/MigrateRepoCommandHandlerTests.cs @@ -67,7 +67,7 @@ public async Task Dont_Generate_Archives_If_Target_Repo_Exists() { // Arrange _mockTargetGithubApi.Setup(x => x.DoesRepoExist(TARGET_ORG, TARGET_REPO)).ReturnsAsync(true); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); // Act var args = new MigrateRepoCommandArgs @@ -306,7 +306,7 @@ public async Task Happy_Path_GithubSource_Ghes() _mockEnvironmentVariableProvider.Setup(m => m.SourceGithubPersonalAccessToken(It.IsAny())).Returns(sourceGithubPat); _mockEnvironmentVariableProvider.Setup(m => m.TargetGithubPersonalAccessToken(It.IsAny())).Returns(targetGithubPat); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); var args = new MigrateRepoCommandArgs { @@ -325,8 +325,10 @@ public async Task Happy_Path_GithubSource_Ghes() _mockFileSystemProvider.Verify(x => x.DeleteIfExists(metadataArchiveFilePath), Times.Once); } - [Fact] - public async Task Happy_Path_UseGithubStorage() + [Theory] + [InlineData(false)] + [InlineData(true)] + public async Task Happy_Path_UseGithubStorage(bool useGhesBlobCredentials) { var githubOrgId = Guid.NewGuid().ToString(); var githubOrgDatabaseId = Guid.NewGuid().ToString(); @@ -365,7 +367,7 @@ public async Task Happy_Path_UseGithubStorage() .Setup(m => m.OpenRead(metadataArchiveDownloadFilePath)) .Returns(metaContentStream); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, true)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(useGhesBlobCredentials); _mockTargetGithubApi.Setup(x => x.DoesOrgExist(TARGET_ORG).Result).Returns(true); @@ -482,7 +484,7 @@ public async Task Happy_Path_GithubSource_Ghes_Repo_Renamed() _mockEnvironmentVariableProvider.Setup(m => m.SourceGithubPersonalAccessToken(It.IsAny())).Returns(sourceGithubPat); _mockEnvironmentVariableProvider.Setup(m => m.TargetGithubPersonalAccessToken(It.IsAny())).Returns(targetGithubPat); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); var args = new MigrateRepoCommandArgs { @@ -635,7 +637,7 @@ public async Task Ghes_AzureConnectionString_Uses_Env_When_Option_Empty() _mockEnvironmentVariableProvider.Setup(m => m.TargetGithubPersonalAccessToken(It.IsAny())).Returns(targetGithubPat); _mockEnvironmentVariableProvider.Setup(m => m.AzureStorageConnectionString(It.IsAny())).Returns(azureConnectionStringEnv); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); var args = new MigrateRepoCommandArgs { @@ -699,7 +701,7 @@ public async Task Ghes_With_NoSslVerify_Uses_NoSsl_Client() _mockEnvironmentVariableProvider.Setup(m => m.SourceGithubPersonalAccessToken(It.IsAny())).Returns(sourceGithubPat); _mockEnvironmentVariableProvider.Setup(m => m.TargetGithubPersonalAccessToken(It.IsAny())).Returns(targetGithubPat); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); var args = new MigrateRepoCommandArgs { @@ -762,7 +764,7 @@ public async Task Ghes_With_3_8_0_Version_Returns_Archive_Urls_Directly() _mockEnvironmentVariableProvider.Setup(m => m.SourceGithubPersonalAccessToken(It.IsAny())).Returns(sourceGithubPat); _mockEnvironmentVariableProvider.Setup(m => m.TargetGithubPersonalAccessToken(It.IsAny())).Returns(targetGithubPat); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(false); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(false); var args = new MigrateRepoCommandArgs { @@ -789,7 +791,7 @@ public async Task Ghes_Failed_Archive_Generation_Throws_Error() _mockSourceGithubApi.Setup(x => x.StartMetadataArchiveGeneration(SOURCE_ORG, SOURCE_REPO, false, false).Result).Returns(metadataArchiveId); _mockSourceGithubApi.Setup(x => x.GetArchiveMigrationStatus(SOURCE_ORG, gitArchiveId).Result).Returns(ArchiveMigrationStatus.Failed); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); await FluentActions .Invoking(async () => await _handler.Handle(new MigrateRepoCommandArgs @@ -881,7 +883,7 @@ public async Task Ghes_Retries_Archive_Generation_On_Any_Error() _mockEnvironmentVariableProvider.Setup(m => m.SourceGithubPersonalAccessToken(It.IsAny())).Returns(sourceGithubPat); _mockEnvironmentVariableProvider.Setup(m => m.TargetGithubPersonalAccessToken(It.IsAny())).Returns(targetGithubPat); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); var args = new MigrateRepoCommandArgs { @@ -1065,7 +1067,7 @@ public async Task Does_Not_Pass_Lock_Repos_To_StartMigration_For_GHES() _mockTargetGithubApi.Setup(x => x.DoesOrgExist(TARGET_ORG).Result).Returns(true); _mockAzureApi.Setup(x => x.UploadToBlob(It.IsAny(), It.IsAny()).Result).Returns(new Uri("https://example.com/resource")); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); // Act var args = new MigrateRepoCommandArgs @@ -1329,7 +1331,7 @@ public async Task It_Uses_Aws_If_Arguments_Are_Included() _mockAwsApi.Setup(m => m.UploadToBucket(awsBucketName, It.IsAny(), It.IsAny())).ReturnsAsync(archiveUrl); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); var handler = new MigrateRepoCommandHandler( _mockOctoLogger.Object, @@ -1368,7 +1370,7 @@ public async Task It_Uses_Aws_If_Arguments_Are_Included() [Fact] public async Task Ghes_With_Both_Azure_Storage_Connection_String_And_Aws_Bucket_Name_Throws() { - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs { @@ -1387,7 +1389,7 @@ await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs [Fact] public async Task Ghes_When_Aws_Bucket_Name_Is_Provided_But_No_Aws_Access_Key_Id_Throws() { - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs { @@ -1407,7 +1409,7 @@ await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs [Fact] public async Task Ghes_When_Aws_Bucket_Name_Is_Provided_But_No_Aws_Secret_Key_Throws() { - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs { @@ -1427,7 +1429,7 @@ await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs [Fact] public async Task Ghes_When_Aws_Bucket_Name_Is_Provided_But_No_Aws_Region_Throws() { - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs { @@ -1449,7 +1451,7 @@ await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs [Fact] public async Task Ghes_When_Aws_Bucket_Name_Not_Provided_But_Aws_Access_Key_Provided() { - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs { @@ -1469,7 +1471,7 @@ await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs [Fact] public async Task Ghes_When_Aws_Bucket_Name_Not_Provided_But_Aws_Secret_Key_Provided() { - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs { @@ -1489,7 +1491,7 @@ await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs [Fact] public async Task Ghes_When_Aws_Bucket_Name_Not_Provided_But_Aws_Session_Token_Provided() { - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs { @@ -1509,7 +1511,7 @@ await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs [Fact] public async Task Ghes_When_Aws_Bucket_Name_Not_Provided_But_Aws_Region_Provided() { - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs { @@ -1581,7 +1583,7 @@ public async Task Keep_Archive_Does_Not_Call_DeleteIfExists() _mockEnvironmentVariableProvider.Setup(m => m.SourceGithubPersonalAccessToken(It.IsAny())).Returns(sourceGithubPat); _mockEnvironmentVariableProvider.Setup(m => m.TargetGithubPersonalAccessToken(It.IsAny())).Returns(targetGithubPat); - _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL, false)).ReturnsAsync(true); + _mockGhesVersionChecker.Setup(m => m.AreBlobCredentialsRequired(GHES_API_URL)).ReturnsAsync(true); var args = new MigrateRepoCommandArgs { diff --git a/src/gei/Commands/GenerateScript/GenerateScriptCommandHandler.cs b/src/gei/Commands/GenerateScript/GenerateScriptCommandHandler.cs index 914b97179..d0d405ab5 100644 --- a/src/gei/Commands/GenerateScript/GenerateScriptCommandHandler.cs +++ b/src/gei/Commands/GenerateScript/GenerateScriptCommandHandler.cs @@ -93,7 +93,8 @@ private async Task GenerateSequentialGithubScript(IEnumerable<(string Na content.AppendLine(EXEC_FUNCTION_BLOCK); content.AppendLine(VALIDATE_GH_PAT); - if (await _ghesVersionChecker.AreBlobCredentialsRequired(ghesApiUrl)) + + if (!useGithubStorage && await _ghesVersionChecker.AreBlobCredentialsRequired(ghesApiUrl)) { if (awsBucketName.HasValue() || awsRegion.HasValue()) { @@ -131,7 +132,7 @@ private async Task GenerateParallelGithubScript(IEnumerable<(string Name content.AppendLine(EXEC_AND_GET_MIGRATION_ID_FUNCTION_BLOCK); content.AppendLine(VALIDATE_GH_PAT); - if (await _ghesVersionChecker.AreBlobCredentialsRequired(ghesApiUrl)) + if (!useGithubStorage && await _ghesVersionChecker.AreBlobCredentialsRequired(ghesApiUrl)) { if (awsBucketName.HasValue() || awsRegion.HasValue()) { diff --git a/src/gei/Commands/MigrateRepo/MigrateRepoCommandHandler.cs b/src/gei/Commands/MigrateRepo/MigrateRepoCommandHandler.cs index afb5fd417..0eb1acc2d 100644 --- a/src/gei/Commands/MigrateRepo/MigrateRepoCommandHandler.cs +++ b/src/gei/Commands/MigrateRepo/MigrateRepoCommandHandler.cs @@ -64,7 +64,7 @@ public async Task Handle(MigrateRepoCommandArgs args) _log.LogInformation("Migrating Repo..."); - var blobCredentialsRequired = await _ghesVersionChecker.AreBlobCredentialsRequired(args.GhesApiUrl, args.UseGithubStorage); + var blobCredentialsRequired = await _ghesVersionChecker.AreBlobCredentialsRequired(args.GhesApiUrl); if (args.GhesApiUrl.HasValue()) { @@ -116,7 +116,7 @@ public async Task Handle(MigrateRepoCommandArgs args) args.UseGithubStorage ); - if (blobCredentialsRequired) + if (args.UseGithubStorage || blobCredentialsRequired) { _log.LogInformation("Archives uploaded to blob storage, now starting migration..."); } @@ -221,7 +221,7 @@ private string ExtractGhesBaseUrl(string ghesApiUrl) var (gitArchiveUrl, metadataArchiveUrl, gitArchiveId, metadataArchiveId) = await _retryPolicy.Retry( async () => await GenerateArchive(githubSourceOrg, sourceRepo, skipReleases, lockSourceRepo)); - if (!blobCredentialsRequired) + if (!useGithubStorage && !blobCredentialsRequired) { return (gitArchiveUrl, metadataArchiveUrl); } @@ -396,7 +396,7 @@ private void ValidateGHESOptions(MigrateRepoCommandArgs args, bool cloudCredenti if (args.UseGithubStorage) { - _log.LogWarning("Ignoring --use-github-storage flag because you are running GitHub Enterprise Server (GHES) 3.8.0 or later. The blob storage credentials configured in your GHES Management Console will be used instead."); + _log.LogWarning("Providing the --use-github-storage flag will supersede any credentials you have configured in your GitHub Enterprise Server (GHES) Management Console."); } if (args.KeepArchive) diff --git a/src/gei/Services/GhesVersionChecker.cs b/src/gei/Services/GhesVersionChecker.cs index 5f1a0b3d3..61550913a 100644 --- a/src/gei/Services/GhesVersionChecker.cs +++ b/src/gei/Services/GhesVersionChecker.cs @@ -16,14 +16,10 @@ public GhesVersionChecker(OctoLogger log, GithubApi githubApi) _githubApi = githubApi; } - public virtual async Task AreBlobCredentialsRequired(string ghesApiUrl, bool useGithubStorage = false) + public virtual async Task AreBlobCredentialsRequired(string ghesApiUrl) { var blobCredentialsRequired = false; - if (useGithubStorage) - { - return true; - } if (ghesApiUrl.HasValue()) {