From dda8343af61bcc9a67c97e9670ae74258de1078a Mon Sep 17 00:00:00 2001 From: Damian Edwards Date: Fri, 26 Apr 2024 16:53:39 -0700 Subject: [PATCH] Update KeycloakResource in labs --- .../end/eShop.AppHost/KeycloakResource.cs | 67 ++++++++++++------- .../src/eShop.AppHost/KeycloakResource.cs | 67 ++++++++++++------- .../end/eShop.AppHost/KeycloakResource.cs | 67 ++++++++++++------- .../src/eShop.AppHost/KeycloakResource.cs | 67 ++++++++++++------- .../end/eShop.AppHost/KeycloakResource.cs | 67 ++++++++++++------- .../src/eShop.AppHost/KeycloakResource.cs | 67 ++++++++++++------- .../src/eShop.AppHost/KeycloakResource.cs | 67 ++++++++++++------- 7 files changed, 287 insertions(+), 182 deletions(-) diff --git a/labs/3-Add-Identity/end/eShop.AppHost/KeycloakResource.cs b/labs/3-Add-Identity/end/eShop.AppHost/KeycloakResource.cs index 6ea30c8..0d18341 100644 --- a/labs/3-Add-Identity/end/eShop.AppHost/KeycloakResource.cs +++ b/labs/3-Add-Identity/end/eShop.AppHost/KeycloakResource.cs @@ -6,57 +6,72 @@ internal static class KeycloakHostingExtensions { private const int DefaultContainerPort = 8080; - public static IResourceBuilder AddKeycloakContainer( + public static IResourceBuilder WithReference(this IResourceBuilder builder, + IResourceBuilder keycloakBuilder, + string env) + where TResource : IResourceWithEnvironment + { + builder.WithReference(keycloakBuilder); + builder.WithEnvironment(env, keycloakBuilder.Resource.ClientSecret); + + return builder; + } + + public static IResourceBuilder AddKeycloakContainer( this IDistributedApplicationBuilder builder, string name, int? port = null, string? tag = null) { - var keycloakContainer = new KeycloakContainerResource(name); + var keycloakContainer = new KeycloakResource(name) + { + ClientSecret = Guid.NewGuid().ToString("N") + }; - return builder + var keycloak = builder .AddResource(keycloakContainer) .WithAnnotation(new ContainerImageAnnotation { Registry = "quay.io", Image = "keycloak/keycloak", Tag = tag ?? "latest" }) .WithHttpEndpoint(port: port, targetPort: DefaultContainerPort) .WithEnvironment("KEYCLOAK_ADMIN", "admin") .WithEnvironment("KEYCLOAK_ADMIN_PASSWORD", "admin") - .WithArgs("start-dev") - .WithManifestPublishingCallback(context => WriteKeycloakContainerToManifest(context, keycloakContainer)); + .WithEnvironment("WEBAPP_CLIENT_SECRET", keycloakContainer.ClientSecret); + + if (builder.ExecutionContext.IsRunMode) + { + keycloak.WithArgs("start-dev"); + } + else + { + keycloak.WithArgs("start"); + } + + return keycloak; } - public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) + public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) { builder .WithBindMount(source, "/opt/keycloak/data/import") .WithAnnotation(new CommandLineArgsCallbackAnnotation(args => { + // TODO: This could be cleaned up to make it properly compose with any other callers who customize args args.Clear(); - args.Add("start-dev"); + if (builder.ApplicationBuilder.ExecutionContext.IsRunMode) + { + args.Add("start-dev"); + } + else + { + args.Add("start"); + } args.Add("--import-realm"); })); return builder; } - - private static async Task WriteKeycloakContainerToManifest(ManifestPublishingContext context, KeycloakContainerResource resource) - { - var manifestResource = new KeycloakContainerResource(resource.Name); - - foreach (var annotation in resource.Annotations) - { - if (annotation is not CommandLineArgsCallbackAnnotation) - { - manifestResource.Annotations.Add(annotation); - } - } - - // Set the container entry point to 'start' instead of 'start-dev' - manifestResource.Annotations.Add(new CommandLineArgsCallbackAnnotation(args => args.Add("start"))); - - await context.WriteContainerAsync(resource); - } } -internal class KeycloakContainerResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery +internal class KeycloakResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery { + public string? ClientSecret { get; set; } } diff --git a/labs/3-Add-Identity/src/eShop.AppHost/KeycloakResource.cs b/labs/3-Add-Identity/src/eShop.AppHost/KeycloakResource.cs index 6ea30c8..0d18341 100644 --- a/labs/3-Add-Identity/src/eShop.AppHost/KeycloakResource.cs +++ b/labs/3-Add-Identity/src/eShop.AppHost/KeycloakResource.cs @@ -6,57 +6,72 @@ internal static class KeycloakHostingExtensions { private const int DefaultContainerPort = 8080; - public static IResourceBuilder AddKeycloakContainer( + public static IResourceBuilder WithReference(this IResourceBuilder builder, + IResourceBuilder keycloakBuilder, + string env) + where TResource : IResourceWithEnvironment + { + builder.WithReference(keycloakBuilder); + builder.WithEnvironment(env, keycloakBuilder.Resource.ClientSecret); + + return builder; + } + + public static IResourceBuilder AddKeycloakContainer( this IDistributedApplicationBuilder builder, string name, int? port = null, string? tag = null) { - var keycloakContainer = new KeycloakContainerResource(name); + var keycloakContainer = new KeycloakResource(name) + { + ClientSecret = Guid.NewGuid().ToString("N") + }; - return builder + var keycloak = builder .AddResource(keycloakContainer) .WithAnnotation(new ContainerImageAnnotation { Registry = "quay.io", Image = "keycloak/keycloak", Tag = tag ?? "latest" }) .WithHttpEndpoint(port: port, targetPort: DefaultContainerPort) .WithEnvironment("KEYCLOAK_ADMIN", "admin") .WithEnvironment("KEYCLOAK_ADMIN_PASSWORD", "admin") - .WithArgs("start-dev") - .WithManifestPublishingCallback(context => WriteKeycloakContainerToManifest(context, keycloakContainer)); + .WithEnvironment("WEBAPP_CLIENT_SECRET", keycloakContainer.ClientSecret); + + if (builder.ExecutionContext.IsRunMode) + { + keycloak.WithArgs("start-dev"); + } + else + { + keycloak.WithArgs("start"); + } + + return keycloak; } - public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) + public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) { builder .WithBindMount(source, "/opt/keycloak/data/import") .WithAnnotation(new CommandLineArgsCallbackAnnotation(args => { + // TODO: This could be cleaned up to make it properly compose with any other callers who customize args args.Clear(); - args.Add("start-dev"); + if (builder.ApplicationBuilder.ExecutionContext.IsRunMode) + { + args.Add("start-dev"); + } + else + { + args.Add("start"); + } args.Add("--import-realm"); })); return builder; } - - private static async Task WriteKeycloakContainerToManifest(ManifestPublishingContext context, KeycloakContainerResource resource) - { - var manifestResource = new KeycloakContainerResource(resource.Name); - - foreach (var annotation in resource.Annotations) - { - if (annotation is not CommandLineArgsCallbackAnnotation) - { - manifestResource.Annotations.Add(annotation); - } - } - - // Set the container entry point to 'start' instead of 'start-dev' - manifestResource.Annotations.Add(new CommandLineArgsCallbackAnnotation(args => args.Add("start"))); - - await context.WriteContainerAsync(resource); - } } -internal class KeycloakContainerResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery +internal class KeycloakResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery { + public string? ClientSecret { get; set; } } diff --git a/labs/4-Add-Shopping-Basket/end/eShop.AppHost/KeycloakResource.cs b/labs/4-Add-Shopping-Basket/end/eShop.AppHost/KeycloakResource.cs index 6ea30c8..0d18341 100644 --- a/labs/4-Add-Shopping-Basket/end/eShop.AppHost/KeycloakResource.cs +++ b/labs/4-Add-Shopping-Basket/end/eShop.AppHost/KeycloakResource.cs @@ -6,57 +6,72 @@ internal static class KeycloakHostingExtensions { private const int DefaultContainerPort = 8080; - public static IResourceBuilder AddKeycloakContainer( + public static IResourceBuilder WithReference(this IResourceBuilder builder, + IResourceBuilder keycloakBuilder, + string env) + where TResource : IResourceWithEnvironment + { + builder.WithReference(keycloakBuilder); + builder.WithEnvironment(env, keycloakBuilder.Resource.ClientSecret); + + return builder; + } + + public static IResourceBuilder AddKeycloakContainer( this IDistributedApplicationBuilder builder, string name, int? port = null, string? tag = null) { - var keycloakContainer = new KeycloakContainerResource(name); + var keycloakContainer = new KeycloakResource(name) + { + ClientSecret = Guid.NewGuid().ToString("N") + }; - return builder + var keycloak = builder .AddResource(keycloakContainer) .WithAnnotation(new ContainerImageAnnotation { Registry = "quay.io", Image = "keycloak/keycloak", Tag = tag ?? "latest" }) .WithHttpEndpoint(port: port, targetPort: DefaultContainerPort) .WithEnvironment("KEYCLOAK_ADMIN", "admin") .WithEnvironment("KEYCLOAK_ADMIN_PASSWORD", "admin") - .WithArgs("start-dev") - .WithManifestPublishingCallback(context => WriteKeycloakContainerToManifest(context, keycloakContainer)); + .WithEnvironment("WEBAPP_CLIENT_SECRET", keycloakContainer.ClientSecret); + + if (builder.ExecutionContext.IsRunMode) + { + keycloak.WithArgs("start-dev"); + } + else + { + keycloak.WithArgs("start"); + } + + return keycloak; } - public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) + public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) { builder .WithBindMount(source, "/opt/keycloak/data/import") .WithAnnotation(new CommandLineArgsCallbackAnnotation(args => { + // TODO: This could be cleaned up to make it properly compose with any other callers who customize args args.Clear(); - args.Add("start-dev"); + if (builder.ApplicationBuilder.ExecutionContext.IsRunMode) + { + args.Add("start-dev"); + } + else + { + args.Add("start"); + } args.Add("--import-realm"); })); return builder; } - - private static async Task WriteKeycloakContainerToManifest(ManifestPublishingContext context, KeycloakContainerResource resource) - { - var manifestResource = new KeycloakContainerResource(resource.Name); - - foreach (var annotation in resource.Annotations) - { - if (annotation is not CommandLineArgsCallbackAnnotation) - { - manifestResource.Annotations.Add(annotation); - } - } - - // Set the container entry point to 'start' instead of 'start-dev' - manifestResource.Annotations.Add(new CommandLineArgsCallbackAnnotation(args => args.Add("start"))); - - await context.WriteContainerAsync(resource); - } } -internal class KeycloakContainerResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery +internal class KeycloakResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery { + public string? ClientSecret { get; set; } } diff --git a/labs/4-Add-Shopping-Basket/src/eShop.AppHost/KeycloakResource.cs b/labs/4-Add-Shopping-Basket/src/eShop.AppHost/KeycloakResource.cs index 6ea30c8..0d18341 100644 --- a/labs/4-Add-Shopping-Basket/src/eShop.AppHost/KeycloakResource.cs +++ b/labs/4-Add-Shopping-Basket/src/eShop.AppHost/KeycloakResource.cs @@ -6,57 +6,72 @@ internal static class KeycloakHostingExtensions { private const int DefaultContainerPort = 8080; - public static IResourceBuilder AddKeycloakContainer( + public static IResourceBuilder WithReference(this IResourceBuilder builder, + IResourceBuilder keycloakBuilder, + string env) + where TResource : IResourceWithEnvironment + { + builder.WithReference(keycloakBuilder); + builder.WithEnvironment(env, keycloakBuilder.Resource.ClientSecret); + + return builder; + } + + public static IResourceBuilder AddKeycloakContainer( this IDistributedApplicationBuilder builder, string name, int? port = null, string? tag = null) { - var keycloakContainer = new KeycloakContainerResource(name); + var keycloakContainer = new KeycloakResource(name) + { + ClientSecret = Guid.NewGuid().ToString("N") + }; - return builder + var keycloak = builder .AddResource(keycloakContainer) .WithAnnotation(new ContainerImageAnnotation { Registry = "quay.io", Image = "keycloak/keycloak", Tag = tag ?? "latest" }) .WithHttpEndpoint(port: port, targetPort: DefaultContainerPort) .WithEnvironment("KEYCLOAK_ADMIN", "admin") .WithEnvironment("KEYCLOAK_ADMIN_PASSWORD", "admin") - .WithArgs("start-dev") - .WithManifestPublishingCallback(context => WriteKeycloakContainerToManifest(context, keycloakContainer)); + .WithEnvironment("WEBAPP_CLIENT_SECRET", keycloakContainer.ClientSecret); + + if (builder.ExecutionContext.IsRunMode) + { + keycloak.WithArgs("start-dev"); + } + else + { + keycloak.WithArgs("start"); + } + + return keycloak; } - public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) + public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) { builder .WithBindMount(source, "/opt/keycloak/data/import") .WithAnnotation(new CommandLineArgsCallbackAnnotation(args => { + // TODO: This could be cleaned up to make it properly compose with any other callers who customize args args.Clear(); - args.Add("start-dev"); + if (builder.ApplicationBuilder.ExecutionContext.IsRunMode) + { + args.Add("start-dev"); + } + else + { + args.Add("start"); + } args.Add("--import-realm"); })); return builder; } - - private static async Task WriteKeycloakContainerToManifest(ManifestPublishingContext context, KeycloakContainerResource resource) - { - var manifestResource = new KeycloakContainerResource(resource.Name); - - foreach (var annotation in resource.Annotations) - { - if (annotation is not CommandLineArgsCallbackAnnotation) - { - manifestResource.Annotations.Add(annotation); - } - } - - // Set the container entry point to 'start' instead of 'start-dev' - manifestResource.Annotations.Add(new CommandLineArgsCallbackAnnotation(args => args.Add("start"))); - - await context.WriteContainerAsync(resource); - } } -internal class KeycloakContainerResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery +internal class KeycloakResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery { + public string? ClientSecret { get; set; } } diff --git a/labs/5-Add-Checkout/end/eShop.AppHost/KeycloakResource.cs b/labs/5-Add-Checkout/end/eShop.AppHost/KeycloakResource.cs index 6ea30c8..0d18341 100644 --- a/labs/5-Add-Checkout/end/eShop.AppHost/KeycloakResource.cs +++ b/labs/5-Add-Checkout/end/eShop.AppHost/KeycloakResource.cs @@ -6,57 +6,72 @@ internal static class KeycloakHostingExtensions { private const int DefaultContainerPort = 8080; - public static IResourceBuilder AddKeycloakContainer( + public static IResourceBuilder WithReference(this IResourceBuilder builder, + IResourceBuilder keycloakBuilder, + string env) + where TResource : IResourceWithEnvironment + { + builder.WithReference(keycloakBuilder); + builder.WithEnvironment(env, keycloakBuilder.Resource.ClientSecret); + + return builder; + } + + public static IResourceBuilder AddKeycloakContainer( this IDistributedApplicationBuilder builder, string name, int? port = null, string? tag = null) { - var keycloakContainer = new KeycloakContainerResource(name); + var keycloakContainer = new KeycloakResource(name) + { + ClientSecret = Guid.NewGuid().ToString("N") + }; - return builder + var keycloak = builder .AddResource(keycloakContainer) .WithAnnotation(new ContainerImageAnnotation { Registry = "quay.io", Image = "keycloak/keycloak", Tag = tag ?? "latest" }) .WithHttpEndpoint(port: port, targetPort: DefaultContainerPort) .WithEnvironment("KEYCLOAK_ADMIN", "admin") .WithEnvironment("KEYCLOAK_ADMIN_PASSWORD", "admin") - .WithArgs("start-dev") - .WithManifestPublishingCallback(context => WriteKeycloakContainerToManifest(context, keycloakContainer)); + .WithEnvironment("WEBAPP_CLIENT_SECRET", keycloakContainer.ClientSecret); + + if (builder.ExecutionContext.IsRunMode) + { + keycloak.WithArgs("start-dev"); + } + else + { + keycloak.WithArgs("start"); + } + + return keycloak; } - public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) + public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) { builder .WithBindMount(source, "/opt/keycloak/data/import") .WithAnnotation(new CommandLineArgsCallbackAnnotation(args => { + // TODO: This could be cleaned up to make it properly compose with any other callers who customize args args.Clear(); - args.Add("start-dev"); + if (builder.ApplicationBuilder.ExecutionContext.IsRunMode) + { + args.Add("start-dev"); + } + else + { + args.Add("start"); + } args.Add("--import-realm"); })); return builder; } - - private static async Task WriteKeycloakContainerToManifest(ManifestPublishingContext context, KeycloakContainerResource resource) - { - var manifestResource = new KeycloakContainerResource(resource.Name); - - foreach (var annotation in resource.Annotations) - { - if (annotation is not CommandLineArgsCallbackAnnotation) - { - manifestResource.Annotations.Add(annotation); - } - } - - // Set the container entry point to 'start' instead of 'start-dev' - manifestResource.Annotations.Add(new CommandLineArgsCallbackAnnotation(args => args.Add("start"))); - - await context.WriteContainerAsync(resource); - } } -internal class KeycloakContainerResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery +internal class KeycloakResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery { + public string? ClientSecret { get; set; } } diff --git a/labs/5-Add-Checkout/src/eShop.AppHost/KeycloakResource.cs b/labs/5-Add-Checkout/src/eShop.AppHost/KeycloakResource.cs index 6ea30c8..0d18341 100644 --- a/labs/5-Add-Checkout/src/eShop.AppHost/KeycloakResource.cs +++ b/labs/5-Add-Checkout/src/eShop.AppHost/KeycloakResource.cs @@ -6,57 +6,72 @@ internal static class KeycloakHostingExtensions { private const int DefaultContainerPort = 8080; - public static IResourceBuilder AddKeycloakContainer( + public static IResourceBuilder WithReference(this IResourceBuilder builder, + IResourceBuilder keycloakBuilder, + string env) + where TResource : IResourceWithEnvironment + { + builder.WithReference(keycloakBuilder); + builder.WithEnvironment(env, keycloakBuilder.Resource.ClientSecret); + + return builder; + } + + public static IResourceBuilder AddKeycloakContainer( this IDistributedApplicationBuilder builder, string name, int? port = null, string? tag = null) { - var keycloakContainer = new KeycloakContainerResource(name); + var keycloakContainer = new KeycloakResource(name) + { + ClientSecret = Guid.NewGuid().ToString("N") + }; - return builder + var keycloak = builder .AddResource(keycloakContainer) .WithAnnotation(new ContainerImageAnnotation { Registry = "quay.io", Image = "keycloak/keycloak", Tag = tag ?? "latest" }) .WithHttpEndpoint(port: port, targetPort: DefaultContainerPort) .WithEnvironment("KEYCLOAK_ADMIN", "admin") .WithEnvironment("KEYCLOAK_ADMIN_PASSWORD", "admin") - .WithArgs("start-dev") - .WithManifestPublishingCallback(context => WriteKeycloakContainerToManifest(context, keycloakContainer)); + .WithEnvironment("WEBAPP_CLIENT_SECRET", keycloakContainer.ClientSecret); + + if (builder.ExecutionContext.IsRunMode) + { + keycloak.WithArgs("start-dev"); + } + else + { + keycloak.WithArgs("start"); + } + + return keycloak; } - public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) + public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) { builder .WithBindMount(source, "/opt/keycloak/data/import") .WithAnnotation(new CommandLineArgsCallbackAnnotation(args => { + // TODO: This could be cleaned up to make it properly compose with any other callers who customize args args.Clear(); - args.Add("start-dev"); + if (builder.ApplicationBuilder.ExecutionContext.IsRunMode) + { + args.Add("start-dev"); + } + else + { + args.Add("start"); + } args.Add("--import-realm"); })); return builder; } - - private static async Task WriteKeycloakContainerToManifest(ManifestPublishingContext context, KeycloakContainerResource resource) - { - var manifestResource = new KeycloakContainerResource(resource.Name); - - foreach (var annotation in resource.Annotations) - { - if (annotation is not CommandLineArgsCallbackAnnotation) - { - manifestResource.Annotations.Add(annotation); - } - } - - // Set the container entry point to 'start' instead of 'start-dev' - manifestResource.Annotations.Add(new CommandLineArgsCallbackAnnotation(args => args.Add("start"))); - - await context.WriteContainerAsync(resource); - } } -internal class KeycloakContainerResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery +internal class KeycloakResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery { + public string? ClientSecret { get; set; } } diff --git a/labs/6-Add-Resiliency/src/eShop.AppHost/KeycloakResource.cs b/labs/6-Add-Resiliency/src/eShop.AppHost/KeycloakResource.cs index 6ea30c8..0d18341 100644 --- a/labs/6-Add-Resiliency/src/eShop.AppHost/KeycloakResource.cs +++ b/labs/6-Add-Resiliency/src/eShop.AppHost/KeycloakResource.cs @@ -6,57 +6,72 @@ internal static class KeycloakHostingExtensions { private const int DefaultContainerPort = 8080; - public static IResourceBuilder AddKeycloakContainer( + public static IResourceBuilder WithReference(this IResourceBuilder builder, + IResourceBuilder keycloakBuilder, + string env) + where TResource : IResourceWithEnvironment + { + builder.WithReference(keycloakBuilder); + builder.WithEnvironment(env, keycloakBuilder.Resource.ClientSecret); + + return builder; + } + + public static IResourceBuilder AddKeycloakContainer( this IDistributedApplicationBuilder builder, string name, int? port = null, string? tag = null) { - var keycloakContainer = new KeycloakContainerResource(name); + var keycloakContainer = new KeycloakResource(name) + { + ClientSecret = Guid.NewGuid().ToString("N") + }; - return builder + var keycloak = builder .AddResource(keycloakContainer) .WithAnnotation(new ContainerImageAnnotation { Registry = "quay.io", Image = "keycloak/keycloak", Tag = tag ?? "latest" }) .WithHttpEndpoint(port: port, targetPort: DefaultContainerPort) .WithEnvironment("KEYCLOAK_ADMIN", "admin") .WithEnvironment("KEYCLOAK_ADMIN_PASSWORD", "admin") - .WithArgs("start-dev") - .WithManifestPublishingCallback(context => WriteKeycloakContainerToManifest(context, keycloakContainer)); + .WithEnvironment("WEBAPP_CLIENT_SECRET", keycloakContainer.ClientSecret); + + if (builder.ExecutionContext.IsRunMode) + { + keycloak.WithArgs("start-dev"); + } + else + { + keycloak.WithArgs("start"); + } + + return keycloak; } - public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) + public static IResourceBuilder ImportRealms(this IResourceBuilder builder, string source) { builder .WithBindMount(source, "/opt/keycloak/data/import") .WithAnnotation(new CommandLineArgsCallbackAnnotation(args => { + // TODO: This could be cleaned up to make it properly compose with any other callers who customize args args.Clear(); - args.Add("start-dev"); + if (builder.ApplicationBuilder.ExecutionContext.IsRunMode) + { + args.Add("start-dev"); + } + else + { + args.Add("start"); + } args.Add("--import-realm"); })); return builder; } - - private static async Task WriteKeycloakContainerToManifest(ManifestPublishingContext context, KeycloakContainerResource resource) - { - var manifestResource = new KeycloakContainerResource(resource.Name); - - foreach (var annotation in resource.Annotations) - { - if (annotation is not CommandLineArgsCallbackAnnotation) - { - manifestResource.Annotations.Add(annotation); - } - } - - // Set the container entry point to 'start' instead of 'start-dev' - manifestResource.Annotations.Add(new CommandLineArgsCallbackAnnotation(args => args.Add("start"))); - - await context.WriteContainerAsync(resource); - } } -internal class KeycloakContainerResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery +internal class KeycloakResource(string name) : ContainerResource(name), IResourceWithServiceDiscovery { + public string? ClientSecret { get; set; } }