// // Copyright (c) StellaOps. Licensed under the BUSL-1.1. // namespace StellaOps.Tools.WorkflowGenerator; /// /// Options for workflow generation. /// Sprint: SPRINT_20260109_010_003 Task: Create models /// public sealed record WorkflowOptions { /// /// Target CI/CD platform. /// public required CiPlatform Platform { get; init; } /// /// Workflow name. /// public string Name { get; init; } = "StellaOps Security Scan"; /// /// Trigger configuration. /// public TriggerConfig Triggers { get; init; } = TriggerConfig.Default; /// /// Scan configuration. /// public ScanConfig Scan { get; init; } = ScanConfig.DefaultRepository; /// /// Upload configuration. /// public UploadConfig Upload { get; init; } = UploadConfig.Default; /// /// Runner/image to use. /// public string? Runner { get; init; } /// /// Environment variables. /// public IDictionary EnvironmentVariables { get; init; } = new Dictionary(); /// /// Include comments in generated YAML. /// public bool IncludeComments { get; init; } = true; /// /// Creates default options for GitHub Actions. /// public static WorkflowOptions GitHubActionsDefault => new() { Platform = CiPlatform.GitHubActions, Runner = "ubuntu-latest" }; /// /// Creates default options for GitLab CI. /// public static WorkflowOptions GitLabCiDefault => new() { Platform = CiPlatform.GitLabCi }; /// /// Creates default options for Azure DevOps. /// public static WorkflowOptions AzureDevOpsDefault => new() { Platform = CiPlatform.AzureDevOps, Runner = "ubuntu-latest" }; /// /// Validates the options. /// public ValidationResult Validate() { var errors = new List(); if (string.IsNullOrWhiteSpace(Name)) errors.Add("Workflow name is required"); if (Scan.ImageRef is null && Scan.ScanPath is null) errors.Add("Either ImageRef or ScanPath must be specified"); if (Scan.ImageRef is not null && Scan.ScanPath is not null) errors.Add("Only one of ImageRef or ScanPath should be specified"); return new ValidationResult(errors.Count == 0, errors); } } /// /// Validation result. /// public sealed record ValidationResult(bool IsValid, IReadOnlyList Errors) { public static ValidationResult Success => new(true, []); public static ValidationResult Failure(params string[] errors) => new(false, errors); }