package errors // ErrorCode — тип для кода ошибки. type ErrorCode string const ( // General Errors ErrEmptyFile ErrorCode = "FileIsEmpty" // The file is empty or missing ErrYamlSyntax ErrorCode = "YAMLSyntaxError" // YAML syntax error // Job-related Errors ErrJobNameBlank ErrorCode = "JobNameBlank" // The job name is blank ErrJobNameTooLong ErrorCode = "JobNameTooLong" // The job name exceeds the maximum length ErrMissingScript ErrorCode = "MissingScript" // The required field script (or run) is missing ErrBothScriptAndRun ErrorCode = "BothScriptAndRun" // Both script and run are specified simultaneously ErrJobStageNotExist ErrorCode = "JobStageNotExist" // The specified stage does not exist in the allowed list ErrUndefinedDependency ErrorCode = "UndefinedDependency" // A dependency is not defined among the jobs ErrInvalidStageOrder ErrorCode = "InvalidStageOrder" // A dependency has a stage that occurs later than the job's stage ErrDuplicateNeeds ErrorCode = "DuplicateNeeds" // Duplicate entries found in needs ErrUndefinedNeed ErrorCode = "UndefinedNeed" // A need refers to a non-existent job ErrNeedNameTooLong ErrorCode = "NeedNameTooLong" // The need name exceeds the allowed length ErrNoVisibleJob ErrorCode = "NoVisibleJob" // There are no visible jobs ErrMissingJobs ErrorCode = "MissingJobs" // No jobs defined ErrArtifactsPathsBlank ErrorCode = "ArtifactsPathsBlank" // The artifacts paths block is missing or empty ErrUnknownRootKey ErrorCode = "UnknownRootKey" // An unknown key was found at the root level ErrInvalidWhen ErrorCode = "InvalidWhen" // The value of 'when' is invalid ErrInvalidOnly ErrorCode = "InvalidOnly" // The value of 'only' is invalid ErrUnknownKey ErrorCode = "UnknownKey" // An unknown key was found ErrMissingStage ErrorCode = "MissingStage" // The stage is missing ErrInvalidChanges ErrorCode = "InvalidChanges" // The changes configuration is invalid ErrInvalidRulesFormat ErrorCode = "InvalidRulesFormat" // The rules format is invalid // Changes-related Errors ErrChangesNotArrayOfStrings ErrorCode = "ChangesNotArrayOfStrings" // Changes config should be an array of strings ErrChangesInvalidType ErrorCode = "ChangesInvalidType" // Changes config is of an invalid type ErrChangesTooManyEntries ErrorCode = "ChangesTooManyEntries" // Changes config has too many entries (maximum 50) ErrChangesMissingPaths ErrorCode = "ChangesMissingPaths" // The changes config hash must contain the key 'paths' // Paths-related Errors ErrPathsNotArrayOfStrings ErrorCode = "PathsNotArrayOfStrings" // Paths config should be an array of strings // Job Delayed Parameters ErrStartInMissing ErrorCode = "StartInMissing" // For delayed jobs, start_in is missing ErrStartInInvalid ErrorCode = "StartInInvalid" // start_in is not a valid duration ErrStartInTooLong ErrorCode = "StartInTooLong" // start_in exceeds the allowed limit ErrStartInMustBeBlank ErrorCode = "StartInMustBeBlank" // For non-delayed jobs, start_in must be blank // Dependencies / Needs Consistency ErrDependencyNotInNeeds ErrorCode = "DependencyNotInNeeds" // A dependency is not included in needs // Rules Validation ErrRulesOnlyExcept ErrorCode = "RulesOnlyExcept" // Only and except cannot be used with rules ErrRulesOnly ErrorCode = "RulesOnly" // Only cannot be used with rules ErrRulesExcept ErrorCode = "RulesExcept" // Except cannot be used with rules ErrInvalidExpressionSyntax ErrorCode = "InvalidExpressionSyntax" // The expression syntax is invalid ErrUnknownRulesKey ErrorCode = "UnknownRulesKey" // An unknown key was found in rules // Other Job-related Errors ErrBeforeScriptInvalid ErrorCode = "BeforeScriptInvalid" // The before_script configuration is invalid ErrServiceInvalid ErrorCode = "ServiceInvalid" // The service configuration is invalid ErrStageInvalid ErrorCode = "StageInvalid" // The stage configuration is invalid ErrVariableInvalid ErrorCode = "VariableInvalid" // The variable is invalid ErrVariableNameTooLong ErrorCode = "VariableNameTooLong" // The variable name exceeds the maximum length ErrInvalidStagesOrder ErrorCode = "InvalidStagesOrder" // The stage order is invalid ErrVariablesInvalid ErrorCode = "VariablesInvalid" // The variables configuration is invalid ErrVariablesInvalidKey ErrorCode = "VariablesInvalidKey" // The variable uses invalid keys // Additional Errors ErrCyclicDependency ErrorCode = "CyclicDependency" // A cyclic dependency was detected ErrBooleanValue ErrorCode = "BooleanValue" // The value must be boolean ErrIncludeRulesInvalid ErrorCode = "IncludeRulesInvalid" // The 'exists' or 'changes' value is not a string or an array of strings // Style Note (Informational/Note) ErrMissingFinalNewline ErrorCode = "MissingFinalNewline" // The file is missing a final empty newline ) // ErrorSeverity maps each error code to a severity level. var ErrorSeverity = map[ErrorCode]SeverityLevel{ // Critical errors ErrEmptyFile: Critical, ErrYamlSyntax: Critical, ErrMissingJobs: Critical, ErrJobNameBlank: Critical, ErrMissingScript: Critical, ErrBothScriptAndRun: Critical, ErrMissingStage: Critical, ErrJobStageNotExist: Critical, ErrUndefinedDependency: Critical, ErrInvalidStageOrder: Critical, ErrUndefinedNeed: Critical, ErrCyclicDependency: Critical, ErrStartInMissing: Critical, ErrStartInInvalid: Critical, ErrStartInTooLong: Critical, ErrStartInMustBeBlank: Critical, ErrVariableInvalid: Critical, ErrVariablesInvalid: Critical, ErrVariablesInvalidKey: Critical, ErrServiceInvalid: Critical, ErrBeforeScriptInvalid: Critical, ErrChangesNotArrayOfStrings: Critical, ErrChangesInvalidType: Critical, ErrChangesTooManyEntries: Critical, ErrChangesMissingPaths: Critical, ErrPathsNotArrayOfStrings: Critical, // Warnings ErrDuplicateNeeds: Warning, ErrNoVisibleJob: Warning, ErrUnknownRootKey: Warning, ErrUnknownKey: Warning, ErrInvalidWhen: Warning, ErrInvalidOnly: Warning, ErrInvalidRulesFormat: Warning, ErrRulesOnlyExcept: Warning, ErrRulesOnly: Warning, ErrRulesExcept: Warning, ErrInvalidExpressionSyntax: Warning, ErrUnknownRulesKey: Warning, // Notes (if needed, add informational codes here) ErrJobNameTooLong: Note, ErrVariableNameTooLong: Note, ErrNeedNameTooLong: Note, ErrMissingFinalNewline: Note, }