validateVersion validates the version string. NB: we decided that we would not enforce strict semver for version strings
(ctx *ValidationContext, version string)
| 333 | // validateVersion validates the version string. |
| 334 | // NB: we decided that we would not enforce strict semver for version strings |
| 335 | func validateVersion(ctx *ValidationContext, version string) *ValidationResult { |
| 336 | result := &ValidationResult{Valid: true, Issues: []ValidationIssue{}} |
| 337 | |
| 338 | if version == "latest" { |
| 339 | issue := NewValidationIssueFromError( |
| 340 | ValidationIssueTypeSemantic, |
| 341 | ctx.String(), |
| 342 | ErrReservedVersionString, |
| 343 | "reserved-version-string", |
| 344 | ) |
| 345 | result.AddIssue(issue) |
| 346 | return result |
| 347 | } |
| 348 | |
| 349 | // Reject semver range-like inputs |
| 350 | if looksLikeVersionRange(version) { |
| 351 | issue := NewValidationIssueFromError( |
| 352 | ValidationIssueTypeSemantic, |
| 353 | ctx.String(), |
| 354 | fmt.Errorf("%w: %q", ErrVersionLooksLikeRange, version), |
| 355 | "version-looks-like-range", |
| 356 | ) |
| 357 | result.AddIssue(issue) |
| 358 | } |
| 359 | |
| 360 | return result |
| 361 | } |
| 362 | |
| 363 | // looksLikeVersionRange detects common semver range syntaxes and wildcard patterns. |
| 364 | // that indicate the value is not a single, specific version. |
no test coverage detected
searching dependent graphs…