Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/ModularPipelines/Context/IPipelineEncoding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using ModularPipelines.Helpers;

namespace ModularPipelines.Context;

/// <summary>
/// Provides access to serialization and encoding helpers.
/// </summary>
/// <remarks>
/// This interface groups JSON, XML, YAML serialization and encoding helpers (Hex, Base64, Hasher)
/// for better Interface Segregation.
/// </remarks>
public interface IPipelineEncoding
{
/// <summary>
/// Gets helpers for converting JSON.
/// </summary>
IJson Json { get; }

/// <summary>
/// Gets helpers for convering XML.
/// </summary>
IXml Xml { get; }

/// <summary>
/// Gets helpers for convering YAML.
/// </summary>
IYaml Yaml { get; }

/// <summary>
/// Gets helpers for converting to and from hex strings.
/// </summary>
IHex Hex { get; }

/// <summary>
/// Gets helpers for converting to and from Base64 strings.
/// </summary>
IBase64 Base64 { get; }

/// <summary>
/// Gets helpers for hashing data.
/// </summary>
/// <remarks>
/// Supports MD5, SHA1, SHA256, SHA512 hashing algorithms.
/// </remarks>
IHasher Hasher { get; }
}
30 changes: 30 additions & 0 deletions src/ModularPipelines/Context/IPipelineEnvironment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using ModularPipelines.Engine;
using ModularPipelines.Helpers;

namespace ModularPipelines.Context;

/// <summary>
/// Provides access to environment and build system detection.
/// </summary>
/// <remarks>
/// This interface groups environment context and build system detection helpers
/// for better Interface Segregation.
/// </remarks>
public interface IPipelineEnvironment
{
/// <summary>
/// Gets helpers for getting information about the current environment.
/// </summary>
/// <remarks>
/// Provides access to OS info, environment variables, working directory, etc.
/// </remarks>
IEnvironmentContext Environment { get; }

/// <summary>
/// Gets helpers for detecting the current build system.
/// </summary>
/// <remarks>
/// Detects GitHub Actions, Azure DevOps, Jenkins, GitLab CI, etc.
/// </remarks>
IBuildSystemDetector BuildSystemDetector { get; }
}
31 changes: 31 additions & 0 deletions src/ModularPipelines/Context/IPipelineFileSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using ModularPipelines.Helpers;

namespace ModularPipelines.Context;

