You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: improve deployment-guard error messages and repository validation (#12)
## Summary
Improves error messages in deployment-guard workflow for better
traceability and fixes repository validation bug when using registry
prefixes.
## Changes
### 1. Error Message Improvements (Related to
dotCMS/deutschebank-infrastructure#339)
All validation error messages now include:
- Clear "REASON:" prefix explaining why validation failed
- Explicit statement of validation rules
- Removed "how to fix" suggestions (just state the rules)
**Before:**
```
❌ BLOCKED: Modified files are not in the allowlist
Please ensure you're only modifying allowed files.
```
**After:**
```
❌ BLOCKED: File allowlist validation failed
REASON: One or more modified files are not in the allowlist
Validation Rule: Only files matching the following pattern can be modified:
- Pattern: kubernetes/dotcms/**/statefulset.ya?ml
```
### 2. Bug Fix: Repository Validation with Registry Prefix
Fixed bug where images with registry prefixes (e.g.,
`mirror.gcr.io/dotcms/dotcms:25.12.11`) would fail repository validation
even when the base repository (`dotcms/dotcms`) is in the allowlist.
**The Problem:**
```yaml
# Actual image in statefulset
image: mirror.gcr.io/dotcms/dotcms:25.12.11
# Allowed repositories in caller workflow
allowed_image_repositories: 'dotcms/dotcms'
# Previous behavior: ❌ FAIL - exact match required
# mirror.gcr.io/dotcms/dotcms != dotcms/dotcms
```
**The Solution:**
- Extract base repository name from full image path
- Compare both full repository AND base repository with allowlist
- Handles: `mirror.gcr.io/dotcms/dotcms`,
`gcr.io/project/dotcms/dotcms`, `dotcms/dotcms`
- All resolve to base: `dotcms/dotcms` for comparison
**Added Debug Logging:**
```
Full image: mirror.gcr.io/dotcms/dotcms:25.12.11
Repository: mirror.gcr.io/dotcms/dotcms
Tag: 25.12.11
Comparing 'dotcms/dotcms' with allowed 'dotcms/dotcms'
✓ Match found
```
### 3. Improved All Validation Errors
- **File Allowlist**: Clear reason and pattern display
- **Image-Only Changes**: Explicit list of allowed vs not-allowed
changes
- **Image Format**: Shows expected format when invalid
- **Repository**: Shows reason for failure and allowed list
- **Version Pattern**: Explains evergreen requirements and shows pattern
- **Registry Existence**: Clear reason when image not found
- **Final Summary**: Lists all validation rules including downgrade
prevention
## Testing
Tested with Deutsche Bank infrastructure during Phase 1 testing:
- ✅ Test 1.1: PUBLIC member bypass works
- ✅ Test 1.2: File allowlist blocks correctly
- ✅ Test 1.3: Image-only check detects multiple changes
- ✅ Test 1.4: LTS version rejected
- ✅ Test 1.5: Latest tag rejected
- Identified repository validation bug with `mirror.gcr.io` prefix →
Fixed
## Benefits
1. **Traceability**: All errors clearly state WHY validation failed
2. **Compliance**: Error messages suitable for audit purposes
3. **User Experience**: Users understand validation rules without
needing documentation
4. **Registry Flexibility**: Supports images from mirror registries
without configuration changes
## Breaking Changes
None - this is backward compatible. Existing workflows will continue to
work and benefit from improved error messages.
## Related Issues
- dotCMS/deutschebank-infrastructure#339 - Deployment guard
implementation and testing
0 commit comments