Repository navigation
feat: update API - #2678
feat: update API#2678bouskaJ wants to merge 1 commit into
Conversation
PR Summary by QodoMulti-entry TUF trust root bindings with TargetName and validity
AI Description
Merge Risk
|
Code Review by Qodo 1. Additional trust bindings disappear
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2678 +/- ##
==========================================
- Coverage 59.54% 59.46% -0.09%
==========================================
Files 302 302
Lines 17543 17715 +172
==========================================
+ Hits 10446 10534 +88
- Misses 6338 6417 +79
- Partials 759 764 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d227e57 to
c533cb8
Compare
c533cb8 to
777b2eb
Compare
777b2eb to
9dc7084
Compare
fghanmi
left a comment
There was a problem hiding this comment.
I tested on a live deployment: the sample deploys to Ready, the TUF repo serves all targets, and cosign initialize works, so the happy path is fine.
I added comments for few concerns.
| func ActiveKeys(instance *rhtasv1.Tuf) []ComponentKey { | ||
| keys := []ComponentKey{Rekor, CTFE, Fulcio} | ||
| if instance.Spec.Tsa != nil { | ||
| keys := make([]ComponentKey, 0, 4) |
There was a problem hiding this comment.
The PR description says the follow-up will use status.keys to migrate existing standalone Tufs. This change deletes that data first.
ActiveKeys now returns no keys when the spec has no bindings. ResolveKeys (not changed here) then replaces status.keys with an empty list. I tested this on a live instance: a Tuf had 4 secret references in status.keys. After the binding lists were removed, it had none and stayed Ready.
Could we leave status.keys as it is until the migration reads it, for example by not writing when no binding resolves?
| if err := serviceReferenceToAddressPort(&in.Rekor[0].ServiceReference, &out.Rekor.Address, &out.Rekor.Port); err != nil { | ||
| // v1alpha1 has a single slot per component. Populate it only from the | ||
| // legacy-named binding; differently named keys stay annotation-only. | ||
| if i := slices.IndexFunc(in.Rekor, func(b rhtasv1.TrustRootBinding) bool { return b.TargetName == rhtasv1.TufKeyRekor }); i >= 0 { |
There was a problem hiding this comment.
v1alpha1 only shows a binding when its name is exactly rekor.pub, ctfe.pub and so on. Defaulted bindings are named like rekor-<ref>.pub, so a normal v1 object shows no keys.
The v1alpha1 CRD adds four keys when none are given. After a full update through v1alpha1, converting back creates a TSA binding. I tested this on a Tuf with no TSA. It got a tsa.certchain.pem binding with no source, and stays Pending with a "no TimestampAuthority" error.
Could conversion remember which bindings existed, including when none are visible in v1alpha1?
| name := r.GetName() | ||
| if spoke, ok := spokeByName[name]; ok { | ||
| out = append(out, restore(spoke, r)) | ||
| } else if name != legacyName { |
There was a problem hiding this comment.
The loop only goes through the saved list. If a v1alpha1 client adds a new legacy entry such as rekor.pub with its own secret, nothing visits it and it is silently dropped. I reproduced this live.
Could we merge entries that are new in the v1alpha1 object, and keep edits to visible fields?
Summary
Prepare the TUF API for declarative trust-root management. Bindings can specify a target name and validity window, and the API can represent multiple bindings per component and a snapshot of the published trust root.
TUF now skips components whose binding lists are empty. This disables implicit autoloading for omitted bindings. Namespace-wide discovery can select trust material from an unintended component, so the desired trust root should identify its sources explicitly. SecureSign supplies sibling refs for the components it manages.
Compatibility
Potentially breaking for standalone TUF resources that rely on autoloading. New standalone resources should declare each desired binding using a component ref or a secretRef with an explicit service URL. Existing standalone resources that previously resolved their keys have Secret references recorded in status.keys. A follow-up PR will use those references to migrate them to explicit bindings.
Legacy bindings without a secretRef relied on autoloading for trust material. When conversion assigns a sibling ref to such a binding on a SecureSign-managed TUF, it clears the legacy URL. TUF then reads the endpoint and trust material from the referenced component.
Changing bindings on an already initialized repository did not reliably update the published trust root. This PR introduces the API for declarative updates as new functionality.