/// <summary>
/// Provides access to file system operations.
/// </summary>
/// <remarks>
/// This interface groups file system, zip, and checksum helpers
/// for better Interface Segregation.
/// </remarks>
public interface IPipelineFileSystem
{
/// <summary>
/// Gets helpers for interacting with the filesystem.
/// </summary>
/// <remarks>
/// Provides file/directory operations with logging and error handling.
/// </remarks>
IFileSystemContext FileSystem { get; }

/// <summary>
/// Gets helpers for zipping and unzipping files and directories.
/// </summary>
IZip Zip { get; }

/// <summary>
/// Gets helpers for checking the Checksum of a file.
/// </summary>
IChecksum Checksum { get; }
}
204 changes: 12 additions & 192 deletions src/ModularPipelines/Context/IPipelineHookContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,199 +23,19 @@ namespace ModularPipelines.Context;
/// Extension Pattern:
/// Tool integrations (ModularPipelines.Git, ModularPipelines.Docker, etc.) add extension methods
/// like context.Git() and context.Docker() that provide strongly-typed APIs for those tools.
///
/// Interface Segregation:
/// This interface inherits from focused sub-interfaces (IPipelineServices, IPipelineLogging, etc.)
/// allowing consumers to depend on only the subset of functionality they need.
/// </remarks>
public interface IPipelineHookContext
public interface IPipelineHookContext :
IPipelineServices,
IPipelineLogging,
IPipelineTools,
IPipelineEncoding,
IPipelineFileSystem,
IPipelineEnvironment
{
#region DependencyInjection

/// <summary>
/// Gets the service provider orchestrating DI within the pipeline.
/// </summary>
/// <remarks>
/// Use the generic Get&lt;T&gt;() method instead of accessing ServiceProvider directly
/// when possible for better type safety.
/// </remarks>
public IServiceProvider ServiceProvider { get; }

/// <summary>
/// Helper method for retrieving services from the Service Provider.
/// </summary>
/// <typeparam name="T">Type to retrieve.</typeparam>
/// <returns>The service instance, or null if not registered.</returns>
public T? Get<T>();

#endregion

#region Configuration

/// <summary>
/// Gets the configuration powering the pipeline.
/// </summary>
/// <remarks>
/// Configuration is loaded from appsettings.json, environment variables, user secrets, and command line.
/// </remarks>
public IConfiguration Configuration { get; }

/// <summary>
/// Gets the pipeline's options.
/// </summary>
public IOptions<PipelineOptions> PipelineOptions { get; }

#endregion

#region Logging

/// <summary>
/// Gets the logger to be used from the pipeline.
/// </summary>
/// <remarks>
/// This logger is module-scoped and will include the module name in log output.
/// </remarks>
public IModuleLogger Logger { get; }

#endregion

#region EnvironmentHelpers

/// <summary>
/// Gets helpers for getting information about the current environment.
/// </summary>
/// <remarks>
/// Provides access to OS info, environment variables, working directory, etc.
/// </remarks>
public IEnvironmentContext Environment { get; }

/// <summary>
/// Gets helpers for detecting the current build system.
/// </summary>
/// <remarks>
/// Detects GitHub Actions, Azure DevOps, Jenkins, GitLab CI, etc.
/// </remarks>
public IBuildSystemDetector BuildSystemDetector { get; }

#endregion

#region FileSystemHelpers

/// <summary>
/// Gets helpers for interacting with the filesystem.
/// </summary>
/// <remarks>
/// Provides file/directory operations with logging and error handling.
/// </remarks>
public IFileSystemContext FileSystem { get; }

/// <summary>
/// Gets helpers for zipping and unzipping files and directories.
/// </summary>
public IZip Zip { get; }

/// <summary>
/// Gets helpers for checking the Checksum of a file.
/// </summary>
IChecksum Checksum { get; }

#endregion

#region CommandExecution

/// <summary>
/// Gets helpers for running commands.
/// </summary>
/// <remarks>
/// Provides cross-platform command execution with output capture and logging.
/// </remarks>
public ICommand Command { get; }

/// <summary>
/// Gets helpers for running powershell.
/// </summary>
public IPowershell Powershell { get; }

/// <summary>
/// Gets helpers for executing bash commands.
/// </summary>
public IBash Bash { get; }

#endregion

#region Serialization

/// <summary>
/// Gets helpers for converting JSON.
/// </summary>
public IJson Json { get; }

/// <summary>
/// Gets helpers for convering XML.
/// </summary>
public IXml Xml { get; }

/// <summary>
/// Gets helpers for convering YAML.
/// </summary>
public IYaml Yaml { get; }

#endregion

#region Encoding

/// <summary>
/// Gets helpers for converting to and from hex strings.
/// </summary>
public IHex Hex { get; }

/// <summary>
/// Gets helpers for converting to and from Base64 strings.
/// </summary>
public IBase64 Base64 { get; }

#endregion

#region Security

/// <summary>
/// Gets helpers for hashing data.
/// </summary>
/// <remarks>
/// Supports MD5, SHA1, SHA256, SHA512 hashing algorithms.
/// </remarks>
public IHasher Hasher { get; }

#endregion

#region NetworkHelpers

/// <summary>
/// Gets helpers for sending HTTP requests.
/// </summary>
/// <remarks>
/// Provides a configured HttpClient with retry policies and logging.
/// </remarks>
public IHttp Http { get; }

/// <summary>
/// Gets helpers for downloading data from the web.
/// </summary>
/// <remarks>
/// Includes progress tracking and verification helpers.
/// </remarks>
public IDownloader Downloader { get; }

#endregion

#region Installation

/// <summary>
/// Gets helpers for installing applications.
/// </summary>
/// <remarks>
/// Supports package managers like Chocolatey, apt, brew, etc.
/// </remarks>
public IInstaller Installer { get; }

#endregion

#region Internal

/// <summary>
Expand All @@ -240,4 +60,4 @@ public interface IPipelineHookContext
internal EngineCancellationToken EngineCancellationToken { get; }

#endregion
}
}
20 changes: 20 additions & 0 deletions src/ModularPipelines/Context/IPipelineLogging.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using ModularPipelines.Logging;

namespace ModularPipelines.Context;

/// <summary>
/// Provides access to logging functionality.
/// </summary>
/// <remarks>
/// This interface groups logging-related members for better Interface Segregation.
/// </remarks>
public interface IPipelineLogging
{
/// <summary>
/// Gets the logger to be used from the pipeline.
/// </summary>
/// <remarks>
/// This logger is module-scoped and will include the module name in log output.
/// </remarks>
IModuleLogger Logger { get; }
}
43 changes: 43 additions & 0 deletions src/ModularPipelines/Context/IPipelineServices.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using ModularPipelines.Options;

namespace ModularPipelines.Context;

/// <summary>
/// Provides access to dependency injection and configuration services.
/// </summary>
/// <remarks>
/// This interface groups DI and configuration-related members for better Interface Segregation.
/// </remarks>
public interface IPipelineServices
{
/// <summary>
/// Gets the service provider orchestrating DI within the pipeline.
/// </summary>
/// <remarks>
/// Use the generic Get&lt;T&gt;() method instead of accessing ServiceProvider directly
/// when possible for better type safety.
/// </remarks>
IServiceProvider ServiceProvider { get; }

/// <summary>
/// Helper method for retrieving services from the Service Provider.
/// </summary>
/// <typeparam name="T">Type to retrieve.</typeparam>
/// <returns>The service instance, or null if not registered.</returns>
T? Get<T>();

/// <summary>
/// Gets the configuration powering the pipeline.
/// </summary>
/// <remarks>
/// Configuration is loaded from appsettings.json, environment variables, user secrets, and command line.
/// </remarks>
IConfiguration Configuration { get; }

/// <summary>
/// Gets the pipeline's options.
/// </summary>
IOptions<PipelineOptions> PipelineOptions { get; }
}
Loading
Loading