forked from github/gh-actions-importer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Bamboo audit command * Add Bamboo dry-run commands * Add Bamboo migrate commands * Wire things up * lint * Fix typo
- Loading branch information
1 parent
b3f8e99
commit 12938b7
Showing
11 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Collections.Immutable; | ||
using System.CommandLine; | ||
|
||
namespace ActionsImporter.Commands.Bamboo; | ||
|
||
public class Audit : ContainerCommand | ||
{ | ||
public Audit(string[] args) | ||
: base(args) | ||
{ | ||
} | ||
|
||
protected override string Name => "bamboo"; | ||
protected override string Description => "An audit will output a list of data used in a Bamboo instance."; | ||
protected override ImmutableArray<Option> Options => ImmutableArray.Create<Option>( | ||
Common.AccessToken, | ||
Common.InstanceUrl, | ||
Common.Project, | ||
Common.ConfigFilePath, | ||
Common.IncludeFrom | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Collections.Immutable; | ||
using System.CommandLine; | ||
|
||
namespace ActionsImporter.Commands.Bamboo.BuildPlan; | ||
|
||
public class DryRun : ContainerCommand | ||
{ | ||
public DryRun(string[] args) : base(args) | ||
{ | ||
} | ||
|
||
protected override string Name => "build"; | ||
protected override string Description => "Target a build plan"; | ||
|
||
protected override ImmutableArray<Option> Options => ImmutableArray.Create<Option>( | ||
Common.ConfigFilePath, | ||
Common.SourceFilePath, | ||
Common.PlanSlug | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Collections.Immutable; | ||
using System.CommandLine; | ||
|
||
namespace ActionsImporter.Commands.Bamboo.BuildPlan; | ||
|
||
public class Migrate : ContainerCommand | ||
{ | ||
public Migrate(string[] args) : base(args) | ||
{ | ||
} | ||
|
||
protected override string Name => "build"; | ||
protected override string Description => "Target a build plan"; | ||
|
||
protected override ImmutableArray<Option> Options => ImmutableArray.Create<Option>( | ||
Common.ConfigFilePath, | ||
Common.SourceFilePath, | ||
Common.PlanSlug | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.CommandLine; | ||
|
||
namespace ActionsImporter.Commands.Bamboo; | ||
|
||
public static class Common | ||
{ | ||
public static readonly Option<string> AccessToken = new("--bamboo-access-token") | ||
{ | ||
Description = "Access token for the Bamboo instance.", | ||
IsRequired = false, | ||
}; | ||
|
||
public static readonly Option<string> InstanceUrl = new("--bamboo-instance-url") | ||
{ | ||
Description = "The URL of the Bamboo instance.", | ||
IsRequired = false, | ||
}; | ||
|
||
public static readonly Option<string> Project = new(new[] { "-p", "--project" }) | ||
{ | ||
Description = "The Bamboo project name.", | ||
IsRequired = false, | ||
}; | ||
|
||
public static readonly Option<FileInfo> ConfigFilePath = new("--config-file-path") | ||
{ | ||
Description = "The file path to the GitHub Actions Importer configuration file.", | ||
IsRequired = false, | ||
}; | ||
|
||
public static readonly Option<FileInfo> SourceFilePath = new("--source-file-path") | ||
{ | ||
Description = "The file path corresponding to the Bamboo pipeline file.", | ||
IsRequired = false, | ||
}; | ||
|
||
public static readonly Option<FileInfo> IncludeFrom = new("--include-from") | ||
{ | ||
Description = "The file path containing a list of line-delimited repositories to include in the audit.", | ||
IsRequired = false, | ||
}; | ||
|
||
public static readonly Option<int> PlanSlug = new(new[] { "-p", "--plan-slug" }) | ||
{ | ||
Description = "The project and plan key in the format 'ProjectKey-PlanKey'.", | ||
IsRequired = true, | ||
}; | ||
|
||
public static readonly Option<FileInfo> DeploymentProjectId = new("--deployment-project-id") | ||
{ | ||
Description = "The Bamboo deployment project id.", | ||
IsRequired = true, | ||
}; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/ActionsImporter/Commands/Bamboo/DeploymentPlan/DryRun.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Collections.Immutable; | ||
using System.CommandLine; | ||
|
||
namespace ActionsImporter.Commands.Bamboo.DeploymentPlan; | ||
|
||
public class DryRun : ContainerCommand | ||
{ | ||
public DryRun(string[] args) : base(args) | ||
{ | ||
} | ||
|
||
protected override string Name => "deployment"; | ||
protected override string Description => "Target a deployment plan"; | ||
|
||
protected override ImmutableArray<Option> Options => ImmutableArray.Create<Option>( | ||
Common.DeploymentProjectId | ||
); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/ActionsImporter/Commands/Bamboo/DeploymentPlan/Migrate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Collections.Immutable; | ||
using System.CommandLine; | ||
|
||
namespace ActionsImporter.Commands.Bamboo.DeploymentPlan; | ||
|
||
public class Migrate : ContainerCommand | ||
{ | ||
public Migrate(string[] args) : base(args) | ||
{ | ||
} | ||
|
||
protected override string Name => "deployment"; | ||
protected override string Description => "Target a deployment plan"; | ||
|
||
protected override ImmutableArray<Option> Options => ImmutableArray.Create<Option>( | ||
Common.DeploymentProjectId | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.CommandLine; | ||
|
||
namespace ActionsImporter.Commands.Bamboo; | ||
|
||
public class DryRun : BaseCommand | ||
{ | ||
private readonly string[] _args; | ||
|
||
public DryRun(string[] args) | ||
{ | ||
_args = args; | ||
} | ||
|
||
protected override string Name => "bamboo"; | ||
protected override string Description => "Convert a Bamboo pipeline to a GitHub Actions workflow and output its yaml file."; | ||
|
||
protected override Command GenerateCommand(App app) | ||
{ | ||
var command = base.GenerateCommand(app); | ||
|
||
command.AddGlobalOption(Common.AccessToken); | ||
command.AddGlobalOption(Common.InstanceUrl); | ||
command.AddGlobalOption(Common.Project); | ||
|
||
command.AddCommand(new BuildPlan.DryRun(_args).Command(app)); | ||
command.AddCommand(new DeploymentPlan.DryRun(_args).Command(app)); | ||
|
||
return command; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.CommandLine; | ||
|
||
namespace ActionsImporter.Commands.Bamboo; | ||
|
||
public class Migrate : BaseCommand | ||
{ | ||
private readonly string[] _args; | ||
|
||
public Migrate(string[] args) | ||
{ | ||
_args = args; | ||
} | ||
|
||
protected override string Name => "bamboo"; | ||
protected override string Description => "Convert a Bamboo pipeline to a GitHub Actions workflow and open a pull request with the changes."; | ||
|
||
protected override Command GenerateCommand(App app) | ||
{ | ||
var command = base.GenerateCommand(app); | ||
|
||
command.AddGlobalOption(Common.AccessToken); | ||
command.AddGlobalOption(Common.InstanceUrl); | ||
command.AddGlobalOption(Common.Project); | ||
|
||
command.AddCommand(new BuildPlan.Migrate(_args).Command(app)); | ||
command.AddCommand(new DeploymentPlan.Migrate(_args).Command(app)); | ||
|
||
return command; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters