chore: update project structure with contracts and services for CaddyManager, including configuration and Docker integration
All checks were successful
Caddy Manager CI build / docker (push) Successful in 1m16s

This commit is contained in:
2025-07-23 10:37:51 +07:00
parent 18c710d341
commit ec454d0346
56 changed files with 8511 additions and 34 deletions

View File

@@ -0,0 +1,11 @@
namespace CaddyManager.Contracts.Configurations.Caddy;
/// <summary>
/// Wraps the configurations for Caddy service
/// </summary>
public class CaddyServiceConfigurations
{
public const string Caddy = "Caddy";
public string ConfigDir { get; set; } = "/config";
}

View File

@@ -0,0 +1,32 @@
namespace CaddyManager.Contracts.Configurations.Docker;
/// <summary>
/// Configuration for the Docker service
/// </summary>
public class DockerServiceConfiguration
{
public const string Docker = "Docker";
/// <summary>
/// Name of the Caddy container to be controlled (i.e restart)
/// </summary>
public string CaddyContainerName { get; set; } = "caddy";
/// <summary>
/// Uri to the Docker host
/// </summary>
public string DockerHost { get; set; } = "unix:///var/run/docker.sock";
/// <summary>
/// Returns the Docker host with environment check. If the environment variable DOCKER_HOST is set, it will return
/// that value, otherwise it will return the value of DockerHost
/// </summary>
public string DockerHostWithEnvCheck
{
get
{
var envValue = Environment.GetEnvironmentVariable("DOCKER_HOST");
return string.IsNullOrWhiteSpace(envValue) ? DockerHost : envValue;
}
}
}

View File

@@ -0,0 +1,18 @@
using CaddyManager.Contracts.Configurations.Caddy;
using CaddyManager.Contracts.Configurations.Docker;
namespace CaddyManager.Contracts.Configurations;
/// <summary>
/// Contract for the services providing the configurations for the application
/// </summary>
public interface IConfigurationsService
{
/// <summary>
/// Method extracting the configurations from the appsettings.json file or environment variables base on the
/// type of the configuration class to determine the section name
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
T Get<T>() where T : class;
}