Skip to content

Commit 4481199

Browse files
renovate[bot]buehler
authored andcommitted
fix(deps): update dependencies
Signed-off-by: Christoph Bühler <christoph.buehler@unisg.ch>
1 parent 6b2268f commit 4481199

File tree

15 files changed

+138
-129
lines changed

15 files changed

+138
-129
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
PrivateAssets="all"
4444
Condition="$(MSBuildProjectExtension) == '.csproj'" />
4545
<PackageReference Include="SonarAnalyzer.CSharp"
46-
Version="10.12.0.118525"
46+
Version="10.14.0.120626"
4747
PrivateAssets="all"
4848
Condition="$(MSBuildProjectExtension) == '.csproj'" />
4949
<PackageReference Include="Roslynator.Analyzers"

src/KubeOps.Abstractions/KubeOps.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<ItemGroup>
1717
<PackageReference Include="JsonPatch.Net" Version="3.3.0" />
1818
<PackageReference Include="KubernetesClient" Version="16.0.7" />
19-
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.6"/>
19+
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.7"/>
2020
<PackageReference Include="ZiggyCreatures.FusionCache" Version="2.3.0" />
2121
</ItemGroup>
2222

src/KubeOps.Cli/Arguments.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace KubeOps.Cli;
88

99
internal static class Arguments
1010
{
11-
public static readonly Argument<FileInfo?> SolutionOrProjectFile = new(
12-
"sln/csproj file",
13-
() =>
11+
public static readonly Argument<FileInfo> SolutionOrProjectFile = new("sln/csproj file")
12+
{
13+
DefaultValueFactory = result =>
1414
{
1515
var projectFile
1616
= Directory.EnumerateFiles(
@@ -24,20 +24,26 @@ var slnFile
2424
"*.sln")
2525
.Select(f => new FileInfo(f))
2626
.FirstOrDefault();
27-
28-
return (projectFile, slnFile) switch
27+
var file = (projectFile, slnFile) switch
2928
{
3029
({ } prj, _) => prj,
3130
(_, { } sln) => sln,
3231
_ => null,
3332
};
33+
34+
if (file is not null)
35+
{
36+
return file;
37+
}
38+
39+
result.AddError("No solution or project file found in the current directory, and none was provided.");
40+
return new FileInfo("not-found");
3441
},
35-
"A solution or project file where entities are located. " +
36-
"If omitted, the current directory is searched for a *.csproj or *.sln file. " +
37-
"If an *.sln file is used, all projects in the solution (with the newest framework) will be searched for entities. " +
38-
"This behaviour can be filtered by using the --project and --target-framework option.");
42+
Description = "A solution or project file where entities are located. " +
43+
"If omitted, the current directory is searched for a *.csproj or *.sln file. " +
44+
"If an *.sln file is used, all projects in the solution (with the newest framework) will be searched for entities. " +
45+
"This behaviour can be filtered by using the --project and --target-framework option.",
46+
};
3947

40-
public static readonly Argument<string> OperatorName = new(
41-
"name",
42-
"Name of the operator.");
48+
public static readonly Argument<string> OperatorName = new("name") { Description = "Name of the operator.", };
4349
}

src/KubeOps.Cli/Commands/Generator/Generate.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ public static Command Command
1717
{
1818
OperatorGenerator.Command,
1919
};
20-
cmd.AddAlias("gen");
21-
cmd.AddAlias("g");
22-
cmd.SetHandler(ctx => ctx.HelpBuilder.Write(cmd, Console.Out));
20+
cmd.Aliases.Add("gen");
21+
cmd.Aliases.Add("g");
2322

2423
return cmd;
2524
}

src/KubeOps.Cli/Commands/Generator/OperatorGenerator.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,21 @@ public static Command Command
3939
Arguments.OperatorName,
4040
Arguments.SolutionOrProjectFile,
4141
};
42-
cmd.AddAlias("op");
43-
cmd.SetHandler(ctx => Handler(AnsiConsole.Console, ctx));
42+
cmd.Aliases.Add("op");
43+
cmd.SetAction(result => Handler(AnsiConsole.Console, result));
4444

4545
return cmd;
4646
}
4747
}
4848

