Skip to content

feat: add per-target validation hints to aib-target-defaults ConfigMap#302

Merged
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:aib-validation
Jun 11, 2026
Merged

feat: add per-target validation hints to aib-target-defaults ConfigMap#302
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:aib-validation

Conversation

@bennyz

@bennyz bennyz commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Each target now declares acceptedFormats and acceptedArchitectures, enabling server-side validation of ConfigMap entries at parse time and CLI warnings for user-supplied values before build submission.

Summary

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • CI/CD improvement
  • Refactoring

Testing

  • Unit tests pass (make test)
  • Linter passes (make lint)
  • Manifests are up to date (make manifests generate)
  • Tested on OpenShift cluster (if applicable)

Summary by CodeRabbit

Release Notes

  • New Features

    • Build targets now support accepted formats and architectures configuration constraints, enabling operators to define valid options.
    • Added validation warnings that alert users when selected architecture or export format do not match operator-approved values.
  • Tests

    • Added comprehensive test coverage for target default validation scenarios.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@bennyz, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 20 minutes and 18 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8e7e41e7-d704-4902-8971-81cd6ab08786

📥 Commits

Reviewing files that changed from the base of the PR and between c647897 and f39a67f.

📒 Files selected for processing (8)
  • cmd/caib/buildcmd/build.go
  • cmd/caib/clilog/clilog.go
  • internal/buildapi/build_validation.go
  • internal/buildapi/build_validation_test.go
  • internal/buildapi/server.go
  • internal/buildapi/server_test.go
  • internal/buildapi/types.go
  • internal/controller/operatorconfig/controller.go
📝 Walkthrough

Walkthrough

This PR extends the operator's target default configuration system with validation hints. TargetDefaults now includes accepted format and architecture lists; the server validates these during YAML parsing, and the CLI emits warnings when user selections fall outside those lists.

Changes

Target defaults validation hints

Layer / File(s) Summary
TargetDefaults schema extension
internal/buildapi/types.go
TargetDefaults struct adds AcceptedFormats and AcceptedArchitectures slice fields to carry operator-provided validation constraints.
Build target defaults validation logic
internal/buildapi/build_validation.go, internal/buildapi/build_validation_test.go
New validateTargetDefaults function checks each target's architecture and default format against their accepted lists and aggregates violations; comprehensive tests cover nil inputs, missing constraints, matching defaults, and multi-target error reporting.
Server-side YAML parsing and validation
internal/buildapi/server.go, internal/buildapi/server_test.go
loadTargetDefaultsFn now parses acceptedFormats and acceptedArchitectures from YAML into TargetDefaults entries and validates via validateTargetDefaults; integration test verifies the new fields are included in the /v1/config HTTP response.
CLI-side membership warnings
cmd/caib/buildcmd/build.go
ApplyTargetDefaults calls new warnIfNotInList helper to emit stderr warnings when the selected architecture or export format is not present in the operator's accepted lists.
Operator configuration defaults
internal/controller/operatorconfig/controller.go
Embedded targetDefaultsYAML is updated to include acceptedFormats and acceptedArchitectures for targets (qemu, ridesx4 variants, ebbr, rcar_s4, j784s4evm, s32g_vnp_rdb3).

Sequence Diagram

sequenceDiagram
  participant Server as Build API Server
  participant Validation as validateTargetDefaults
  participant CLI as CLI (caib build)
  participant Warning as warnIfNotInList
  
  Server->>Server: Parse target-defaults.yaml
  Server->>Validation: Validate loaded TargetDefaults
  Validation->>Validation: Check Architecture in AcceptedArchitectures
  Validation->>Validation: Check DefaultFormat in AcceptedFormats
  Validation-->>Server: Return validation result
  
  CLI->>CLI: Fetch operator config via /v1/config
  CLI->>CLI: Apply TargetDefaults to request
  CLI->>Warning: Check selected Architecture
  Warning-->>CLI: Warn if not in AcceptedArchitectures
  CLI->>Warning: Check selected ExportFormat
  Warning-->>CLI: Warn if not in AcceptedFormats
  CLI->>CLI: Proceed with build
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • bkhizgiy

