Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Bamboo commands #102

Merged
merged 6 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
锘縰sing 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>(
Chaseshak marked this conversation as resolved.
Show resolved Hide resolved
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 @@
锘縰sing 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 @@
锘縰sing 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
Chaseshak marked this conversation as resolved.
Show resolved Hide resolved
);
}
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 @@
锘縰sing 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 @@
锘縰sing 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
Chaseshak marked this conversation as resolved.
Show resolved Hide resolved
);
}
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 @@
锘縰sing 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 @@
锘縰sing 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 @@
锘縰sing 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