Skip to content

Commit 10ce5c2

Browse files
committed
Add from-build command
1 parent fd75ef5 commit 10ce5c2

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Threading.Tasks;
5+
using Microsoft.DotNet.DarcLib;
6+
using Microsoft.DotNet.ProductConstructionService.Client.Models;
7+
using Microsoft.Extensions.Logging;
8+
9+
namespace Dotnet.Docker;
10+
11+
internal class FromBuildCommand(
12+
IBasicBarClient barClient,
13+
IBuildUpdaterService buildUpdaterService,
14+
ILogger<FromBuildCommand> logger)
15+
: BaseCommand<FromBuildOptions>
16+
{
17+
private readonly IBasicBarClient _barClient = barClient;
18+
private readonly IBuildUpdaterService _buildUpdaterService = buildUpdaterService;
19+
private readonly ILogger<FromBuildCommand> _logger = logger;
20+
21+
public override async Task<int> ExecuteAsync(FromBuildOptions options)
22+
{
23+
_logger.LogInformation("Getting BAR build with ID {options.Id}", options.Id);
24+
Build build = await _barClient.GetBuildAsync(options.Id);
25+
return await _buildUpdaterService.UpdateFrom(build, options);
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Collections.Generic;
5+
using System.CommandLine;
6+
7+
namespace Dotnet.Docker;
8+
9+
internal class FromBuildOptions : CreatePullRequestOptions, IOptions
10+
{
11+
public required int Id { get; init; }
12+
13+
public static new List<Argument> Arguments { get; } =
14+
[
15+
new Argument<int>("id")
16+
{
17+
Arity = ArgumentArity.ExactlyOne,
18+
Description = "The BAR build ID to use as a source for the update (see https://aka.ms/bar)"
19+
},
20+
..CreatePullRequestOptions.Arguments,
21+
];
22+
23+
public static new List<Option> Options { get; } =
24+
[
25+
..CreatePullRequestOptions.Options,
26+
];
27+
}

eng/update-dependencies/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
var rootCommand = new RootCommand()
1616
{
17+
FromBuildCommand.Create(
18+
name: "from-build",
19+
description: "Update dependencies using a specific BAR build"),
1720
FromChannelCommand.Create(
1821
name: "from-channel",
1922
description: "Update dependencies using the latest build from a channel"),
@@ -46,6 +49,7 @@
4649
services.AddSingleton<IBuildAssetService, BuildAssetService>();
4750
services.AddSingleton<HttpClient>();
4851

52+
FromBuildCommand.Register<FromBuildCommand>(services);
4953
FromChannelCommand.Register<FromChannelCommand>(services);
5054
SpecificCommand.Register<SpecificCommand>(services);
5155
})

0 commit comments

Comments
 (0)