Poem

🐰 Hop, skip, and validate we go,
Defaults now with hints in tow,
Formats blessed, architectures blessed,
Warnings whisper what is best! 🎯✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding per-target validation hints (acceptedFormats and acceptedArchitectures) to the aib-target-defaults ConfigMap, which is reflected across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/buildapi/build_validation_test.go (1)

198-293: 💤 Low value

Note: Tests and implementation added together.

As per coding guidelines, tests should be added before starting implementation. Both the validateTargetDefaults implementation and its tests appear together in this PR. While the test coverage is excellent, consider following a test-first approach in future changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/buildapi/build_validation_test.go` around lines 198 - 293, The PR
added both the validateTargetDefaults implementation and its tests together; per
our guideline, split them so tests land before implementation. Create one change
that adds the test cases (all Describe/It blocks referencing
validateTargetDefaults) without adding or modifying the implementation, then
follow with a second change that implements validateTargetDefaults (or modifies
it) to satisfy those tests; ensure the tests reference the same function name
validateTargetDefaults so CI runs the failing tests first and reviewers can
verify behavior before implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/buildapi/build_validation_test.go`:
- Around line 198-293: The PR added both the validateTargetDefaults
implementation and its tests together; per our guideline, split them so tests
land before implementation. Create one change that adds the test cases (all
Describe/It blocks referencing validateTargetDefaults) without adding or
modifying the implementation, then follow with a second change that implements
validateTargetDefaults (or modifies it) to satisfy those tests; ensure the tests
reference the same function name validateTargetDefaults so CI runs the failing
tests first and reviewers can verify behavior before implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34fdc2cd-ab78-4102-8605-a44557d97e19

📥 Commits

Reviewing files that changed from the base of the PR and between edd437e and c647897.

📒 Files selected for processing (7)
  • cmd/caib/buildcmd/build.go
  • internal/buildapi/build_validation.go
  • internal/buildapi/build_validation_test.go
  • internal/buildapi/server.go
  • internal/buildapi/server_test.go
  • internal/buildapi/types.go
  • internal/controller/operatorconfig/controller.go

@bennyz bennyz requested a review from maboras-rh June 3, 2026 14:58

@maboras-rh maboras-rh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. other than the two small comments

Comment thread internal/buildapi/build_validation.go Outdated
checkInList(&errs, name, "defaultFormat", td.DefaultFormat, "acceptedFormats", td.AcceptedFormats)
}
if len(errs) > 0 {
return fmt.Errorf("%s", strings.Join(errs, "; "))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("%s", strings.Join(errs, "; "))
return errors.New(strings.Join(errs, "; "))

Comment thread cmd/caib/buildcmd/build.go Outdated
return
}
if !slices.Contains(accepted, value) {
fmt.Fprintf(os.Stderr, "Warning: %s %q is not in accepted values %v\n", field, value, accepted)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warnIfNotInList writes directly to os.Stderr and the rest of build.go uses clilog.Infof(...) for output. i think that warnings should go through the same logging abstraction for consistency. If clilog doesn't have a Warnf, add one or use clilog.Infof("Warning: ...")
WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added warn

@bennyz bennyz force-pushed the aib-validation branch 2 times, most recently from 1deeaef to 28bd015 Compare June 11, 2026 14:18
Each target now declares acceptedFormats and acceptedArchitectures,
enabling server-side validation of ConfigMap entries at parse time
and CLI warnings for user-supplied values before build submission.

Assisted-by: claude-opus-4.6
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
@bennyz bennyz merged commit e07f620 into centos-automotive-suite:main Jun 11, 2026
4 checks passed
@bennyz bennyz deleted the aib-validation branch June 11, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants