diff --git a/src/KubeOps/Operator/Commands/Generators/CrdGenerator.cs b/src/KubeOps/Operator/Commands/Generators/CrdGenerator.cs index 322a40d6..b722cb7b 100644 --- a/src/KubeOps/Operator/Commands/Generators/CrdGenerator.cs +++ b/src/KubeOps/Operator/Commands/Generators/CrdGenerator.cs @@ -7,7 +7,7 @@ namespace KubeOps.Operator.Commands.Generators; [Command("crd", "crds", Description = "Generates the needed CRD for kubernetes.")] -internal class CrdGenerator : GeneratorBase +internal class CrdGenerator : OutputBase { private readonly ICrdBuilder _crdBuilder; diff --git a/src/KubeOps/Operator/Commands/Generators/DockerGenerator.cs b/src/KubeOps/Operator/Commands/Generators/DockerGenerator.cs index 0fae9d88..9ad0568a 100644 --- a/src/KubeOps/Operator/Commands/Generators/DockerGenerator.cs +++ b/src/KubeOps/Operator/Commands/Generators/DockerGenerator.cs @@ -5,7 +5,7 @@ namespace KubeOps.Operator.Commands.Generators; [Command("docker", Description = "Generates the docker file for building.")] -internal class DockerGenerator : GeneratorBase +internal class DockerGenerator : OutputBase { private readonly OperatorSettings _settings; private readonly bool _hasWebhooks; diff --git a/src/KubeOps/Operator/Commands/Generators/Generator.cs b/src/KubeOps/Operator/Commands/Generators/Generator.cs index f99fddc2..3385f6ad 100644 --- a/src/KubeOps/Operator/Commands/Generators/Generator.cs +++ b/src/KubeOps/Operator/Commands/Generators/Generator.cs @@ -8,7 +8,7 @@ namespace KubeOps.Operator.Commands.Generators; [Subcommand(typeof(InstallerGenerator))] [Subcommand(typeof(OperatorGenerator))] [Subcommand(typeof(RbacGenerator))] -internal class Generator : GeneratorBase +internal class Generator { public Task OnExecuteAsync(CommandLineApplication app) { diff --git a/src/KubeOps/Operator/Commands/Generators/InstallerGenerator.cs b/src/KubeOps/Operator/Commands/Generators/InstallerGenerator.cs index dafcf4e2..663b4a01 100644 --- a/src/KubeOps/Operator/Commands/Generators/InstallerGenerator.cs +++ b/src/KubeOps/Operator/Commands/Generators/InstallerGenerator.cs @@ -6,21 +6,27 @@ namespace KubeOps.Operator.Commands.Generators; -[Command("installer", Description = "Generates kustomization yaml for the whole installation of the operator.")] -internal class InstallerGenerator : GeneratorBase +[Command("installer", Description = "Generates kustomization YAML for installing the entire operator.")] +internal class InstallerGenerator : OutputBase { private readonly OperatorSettings _settings; public InstallerGenerator(OperatorSettings settings) => _settings = settings; - [Option("--crds-dir", Description = "The path where the crds are located.")] - public string? CrdsPath { get; set; } + [Option("--crds-dir", Description = "The path where the CRD YAML files are located.")] + public string CrdsPath { get; set; } = "../crds"; - [Option("--rbac-dir", Description = "The path where the rbac yamls are located.")] - public string? RbacPath { get; set; } + [Option("--rbac-dir", Description = "The path where the RBAC YAML files are located.")] + public string RbacPath { get; set; } = "../rbac"; - [Option("--operator-dir", Description = "The path where the operator yamls are located.")] - public string? OperatorPath { get; set; } + [Option("--operator-dir", Description = "The path where the operator YAML files are located.")] + public string OperatorPath { get; set; } = "../operator"; + + [Option("--image-name", Description = "The name of the operator's Docker image.")] + public string ImageName { get; set; } = "public-docker-image-path"; + + [Option("--image-tag", Description = "The tag for the Docker image.")] + public string ImageTag { get; set; } = "latest"; public async Task OnExecuteAsync(CommandLineApplication app) { @@ -44,19 +50,19 @@ public async Task OnExecuteAsync(CommandLineApplication app) Resources = new List { $"./namespace.{Format.ToString().ToLower()}", - CrdsPath == null || OutputPath == null - ? "../crds" + OutputPath == null + ? CrdsPath : Path.GetRelativePath(OutputPath, CrdsPath).Replace('\\', '/'), - RbacPath == null || OutputPath == null - ? "../rbac" + OutputPath == null + ? RbacPath : Path.GetRelativePath(OutputPath, RbacPath).Replace('\\', '/'), - OperatorPath == null || OutputPath == null - ? "../operator" + OutputPath == null + ? OperatorPath : Path.GetRelativePath(OutputPath, OperatorPath).Replace('\\', '/'), }, Images = new List { - new() { Name = "operator", NewName = "public-docker-image-path", NewTag = "latest", }, + new() { Name = "operator", NewName = ImageName, NewTag = ImageTag, }, }, }, Format)); diff --git a/src/KubeOps/Operator/Commands/Generators/OperatorGenerator.cs b/src/KubeOps/Operator/Commands/Generators/OperatorGenerator.cs index c2fd3190..0e8a9d7c 100644 --- a/src/KubeOps/Operator/Commands/Generators/OperatorGenerator.cs +++ b/src/KubeOps/Operator/Commands/Generators/OperatorGenerator.cs @@ -8,7 +8,7 @@ namespace KubeOps.Operator.Commands.Generators; [Command("operator", "op", Description = "Generates the needed yamls to run the operator.")] -internal class OperatorGenerator : GeneratorBase +internal class OperatorGenerator : OutputBase { private readonly OperatorSettings _settings; private readonly bool _hasWebhooks; diff --git a/src/KubeOps/Operator/Commands/Generators/GeneratorBase.cs b/src/KubeOps/Operator/Commands/Generators/OutputBase.cs similarity index 51% rename from src/KubeOps/Operator/Commands/Generators/GeneratorBase.cs rename to src/KubeOps/Operator/Commands/Generators/OutputBase.cs index 47fcc486..1c99c81e 100644 --- a/src/KubeOps/Operator/Commands/Generators/GeneratorBase.cs +++ b/src/KubeOps/Operator/Commands/Generators/OutputBase.cs @@ -3,13 +3,15 @@ namespace KubeOps.Operator.Commands.Generators; -internal abstract class GeneratorBase +internal abstract class OutputBase { - [Option(CommandOptionType.SingleValue, Description = "Determines the output format for the generator.")] + [Option( + CommandOptionType.SingleValue, + Description = "Sets the output format for the generator.")] public SerializerOutputFormat Format { get; set; } [Option( - Description = @"The ""root"" path for the generator to put files in - if empty, prints to console.", + Description = @"The path the command will write the files to. If empty, prints output to console.", LongName = "out")] public string? OutputPath { get; set; } } diff --git a/src/KubeOps/Operator/Commands/Generators/RbacGenerator.cs b/src/KubeOps/Operator/Commands/Generators/RbacGenerator.cs index df39d032..c0a40ac9 100644 --- a/src/KubeOps/Operator/Commands/Generators/RbacGenerator.cs +++ b/src/KubeOps/Operator/Commands/Generators/RbacGenerator.cs @@ -8,7 +8,7 @@ namespace KubeOps.Operator.Commands.Generators; [Command("rbac", Description = "Generates the needed rbac roles for the operator.")] -internal class RbacGenerator : GeneratorBase +internal class RbacGenerator : OutputBase { private readonly IRbacBuilder _rbacBuilder;