49-
internal static async Task Handler(IAnsiConsole console, InvocationContext ctx)
49+
internal static async Task<int> Handler(IAnsiConsole console, ParseResult parseResult)
5050
{
51-
var name = ctx.ParseResult.GetValueForArgument(Arguments.OperatorName);
52-
var file = ctx.ParseResult.GetValueForArgument(Arguments.SolutionOrProjectFile);
53-
var outPath = ctx.ParseResult.GetValueForOption(Options.OutputPath);
54-
var format = ctx.ParseResult.GetValueForOption(Options.OutputFormat);
55-
var dockerImage = ctx.ParseResult.GetValueForOption(Options.AccessibleDockerImage)!;
56-
var dockerImageTag = ctx.ParseResult.GetValueForOption(Options.AccessibleDockerTag)!;
51+
var name = parseResult.GetValue(Arguments.OperatorName) ?? "operator";
52+
var file = parseResult.GetValue(Arguments.SolutionOrProjectFile);
53+
var outPath = parseResult.GetValue(Options.OutputPath);
54+
var format = parseResult.GetValue(Options.OutputFormat);
55+
var dockerImage = parseResult.GetValue(Options.AccessibleDockerImage)!;
56+
var dockerImageTag = parseResult.GetValue(Options.AccessibleDockerTag)!;
5757

5858
var result = new ResultOutput(console, format);
5959
console.WriteLine("Generate operator resources.");
@@ -65,8 +65,8 @@ internal static async Task Handler(IAnsiConsole console, InvocationContext ctx)
6565
{ Extension: ".sln", Exists: true } => await AssemblyLoader.ForSolution(
6666
console,
6767
file,
68-
ctx.ParseResult.GetValueForOption(Options.SolutionProjectRegex),
69-
ctx.ParseResult.GetValueForOption(Options.TargetFramework)),
68+
parseResult.GetValue(Options.SolutionProjectRegex),
69+
parseResult.GetValue(Options.TargetFramework)),
7070
{ Exists: false } => throw new FileNotFoundException($"The file {file.Name} does not exist."),
7171
_ => throw new NotSupportedException("Only *.csproj and *.sln files are supported."),
7272
};
@@ -111,7 +111,7 @@ internal static async Task Handler(IAnsiConsole console, InvocationContext ctx)
111111
new DeploymentGenerator(format).Generate(result);
112112

113113
console.MarkupLine("[green]Generate CRDs.[/]");
114-
new CrdGenerator(parser, Array.Empty<byte>(), format).Generate(result);
114+
new CrdGenerator(parser, [], format).Generate(result);
115115
}
116116

117117
result.Add(
@@ -158,7 +158,7 @@ internal static async Task Handler(IAnsiConsole console, InvocationContext ctx)
158158

159159
if (outPath is not null)
160160
{
161-
if (ctx.ParseResult.GetValueForOption(Options.ClearOutputPath))
161+
if (parseResult.GetValue(Options.ClearOutputPath))
162162
{
163163
console.MarkupLine("[yellow]Clear output path.[/]");
164164
try
@@ -182,5 +182,7 @@ internal static async Task Handler(IAnsiConsole console, InvocationContext ctx)
182182
{
183183
result.Write();
184184
}
185+
186+
return ExitCodes.Success;
185187
}
186188
}

src/KubeOps.Cli/Commands/Management/Install.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@ public static Command Command
3030
Options.TargetFramework,
3131
Arguments.SolutionOrProjectFile,
3232
};
33-
cmd.AddAlias("i");
34-
cmd.SetHandler(ctx => Handler(
33+
cmd.Aliases.Add("i");
34+
cmd.SetAction(result => Handler(
3535
AnsiConsole.Console,
3636
new Kubernetes(KubernetesClientConfiguration.BuildDefaultConfig()),
37-
ctx));
37+
result));
3838

3939
return cmd;
4040
}
4141
}
4242

