-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(operator): add build targets extension for automatic resource ge…
…neration BREAKING CHANGE: The targets file contains other properties than before. Refer to the documentation for explicit details.
- Loading branch information
Showing
15 changed files
with
174 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,7 @@ | |
"tools": { | ||
"docfx": { | ||
"version": "2.71.0", | ||
"commands": [ | ||
"docfx" | ||
] | ||
"commands": ["docfx"] | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
75 changes: 0 additions & 75 deletions
75
_old/src/KubeOps/Operator/Commands/Generators/InstallerGenerator.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
config/ | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
todo: | ||
- other CLI commands | ||
- build targets | ||
- error handling | ||
- web: webhooks | ||
- docs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System.CommandLine; | ||
using System.CommandLine.Invocation; | ||
|
||
using k8s; | ||
using k8s.Models; | ||
|
||
using KubeOps.Abstractions.Kustomize; | ||
using KubeOps.Cli.Output; | ||
|
||
using Spectre.Console; | ||
|
||
namespace KubeOps.Cli.Commands.Generator; | ||
|
||
internal static class InstallerGenerator | ||
{ | ||
public static Command Command | ||
{ | ||
get | ||
{ | ||
var cmd = new Command("installer", "Generates Kustomization YAML to install the entire operator.") | ||
{ | ||
Options.OutputPath, Options.OutputFormat, Arguments.OperatorName, | ||
}; | ||
cmd.SetHandler(ctx => Handler(AnsiConsole.Console, ctx)); | ||
|
||
return cmd; | ||
} | ||
} | ||
|
||
internal static async Task Handler(IAnsiConsole console, InvocationContext ctx) | ||
{ | ||
var outPath = ctx.ParseResult.GetValueForOption(Options.OutputPath); | ||
var format = ctx.ParseResult.GetValueForOption(Options.OutputFormat); | ||
var name = ctx.ParseResult.GetValueForArgument(Arguments.OperatorName); | ||
|
||
var result = new ResultOutput(console, format); | ||
console.WriteLine("Generate operator installer."); | ||
|
||
result.Add( | ||
$"namespace.{format.ToString().ToLowerInvariant()}", | ||
new V1Namespace(metadata: new(name: "system")).Initialize()); | ||
result.Add( | ||
$"kustomization.{format.ToString().ToLowerInvariant()}", | ||
new KustomizationConfig | ||
{ | ||
NamePrefix = $"{name}-", | ||
Namespace = $"{name}-system", | ||
CommonLabels = new Dictionary<string, string> { { "operator", name }, }, | ||
Resources = new List<string> | ||
{ | ||
$"./namespace.{format.ToString().ToLowerInvariant()}", "./rbac", "./operator", "./crds", | ||
}, | ||
Images = new List<KustomizationImage> | ||
{ | ||
new() { Name = "operator", NewName = "accessible-docker-image", NewTag = "latest", }, | ||
}, | ||
}); | ||
|
||
if (outPath is not null) | ||
{ | ||
await result.Write(outPath); | ||
} | ||
else | ||
{ | ||
result.Write(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.