Some checks failed
Build and Publish Docker Image / build-and-push (push) Has been cancelled
53 lines
2.0 KiB
C#
53 lines
2.0 KiB
C#
using OTSSignsOrchestrator.Core.Models.DTOs;
|
|
|
|
namespace OTSSignsOrchestrator.Core.Services;
|
|
|
|
/// <summary>
|
|
/// Abstraction for Docker CLI stack operations (deploy, remove, list, inspect).
|
|
/// Implementations may use local docker CLI or SSH-based remote execution.
|
|
/// </summary>
|
|
public interface IDockerCliService
|
|
{
|
|
Task<DeploymentResultDto> DeployStackAsync(string stackName, string composeYaml, bool resolveImage = false);
|
|
Task<DeploymentResultDto> RemoveStackAsync(string stackName);
|
|
Task<List<StackInfo>> ListStacksAsync();
|
|
Task<List<ServiceInfo>> InspectStackServicesAsync(string stackName);
|
|
|
|
/// <summary>Ensures a directory exists on the target host (equivalent to mkdir -p).</summary>
|
|
Task<bool> EnsureDirectoryAsync(string path);
|
|
|
|
/// <summary>
|
|
/// Ensures the required folders exist on an SMB/CIFS share, creating any that are missing.
|
|
/// If <paramref name="cifsShareFolder"/> is non-empty, creates it first as a subfolder of the share,
|
|
/// then creates the volume folders inside it.
|
|
/// Uses smbclient on the remote host to interact with the share without requiring a mount.
|
|
/// </summary>
|
|
Task<bool> EnsureSmbFoldersAsync(
|
|
string cifsServer,
|
|
string cifsShareName,
|
|
string cifsUsername,
|
|
string cifsPassword,
|
|
IEnumerable<string> folderNames,
|
|
string? cifsShareFolder = null);
|
|
|
|
/// <summary>
|
|
/// Removes all Docker volumes whose names start with <paramref name="stackName"/>_.
|
|
/// Volumes currently in use by running containers will be skipped.
|
|
/// Safe for CIFS volumes since data lives on the remote share, not in the local volume.
|
|
/// </summary>
|
|
Task<bool> RemoveStackVolumesAsync(string stackName);
|
|
}
|
|
|
|
public class StackInfo
|
|
{
|
|
public string Name { get; set; } = string.Empty;
|
|
public int ServiceCount { get; set; }
|
|
}
|
|
|
|
public class ServiceInfo
|
|
{
|
|
public string Name { get; set; } = string.Empty;
|
|
public string Image { get; set; } = string.Empty;
|
|
public string Replicas { get; set; } = string.Empty;
|
|
}
|