Skip to content

Commit e455609

Browse files
authored
Merge pull request #1057 from github/timrogers/require-bbs-server-repo-and-project
Require the Bitbucket Server URL, project and repo name to always be passed for `bbs2gh migrate-repo`
2 parents cc14582 + 54cdc71 commit e455609

File tree

5 files changed

+22
-66
lines changed

5 files changed

+22
-66
lines changed

RELEASENOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
- __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.
2+
- __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
23
- Increase timeouts in archive uploads to AWS to prevent timeouts during large uploads

src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgsTests.cs

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -283,44 +283,6 @@ public void Errors_If_BbsServer_Url_Not_Provided_But_Smb_User_Is_Provided()
283283
.WithMessage("*SSH*SMB*--bbs-server-url*");
284284
}
285285

286-
[Fact]
287-
public void Errors_If_BbsServer_Url_Not_Provided_But_Bbs_Project_Is_Provided()
288-
{
289-
// Act
290-
var args = new MigrateRepoCommandArgs
291-
{
292-
ArchivePath = ARCHIVE_PATH,
293-
GithubOrg = GITHUB_ORG,
294-
GithubRepo = GITHUB_REPO,
295-
BbsProject = BBS_PROJECT
296-
};
297-
298-
// Assert
299-
args.Invoking(x => x.Validate(_mockOctoLogger.Object))
300-
.Should()
301-
.ThrowExactly<OctoshiftCliException>()
302-
.WithMessage("*--bbs-project*--bbs-server-url*");
303-
}
304-
305-
[Fact]
306-
public void Errors_If_BbsServer_Url_Not_Provided_But_Bbs_Repo_Is_Provided()
307-
{
308-
// Act
309-
var args = new MigrateRepoCommandArgs
310-
{
311-
ArchivePath = ARCHIVE_PATH,
312-
GithubOrg = GITHUB_ORG,
313-
GithubRepo = GITHUB_REPO,
314-
BbsRepo = BBS_REPO
315-
};
316-
317-
// Assert
318-
args.Invoking(x => x.Validate(_mockOctoLogger.Object))
319-
.Should()
320-
.ThrowExactly<OctoshiftCliException>()
321-
.WithMessage("*--bbs-repo*--bbs-server-url*");
322-
}
323-
324286
[Fact]
325287
public void It_Throws_If_Github_Org_Is_Provided_But_Github_Repo_Is_Not()
326288
{
@@ -573,7 +535,7 @@ public void Errors_If_Archive_Url_And_Archive_Path_Are_Passed()
573535
}
574536

575537
[Fact]
576-
public void Errors_If_BbsServer_Url_And_Archive_Url_Are_Passed()
538+
public void Allows_BbsServer_Url_And_Archive_Url_To_Be_Passed_Together()
577539
{
578540
// Act
579541
var args = new MigrateRepoCommandArgs
@@ -587,12 +549,11 @@ public void Errors_If_BbsServer_Url_And_Archive_Url_Are_Passed()
587549
// Assert
588550
args.Invoking(x => x.Validate(_mockOctoLogger.Object))
589551
.Should()
590-
.ThrowExactly<OctoshiftCliException>()
591-
.WithMessage("*--bbs-server-url*--archive-url*");
552+
.NotThrow();
592553
}
593554

594555
[Fact]
595-
public void Errors_If_BbsServer_Url_And_Archive_Path_Are_Passed()
556+
public void Allows_BbsServer_Url_And_Archive_Path_To_Be_Passed_Together()
596557
{
597558
// Act
598559
var args = new MigrateRepoCommandArgs
@@ -606,8 +567,7 @@ public void Errors_If_BbsServer_Url_And_Archive_Path_Are_Passed()
606567
// Assert
607568
args.Invoking(x => x.Validate(_mockOctoLogger.Object))
608569
.Should()
609-
.ThrowExactly<OctoshiftCliException>()
610-
.WithMessage("*--bbs-server-url*--archive-path*");
570+
.NotThrow();
611571
}
612572

613573
[Fact]

src/OctoshiftCLI.Tests/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public void Should_Have_Options()
5656
command.Name.Should().Be("migrate-repo");
5757
command.Options.Count.Should().Be(31);
5858

