Skip to content

Commit 3a7e229

Browse files
authored
Remove DotMake.CommandLine (#8)
1 parent 6d04e52 commit 3a7e229

File tree

5 files changed

+13
-51
lines changed

5 files changed

+13
-51
lines changed

src/K8sOperator.NET/Commands/Install.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,27 @@
1-
using DotMake.CommandLine;
2-
using k8s;
1+
using k8s;
32
using k8s.Models;
43
using K8sOperator.NET.Builder;
54
using K8sOperator.NET.Extensions;
6-
using K8sOperator.NET.Generator;
75
using K8sOperator.NET.Generator.Builders;
86
using K8sOperator.NET.Metadata;
9-
using System;
10-
using System.Reflection;
11-
using System.Runtime.CompilerServices;
12-
using System.Xml.Linq;
137

148
namespace K8sOperator.NET.Commands;
159

16-
[CliCommand(
17-
Name = "install",
18-
Description = "Install or update operator",
19-
Parent = typeof(Root)
20-
)]
2110
internal class Install(IServiceProvider serviceProvider, IControllerDataSource dataSource)
2211
{
23-
[CliOption(Description = "export")]
24-
public bool Export { get; set; } = true;
25-
26-
[CliOption(Description = "Name of the operator")]
27-
public string Name { get; set; } = Assembly.GetEntryAssembly()?.GetName().Name ?? string.Empty;
28-
2912
public async Task RunAsync()
3013
{
3114
var watchers = dataSource.GetWatchers(serviceProvider);
3215
var clusterrole = CreateClusterRole(dataSource.Metadata, watchers);
3316
var clusterrolebinding = CreateClusterRoleBinding(dataSource.Metadata);
3417
var deployment = CreateDeployment(dataSource.Metadata);
3518

36-
3719
foreach (var item in watchers)
3820
{
3921
var crd = CreateCustomResourceDefinition(item);
40-
4122
Console.WriteLine(KubernetesYaml.Serialize(crd));
4223
Console.WriteLine("---");
4324
}
44-
4525
Console.WriteLine(KubernetesYaml.Serialize(clusterrole));
4626
Console.WriteLine("---");
4727
Console.WriteLine(KubernetesYaml.Serialize(clusterrolebinding));

src/K8sOperator.NET/Commands/Operator.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
using DotMake.CommandLine;
2-
using K8sOperator.NET.Builder;
1+
using K8sOperator.NET.Builder;
32
using K8sOperator.NET.Extensions;
43
using Microsoft.Extensions.Logging;
54

65
namespace K8sOperator.NET.Commands;
76

8-
[CliCommand(
9-
Name = "operator",
10-
NamePrefixConvention = CliNamePrefixConvention.DoubleHyphen,
11-
Parent = typeof(Root)
12-
)]
137
internal class Operator(IServiceProvider serviceProvider, IControllerDataSource dataSource, ILoggerFactory loggerFactory)
148
{
159
private readonly CancellationTokenSource _tokenSource = new();

src/K8sOperator.NET/Commands/Root.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/K8sOperator.NET/K8sOperator.NET.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="DotMake.CommandLine" />
1110
<PackageReference Include="KubernetesClient" />
1211
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" />
1312
<PackageReference Include="Microsoft.Extensions.Hosting" />

src/K8sOperator.NET/OperatorHost.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using DotMake.CommandLine;
2-
using K8sOperator.NET.Builder;
1+
using K8sOperator.NET.Builder;
32
using K8sOperator.NET.Commands;
43
using Microsoft.Extensions.DependencyInjection;
54

@@ -52,7 +51,15 @@ internal OperatorHostApplication(IServiceProvider serviceProvider, IControllerDa
5251

5352
public async Task RunAsync()
5453
{
55-
Cli.Ext.SetServiceProvider(ServiceProvider);
56-
await Cli.RunAsync<Root>(_args);
54+
if (_args.Contains("--operator"))
55+
{
56+
var oper = ActivatorUtilities.CreateInstance<Operator>(ServiceProvider, DataSource);
57+
await oper.RunAsync();
58+
}
59+
else if(_args.Contains("install"))
60+
{
61+
var installer = ActivatorUtilities.CreateInstance<Install>(ServiceProvider, DataSource);
62+
await installer.RunAsync();
63+
}
5764
}
5865
}

0 commit comments

Comments
 (0)