43-
internal static async Task Handler(IAnsiConsole console, IKubernetes client, InvocationContext ctx)
43+
internal static async Task<int> Handler(IAnsiConsole console, IKubernetes client, ParseResult parseResult)
4444
{
45-
var file = ctx.ParseResult.GetValueForArgument(Arguments.SolutionOrProjectFile);
46-
var force = ctx.ParseResult.GetValueForOption(Options.Force);
45+
var file = parseResult.GetValue(Arguments.SolutionOrProjectFile);
46+
var force = parseResult.GetValue(Options.Force);
4747

4848
var parser = file switch
4949
{
5050
{ Extension: ".csproj", Exists: true } => await AssemblyLoader.ForProject(console, file),
5151
{ Extension: ".sln", Exists: true } => await AssemblyLoader.ForSolution(
5252
console,
5353
file,
54-
ctx.ParseResult.GetValueForOption(Options.SolutionProjectRegex),
55-
ctx.ParseResult.GetValueForOption(Options.TargetFramework)),
54+
parseResult.GetValue(Options.SolutionProjectRegex),
55+
parseResult.GetValue(Options.TargetFramework)),
5656
{ Exists: false } => throw new FileNotFoundException($"The file {file.Name} does not exist."),
5757
_ => throw new NotSupportedException("Only *.csproj and *.sln files are supported."),
5858
};
@@ -62,8 +62,7 @@ internal static async Task Handler(IAnsiConsole console, IKubernetes client, Inv
6262
if (crds.Count == 0)
6363
{
6464
console.WriteLine("No CRDs found. Exiting.");
65-
ctx.ExitCode = ExitCodes.Success;
66-
return;
65+
return ExitCodes.Success;
6766
}
6867

6968
console.WriteLine($"Found {crds.Count} CRDs.");
@@ -84,8 +83,7 @@ internal static async Task Handler(IAnsiConsole console, IKubernetes client, Inv
8483
$"""[yellow]CRD "{crd.Spec.Group}/{crd.Spec.Names.Kind}" already exists.[/]""");
8584
if (!force && !await console.ConfirmAsync("[yellow]Should the CRD be overwritten?[/]"))
8685
{
87-
ctx.ExitCode = ExitCodes.Aborted;
88-
return;
86+
return ExitCodes.Aborted;
8987
}
9088

9189
crd.Metadata.ResourceVersion = existing.ResourceVersion();
@@ -112,5 +110,7 @@ internal static async Task Handler(IAnsiConsole console, IKubernetes client, Inv
112110
throw;
113111
}
114112
}
113+
114+
return ExitCodes.Success;
115115
}
116116
}

src/KubeOps.Cli/Commands/Management/Uninstall.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@ public static Command Command
3030
Options.TargetFramework,
3131
Arguments.SolutionOrProjectFile,
3232
};
33-
cmd.AddAlias("u");
34-
cmd.SetHandler(ctx => Handler(
33+
cmd.Aliases.Add("u");
34+
cmd.SetAction(result => Handler(
3535
AnsiConsole.Console,
3636
new Kubernetes(KubernetesClientConfiguration.BuildDefaultConfig()),
37-
ctx));
37+
result));
3838

3939
return cmd;
4040
}
4141
}
4242

43-
internal static async Task Handler(IAnsiConsole console, IKubernetes client, InvocationContext ctx)
43+
internal static async Task<int> Handler(IAnsiConsole console, IKubernetes client, ParseResult parseResult)
4444
{
45-
var file = ctx.ParseResult.GetValueForArgument(Arguments.SolutionOrProjectFile);
46-
var force = ctx.ParseResult.GetValueForOption(Options.Force);
45+
var file = parseResult.GetValue(Arguments.SolutionOrProjectFile);
46+
var force = parseResult.GetValue(Options.Force);
4747

4848
var parser = file switch
4949
{
5050
{ Extension: ".csproj", Exists: true } => await AssemblyLoader.ForProject(console, file),
5151
{ Extension: ".sln", Exists: true } => await AssemblyLoader.ForSolution(
5252
console,
5353
file,
54-
ctx.ParseResult.GetValueForOption(Options.SolutionProjectRegex),
55-
ctx.ParseResult.GetValueForOption(Options.TargetFramework)),
54+
parseResult.GetValue(Options.SolutionProjectRegex),
55+
parseResult.GetValue(Options.TargetFramework)),
5656
{ Exists: false } => throw new FileNotFoundException($"The file {file.Name} does not exist."),
5757
_ => throw new NotSupportedException("Only *.csproj and *.sln files are supported."),
5858
};
@@ -62,15 +62,13 @@ internal static async Task Handler(IAnsiConsole console, IKubernetes client, Inv
6262
if (crds.Count == 0)
6363
{
6464
console.WriteLine("No CRDs found. Exiting.");
65-
ctx.ExitCode = ExitCodes.Success;
66-
return;
65+
return ExitCodes.Success;
6766
}
6867

6968
console.WriteLine($"Found {crds.Count} CRDs.");
7069
if (!force && !await console.ConfirmAsync("[red]Should the CRDs be uninstalled?[/]", false))
7170
{
72-
ctx.ExitCode = ExitCodes.Aborted;
73-
return;
71+
return ExitCodes.Aborted;
7472
}
7573

7674
console.WriteLine($"""Starting uninstall from cluster with url "{client.BaseUri}".""");
@@ -109,5 +107,7 @@ internal static async Task Handler(IAnsiConsole console, IKubernetes client, Inv
109107
throw;
110108
}
111109
}
110+
111+
return ExitCodes.Success;
112112
}
113113
}