59-
TestHelpers.VerifyCommandOption(command.Options, "bbs-server-url", false);
60-
TestHelpers.VerifyCommandOption(command.Options, "bbs-project", false);
61-
TestHelpers.VerifyCommandOption(command.Options, "bbs-repo", false);
59+
TestHelpers.VerifyCommandOption(command.Options, "bbs-server-url", true);
60+
TestHelpers.VerifyCommandOption(command.Options, "bbs-project", true);
61+
TestHelpers.VerifyCommandOption(command.Options, "bbs-repo", true);
6262
TestHelpers.VerifyCommandOption(command.Options, "bbs-username", false);
6363
TestHelpers.VerifyCommandOption(command.Options, "bbs-password", false);
6464
TestHelpers.VerifyCommandOption(command.Options, "archive-url", false);

src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommand.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,24 @@ public MigrateRepoCommand() : base(
5252

5353
public Option<string> BbsServerUrl { get; } = new(
5454
name: "--bbs-server-url",
55-
description: "The full URL of the Bitbucket Server/Data Center to migrate from. E.g. http://bitbucket.contoso.com:7990");
55+
description: "The full URL of the Bitbucket Server/Data Center to migrate from. E.g. http://bitbucket.contoso.com:7990")
56+
{
57+
IsRequired = true
58+
};
5659

5760
public Option<string> BbsProject { get; } = new(
5861
name: "--bbs-project",
59-
description: "The Bitbucket project to migrate.");
62+
description: "The Bitbucket project to migrate.")
63+
{
64+
IsRequired = true
65+
};
6066

6167
public Option<string> BbsRepo { get; } = new(
6268
name: "--bbs-repo",
63-
description: "The Bitbucket repository to migrate.");
69+
description: "The Bitbucket repository to migrate.")
70+
{
71+
IsRequired = true
72+
};
6473

6574
public Option<string> BbsUsername { get; } = new(
6675
name: "--bbs-username",

src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgs.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ public override void Validate(OctoLogger log)
5959
throw new OctoshiftCliException("Either --bbs-server-url, --archive-path, or --archive-url must be specified.");
6060
}
6161

62-
if (BbsServerUrl.HasValue() && ArchiveUrl.HasValue())
63-
{
64-
throw new OctoshiftCliException("Only one of --bbs-server-url or --archive-url can be specified.");
65-
}
66-
67-
if (BbsServerUrl.HasValue() && ArchivePath.HasValue())
68-
{
69-
throw new OctoshiftCliException("Only one of --bbs-server-url or --archive-path can be specified.");
70-
}
71-
7262
if (ArchivePath.HasValue() && ArchiveUrl.HasValue())
7363
{
7464
throw new OctoshiftCliException("Only one of --archive-path or --archive-url can be specified.");
@@ -127,23 +117,19 @@ private void ValidateNoGenerateOptions()
127117
throw new OctoshiftCliException("--no-ssl-verify can only be provided with --bbs-server-url.");
128118
}
129119

130-
if (BbsProject.HasValue() || BbsRepo.HasValue())
131-
{
132-
throw new OctoshiftCliException("--bbs-project and --bbs-repo can only be provided with --bbs-server-url.");
133-
}
134-
135120
if (new[] { SshUser, SshPrivateKey, ArchiveDownloadHost, SmbUser, SmbPassword, SmbDomain }.Any(obj => obj.HasValue()))
136121
{
137122
throw new OctoshiftCliException("SSH or SMB download options can only be provided with --bbs-server-url.");
138123
}
139124
}
140125

141-
public bool ShouldGenerateArchive() => BbsServerUrl.HasValue();
126+
public bool ShouldGenerateArchive() => BbsServerUrl.HasValue() && !ArchivePath.HasValue() && !ArchiveUrl.HasValue();
142127

143128
public bool ShouldDownloadArchive() => SshUser.HasValue() || SmbUser.HasValue();
144129

145130
public bool ShouldUploadArchive() => ArchiveUrl.IsNullOrWhiteSpace() && GithubOrg.HasValue();
146131

132+
// 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
147133
public bool ShouldImportArchive() => ArchiveUrl.HasValue() || GithubOrg.HasValue();
148134

149135
private void ValidateGenerateOptions()

0 commit comments

Comments
 (0)