Add support for per-project vulnerability scanner configuration#593
Merged
flbla merged 1 commit intoApr 22, 2026
Merged
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 17 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes. Give us feedback
500000e to
0b75268
Compare
Add optional `vulnerability_scanner` attribute to `harbor_project` resource,
allowing users to override the global default scanner on a per-project basis
via the Harbor v2.0 project-level scanner API endpoints.
- Add ProjectScannerBody model for PUT /projects/{id}/scanner
- Add GetScannerByName, SetProjectScanner, GetProjectScanner client functions
- Refactor SetDefaultScanner to reuse GetScannerByName (removes duplication)
- Wire scanner assignment into project Create, Read, and Update handlers
- Expose vulnerability_scanner as computed attribute in data source
- Update resource and data source documentation
https://claude.ai/code/session_012e5CjBngXGn8vJFJewmFWJ
Signed-off-by: Tristan Rivoallan <tristan@rivoallan.net>
0b75268 to
0312771
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for configuring vulnerability scanners on a per-project basis in the Harbor Terraform provider, allowing users to override the global default scanner for individual projects.
Key Changes
New Client Methods: Added three new methods to
client/project.go:GetScannerByName(): Retrieves a scanner by name from the list of available scannersSetProjectScanner(): Assigns a vulnerability scanner to a specific projectGetProjectScanner(): Retrieves the assigned scanner name for a projectRefactored Scanner Logic: Extracted common scanner lookup logic from
client/system.gointo the reusableGetScannerByName()method, simplifyingSetDefaultScanner()and reducing code duplicationResource Schema Updates:
vulnerability_scanneroptional field to theharbor_projectresourcevulnerability_scannercomputed field to theharbor_projectdata sourceResource Lifecycle Management:
resourceProjectCreate()resourceProjectUpdate()resourceProjectRead()and data source read operationsModel Addition: Added
ProjectScannerBodystruct tomodels/projects.gofor API request payloadsDocumentation: Updated resource and data source documentation to describe the new
vulnerability_scannerfieldImplementation Details
strings.EqualFold) for robustness