src/KubeOps.Cli/Commands/Utilities/Version.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public static Command Command
1919
var cmd = new Command(
2020
"api-version",
2121
"Prints the actual server version of the connected kubernetes cluster.");
22-
cmd.AddAlias("av");
23-
cmd.SetHandler(() =>
22+
cmd.Aliases.Add("av");
23+
cmd.SetAction(_ =>
2424
Handler(AnsiConsole.Console, new Kubernetes(KubernetesClientConfiguration.BuildDefaultConfig())));
2525

2626
return cmd;

src/KubeOps.Cli/KubeOps.Cli.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<PrivateAssets>all</PrivateAssets>
3030
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3131
</PackageReference>
32-
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
32+
<PackageReference Include="System.CommandLine" Version="2.0.0-beta6.25358.103" />
3333
</ItemGroup>
3434

3535
<ItemGroup>

src/KubeOps.Cli/Options.cs

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,55 @@ namespace KubeOps.Cli;
1111

1212
internal static class Options
1313
{
14-
public static readonly Option<OutputFormat> OutputFormat = new(
15-
"--format",
16-
() => Output.OutputFormat.Yaml,
17-
"The format of the generated output.");
18-
19-
public static readonly Option<string?> OutputPath = new(
20-
"--out",
21-
"The path the command will write the files to. If omitted, prints output to console.");
22-
23-
public static readonly Option<string?> TargetFramework = new(
24-
["--target-framework", "--tfm"],
25-
description: "Target framework of projects in the solution to search for entities. " +
26-
"If omitted, the newest framework is used.");
27-
28-
public static readonly Option<Regex?> SolutionProjectRegex = new(
29-
"--project",
30-
parseArgument: result =>
14+
public static readonly Option<OutputFormat> OutputFormat = new("--format")
15+
{
16+
Description = "The format of the generated output.",
17+
DefaultValueFactory = _ => Output.OutputFormat.Yaml,
18+
};
19+
20+
public static readonly Option<string?> OutputPath = new("--out")
21+
{
22+
Description = "The path the command will write the files to. If omitted, prints output to console.",
23+
};
24+
25+
public static readonly Option<string?> TargetFramework = new("--target-framework", "--tfm")
26+
{
27+
Description = "Target framework of projects in the solution to search for entities. " +
28+
"If omitted, the newest framework is used.",
29+
};
30+
31+
public static readonly Option<Regex?> SolutionProjectRegex = new("--project")
32+
{
33+
Description = "Regex pattern to filter projects in the solution to search for entities. " +
34+
"If omitted, all projects are searched.",
35+
CustomParser = result =>
3136
{
3237
var value = result.Tokens.Single().Value;
3338
return new Regex(value);
3439
},
35-
description: "Regex pattern to filter projects in the solution to search for entities. " +
36-
"If omitted, all projects are searched.");
37-
38-
public static readonly Option<bool> Force = new(
39-
["--force", "-f"],
40-
() => false,
41-
description: "Do not bother the user with questions and just do it.");
42-
43-
public static readonly Option<bool> ClearOutputPath = new(
44-
["--clear-out"],
45-
() => false,
46-
description: "Clear the output path before generating resources.");
47-
48-
public static readonly Option<string> AccessibleDockerImage = new(
49-
"--docker-image",
50-
() => "accessible-docker-image",
51-
description: "An accessible docker image to deploy");
52-
53-
public static readonly Option<string> AccessibleDockerTag = new(
54-
"--docker-image-tag",
55-
() => "latest",
56-
description: "Tag for an accessible docker image to deploy");
40+
};
41+
42+
public static readonly Option<bool> Force = new("--force", "-f")
43+
{
44+
Description = "Do not bother the user with questions and just do it.",
45+
DefaultValueFactory = _ => false,
46+
};
47+
48+
public static readonly Option<bool> ClearOutputPath = new("--clear-out")
49+
{
50+
Description = "Clear the output path before generating resources.",
51+
DefaultValueFactory = _ => false,
52+
};
53+
54+
public static readonly Option<string> AccessibleDockerImage = new("--docker-image")
55+
{
56+
Description = "An accessible docker image to deploy.",
57+
DefaultValueFactory = _ => "accessible-docker-image",
58+
};
59+
60+
public static readonly Option<string> AccessibleDockerTag = new("--docker-image-tag")
61+
{
62+
Description = "Tag for an accessible docker image to deploy.",
63+
DefaultValueFactory = _ => "latest",
64+
};
5765
}

0 commit comments

Comments
 (0)