Skip to content

Commit

Permalink
bbs migrate repo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
brianaj committed Jan 29, 2024
1 parent bac1a3f commit 169c0c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class MigrateRepoCommandHandlerTests
private const string GITHUB_ORG = "target-org";
private const string GITHUB_REPO = "target-repo";
private const string GITHUB_PAT = "github pat";
private const string TARGET_API_URL = "https://api.github.com";
private const string AWS_BUCKET_NAME = "aws-bucket-name";
private const string AWS_ACCESS_KEY_ID = "aws-access-key-id";
private const string AWS_SECRET_ACCESS_KEY = "aws-secret-access-key";
Expand Down Expand Up @@ -182,6 +183,7 @@ public async Task Happy_Path_Generate_Archive_Ssh_Download_Azure_Upload_And_Inge
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
GithubPat = GITHUB_PAT,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};
await _handler.Handle(args);
Expand Down Expand Up @@ -227,6 +229,7 @@ public async Task Happy_Path_Generate_Archive_Ssh_Download_Aws_Upload_And_Ingest
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
GithubPat = GITHUB_PAT,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};
await _handler.Handle(args);
Expand Down Expand Up @@ -269,6 +272,7 @@ public async Task Happy_Path_Full_Flow_Running_On_Bbs_Server()
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
GithubPat = GITHUB_PAT,
TargetApiUrl = TARGET_API_URL,
BbsSharedHome = bbsSharedHome,
QueueOnly = true,
};
Expand Down Expand Up @@ -327,6 +331,7 @@ public async Task Happy_Path_Full_Flow_Bbs_Credentials_Via_Environment()
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
GithubPat = GITHUB_PAT,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};
await _handler.Handle(args);
Expand Down Expand Up @@ -367,6 +372,7 @@ public async Task Happy_Path_Deletes_Downloaded_Archive()
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
GithubPat = GITHUB_PAT,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};
await _handler.Handle(args);
Expand Down Expand Up @@ -398,7 +404,8 @@ public async Task It_Deletes_Downloaded_Archive_Even_If_Upload_Fails()
AzureStorageConnectionString = AZURE_STORAGE_CONNECTION_STRING,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
GithubPat = GITHUB_PAT
GithubPat = GITHUB_PAT,
TargetApiUrl = TARGET_API_URL,
};
await _handler.Invoking(async x => await x.Handle(args)).Should().ThrowExactlyAsync<InvalidOperationException>();

Expand Down Expand Up @@ -431,6 +438,7 @@ public async Task Happy_Path_Does_Not_Throw_If_Fails_To_Delete_Downloaded_Archiv
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
GithubPat = GITHUB_PAT,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};
await _handler.Handle(args);
Expand Down Expand Up @@ -459,6 +467,7 @@ public async Task Dont_Generate_Archive_If_Target_Repo_Exists()
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
GithubPat = GITHUB_PAT,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};

Expand Down Expand Up @@ -488,6 +497,7 @@ public async Task Uses_GitHub_Pat_When_Provided_As_Option()
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
GithubPat = githubPat,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};
await _handler.Handle(args);
Expand Down Expand Up @@ -522,6 +532,7 @@ public async Task Skip_Migration_If_Target_Repo_Exists()
ArchiveUrl = ARCHIVE_URL,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};
await _handler.Handle(args);
Expand All @@ -547,6 +558,7 @@ await _handler.Invoking(async x => await x.Handle(new MigrateRepoCommandArgs
ArchiveUrl = ARCHIVE_URL,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
}))
.Should()
Expand Down Expand Up @@ -598,6 +610,7 @@ public async Task Uses_Archive_Path_If_Provided()
ArchivePath = ARCHIVE_PATH,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
TargetApiUrl = TARGET_API_URL,
AzureStorageConnectionString = AZURE_STORAGE_CONNECTION_STRING,
QueueOnly = true,
};
Expand Down Expand Up @@ -667,6 +680,7 @@ public async Task It_Does_Not_Set_The_Archive_Path_When_Archive_Path_Is_Provided
AzureStorageConnectionString = AZURE_STORAGE_CONNECTION_STRING,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};
await _handler.Handle(args);
Expand All @@ -686,6 +700,7 @@ public async Task It_Does_Not_Set_The_Archive_Path_When_Archive_Url_Is_Provided(
AzureStorageConnectionString = AZURE_STORAGE_CONNECTION_STRING,
GithubOrg = GITHUB_ORG,
GithubRepo = GITHUB_REPO,
TargetApiUrl = TARGET_API_URL,
QueueOnly = true,
};
await _handler.Handle(args);
Expand Down
8 changes: 6 additions & 2 deletions src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public MigrateRepoCommand() : base(
AddOption(Verbose);
AddOption(KeepArchive);
AddOption(NoSslVerify);
AddOption(TargetApiUrl);
}

public Option<string> BbsServerUrl { get; } = new(
Expand Down Expand Up @@ -182,7 +183,10 @@ public MigrateRepoCommand() : base(
public Option<bool> KeepArchive { get; } = new(
name: "--keep-archive",
description: "Keeps the downloaded export archive after successfully uploading it. By default, it will be automatically deleted.");

public Option<string> TargetApiUrl { get; } = new("--target-api-url")
{
Description = "The URL of the target API, if not migrating to github.com. Defaults to https://api.github.com"
};
public Option<bool> NoSslVerify { get; } = new(
name: "--no-ssl-verify",
description: "Disables SSL verification when communicating with your Bitbucket Server/Data Center instance. All other migration steps will continue to verify SSL. " +
Expand Down Expand Up @@ -212,7 +216,7 @@ public override MigrateRepoCommandHandler BuildHandler(MigrateRepoCommandArgs ar
if (args.GithubOrg.HasValue())
{
var githubApiFactory = sp.GetRequiredService<GithubApiFactory>();
githubApi = githubApiFactory.Create(null, args.GithubPat);
githubApi = githubApiFactory.Create(args.TargetApiUrl, args.GithubPat);
}

if (args.BbsServerUrl.HasValue())
Expand Down
1 change: 1 addition & 0 deletions src/bbs2gh/Commands/MigrateRepo/MigrateRepoCommandArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class MigrateRepoCommandArgs : CommandArgs
public string GithubPat { get; set; }
public bool QueueOnly { get; set; }
public string TargetRepoVisibility { get; set; }
public string TargetApiUrl { get; set; }
public bool Kerberos { get; set; }

public string BbsServerUrl { get; set; }
Expand Down

0 comments on commit 169c0c8

Please sign in to comment.