diff --git a/RELEASENOTES.md b/RELEASENOTES.md index faefce45d..70892eba5 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,2 +1,3 @@ - __BREAKING CHANGE:__ Drop support for deprecated `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` environment variables in `gh gei` and `gh bbs2gh`. The AWS S3 credentials can now only be configured using the industry-standard `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` variables or command line arguments. +- __BREAKING CHANGE__: Require the Bitbucket Server URL, project key and repo to always be provided for `bbs2gh migrate-repo`, even if using the upload-and-migrate (`--archive-path`) or migrate-only (`--archive-url`) flows - Increase timeouts in archive uploads to AWS to prevent timeouts during large uploads diff --git a/src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgsTests.cs b/src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgsTests.cs index fbf141d33..1ebeb53fc 100644 --- a/src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgsTests.cs +++ b/src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgsTests.cs @@ -283,44 +283,6 @@ public void Errors_If_BbsServer_Url_Not_Provided_But_Smb_User_Is_Provided() .WithMessage("*SSH*SMB*--bbs-server-url*"); } - [Fact] - public void Errors_If_BbsServer_Url_Not_Provided_But_Bbs_Project_Is_Provided() - { - // Act - var args = new MigrateRepoCommandArgs - { - ArchivePath = ARCHIVE_PATH, - GithubOrg = GITHUB_ORG, - GithubRepo = GITHUB_REPO, - BbsProject = BBS_PROJECT - }; - - // Assert - args.Invoking(x => x.Validate(_mockOctoLogger.Object)) - .Should() - .ThrowExactly() - .WithMessage("*--bbs-project*--bbs-server-url*"); - } - - [Fact] - public void Errors_If_BbsServer_Url_Not_Provided_But_Bbs_Repo_Is_Provided() - { - // Act - var args = new MigrateRepoCommandArgs - { - ArchivePath = ARCHIVE_PATH, - GithubOrg = GITHUB_ORG, - GithubRepo = GITHUB_REPO, - BbsRepo = BBS_REPO - }; - - // Assert - args.Invoking(x => x.Validate(_mockOctoLogger.Object)) - .Should() - .ThrowExactly() - .WithMessage("*--bbs-repo*--bbs-server-url*"); - } - [Fact] public void It_Throws_If_Github_Org_Is_Provided_But_Github_Repo_Is_Not() { @@ -573,7 +535,7 @@ public void Errors_If_Archive_Url_And_Archive_Path_Are_Passed() } [Fact] - public void Errors_If_BbsServer_Url_And_Archive_Url_Are_Passed() + public void Allows_BbsServer_Url_And_Archive_Url_To_Be_Passed_Together() { // Act var args = new MigrateRepoCommandArgs @@ -587,12 +549,11 @@ public void Errors_If_BbsServer_Url_And_Archive_Url_Are_Passed() // Assert args.Invoking(x => x.Validate(_mockOctoLogger.Object)) .Should() - .ThrowExactly() - .WithMessage("*--bbs-server-url*--archive-url*"); + .NotThrow(); } [Fact] - public void Errors_If_BbsServer_Url_And_Archive_Path_Are_Passed() + public void Allows_BbsServer_Url_And_Archive_Path_To_Be_Passed_Together() { // Act var args = new MigrateRepoCommandArgs @@ -606,8 +567,7 @@ public void Errors_If_BbsServer_Url_And_Archive_Path_Are_Passed() // Assert args.Invoking(x => x.Validate(_mockOctoLogger.Object)) .Should() - .ThrowExactly() - .WithMessage("*--bbs-server-url*--archive-path*"); + .NotThrow(); } [Fact] diff --git a/src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandTests.cs b/src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandTests.cs index 9831cda7e..42e12e6da 100644 --- a/src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandTests.cs +++ b/src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandTests.cs @@ -56,9 +56,9 @@ public void Should_Have_Options() command.Name.Should().Be("migrate-repo"); command.Options.Count.Should().Be(31); - TestHelpers.VerifyCommandOption(command.Options, "bbs-server-url", false); - TestHelpers.VerifyCommandOption(command.Options, "bbs-project", false); - TestHelpers.VerifyCommandOption(command.Options, "bbs-repo", false); + TestHelpers.VerifyCommandOption(command.Options, "bbs-server-url", true); + TestHelpers.VerifyCommandOption(command.Options, "bbs-project", true); + TestHelpers.VerifyCommandOption(command.Options, "bbs-repo", true); TestHelpers.VerifyCommandOption(command.Options, "bbs-username", false); TestHelpers.VerifyCommandOption(command.Options, "bbs-password", false); TestHelpers.VerifyCommandOption(command.Options, "archive-url", false); diff --git a/src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommand.cs b/src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommand.cs index 7c4837543..4f493429a 100644 --- a/src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommand.cs +++ b/src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommand.cs @@ -52,15 +52,24 @@ public MigrateRepoCommand() : base( public Option BbsServerUrl { get; } = new( name: "--bbs-server-url", - description: "The full URL of the Bitbucket Server/Data Center to migrate from. E.g. http://bitbucket.contoso.com:7990"); + description: "The full URL of the Bitbucket Server/Data Center to migrate from. E.g. http://bitbucket.contoso.com:7990") + { + IsRequired = true + }; public Option BbsProject { get; } = new( name: "--bbs-project", - description: "The Bitbucket project to migrate."); + description: "The Bitbucket project to migrate.") + { + IsRequired = true + }; public Option BbsRepo { get; } = new( name: "--bbs-repo", - description: "The Bitbucket repository to migrate."); + description: "The Bitbucket repository to migrate.") + { + IsRequired = true + }; public Option BbsUsername { get; } = new( name: "--bbs-username", diff --git a/src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgs.cs b/src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgs.cs index 8371418a5..16400c804 100644 --- a/src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgs.cs +++ b/src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgs.cs @@ -59,16 +59,6 @@ public override void Validate(OctoLogger log) throw new OctoshiftCliException("Either --bbs-server-url, --archive-path, or --archive-url must be specified."); } - if (BbsServerUrl.HasValue() && ArchiveUrl.HasValue()) - { - throw new OctoshiftCliException("Only one of --bbs-server-url or --archive-url can be specified."); - } - - if (BbsServerUrl.HasValue() && ArchivePath.HasValue()) - { - throw new OctoshiftCliException("Only one of --bbs-server-url or --archive-path can be specified."); - } - if (ArchivePath.HasValue() && ArchiveUrl.HasValue()) { throw new OctoshiftCliException("Only one of --archive-path or --archive-url can be specified."); @@ -127,23 +117,19 @@ private void ValidateNoGenerateOptions() throw new OctoshiftCliException("--no-ssl-verify can only be provided with --bbs-server-url."); } - if (BbsProject.HasValue() || BbsRepo.HasValue()) - { - throw new OctoshiftCliException("--bbs-project and --bbs-repo can only be provided with --bbs-server-url."); - } - if (new[] { SshUser, SshPrivateKey, ArchiveDownloadHost, SmbUser, SmbPassword, SmbDomain }.Any(obj => obj.HasValue())) { throw new OctoshiftCliException("SSH or SMB download options can only be provided with --bbs-server-url."); } } - public bool ShouldGenerateArchive() => BbsServerUrl.HasValue(); + public bool ShouldGenerateArchive() => BbsServerUrl.HasValue() && !ArchivePath.HasValue() && !ArchiveUrl.HasValue(); public bool ShouldDownloadArchive() => SshUser.HasValue() || SmbUser.HasValue(); public bool ShouldUploadArchive() => ArchiveUrl.IsNullOrWhiteSpace() && GithubOrg.HasValue(); + // NOTE: ArchiveUrl doesn't necessarily refer to the value passed in by the user to the CLI - it is set during CLI runtime when an archive is uploaded to blob storage public bool ShouldImportArchive() => ArchiveUrl.HasValue() || GithubOrg.HasValue(); private void ValidateGenerateOptions()