Skip to content

Commit

Permalink
Adds Bamboo commands (github#102)
Browse files Browse the repository at this point in the history
* Add Bamboo audit command

* Add Bamboo dry-run commands

* Add Bamboo migrate commands

* Wire things up

* lint

* Fix typo
  • Loading branch information
simonsanchez authored May 11, 2023
1 parent b3f8e99 commit 12938b7
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ActionsImporter/Commands/Audit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected override Command GenerateCommand(App app)

command.AddGlobalOption(FoldersOption);
command.AddCommand(new AzureDevOps.Audit(_args).Command(app));
command.AddCommand(new Bamboo.Audit(_args).Command(app));
command.AddCommand(new Circle.Audit(_args).Command(app));
command.AddCommand(new GitLab.Audit(_args).Command(app));
command.AddCommand(new Jenkins.Audit(_args).Command(app));
Expand Down
22 changes: 22 additions & 0 deletions src/ActionsImporter/Commands/Bamboo/Audit.cs
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
);
}
20 changes: 20 additions & 0 deletions src/ActionsImporter/Commands/Bamboo/BuildPlan/DryRun.cs
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
);
}
20 changes: 20 additions & 0 deletions src/ActionsImporter/Commands/Bamboo/BuildPlan/Migrate.cs
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
);
}
54 changes: 54 additions & 0 deletions src/ActionsImporter/Commands/Bamboo/Common.cs
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 src/ActionsImporter/Commands/Bamboo/DeploymentPlan/DryRun.cs
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 src/ActionsImporter/Commands/Bamboo/DeploymentPlan/Migrate.cs
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
);
}
30 changes: 30 additions & 0 deletions src/ActionsImporter/Commands/Bamboo/DryRun.cs
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;
}
}
30 changes: 30 additions & 0 deletions src/ActionsImporter/Commands/Bamboo/Migrate.cs
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;
}
}
1 change: 1 addition & 0 deletions src/ActionsImporter/Commands/DryRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected override Command GenerateCommand(App app)
command.AppendCommonOptions();

command.AddCommand(new AzureDevOps.DryRun(_args).Command(app));
command.AddCommand(new Bamboo.DryRun(_args).Command(app));
command.AddCommand(new Circle.DryRun(_args).Command(app));
command.AddCommand(new GitLab.DryRun(_args).Command(app));
command.AddCommand(new Jenkins.DryRun(_args).Command(app));
Expand Down
1 change: 1 addition & 0 deletions src/ActionsImporter/Commands/Migrate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected override Command GenerateCommand(App app)
command.AddGlobalOption(CommitMessage);

command.AddCommand(new AzureDevOps.Migrate(_args).Command(app));
command.AddCommand(new Bamboo.Migrate(_args).Command(app));
command.AddCommand(new Circle.Migrate(_args).Command(app));
command.AddCommand(new GitLab.Migrate(_args).Command(app));
command.AddCommand(new Jenkins.Migrate(_args).Command(app));
Expand Down

0 comments on commit 12938b7

Please sign in to comment.