feat(api): add optional Name field to RepoSubscription#6207
feat(api): add optional Name field to RepoSubscription#6207mail2sudheerobbu-oss wants to merge 12 commits into
Conversation
❌ Deploy Preview for docs-kargo-io failed. Why did it fail? →
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6207 +/- ##
==========================================
+ Coverage 57.96% 58.02% +0.05%
==========================================
Files 496 496
Lines 41602 41639 +37
==========================================
+ Hits 24115 24160 +45
+ Misses 16033 16027 -6
+ Partials 1454 1452 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi team — gentle ping on this PR. It adds an optional |
|
I was just looking for this feature! Would love to see it added. |
|
Thanks @whitelancer — glad to hear there's demand for this! Hopefully the maintainers can take a look soon. |
|
@mail2sudheerobbu-oss I remain supportive of the intent, but the implementation looks incomplete to me.
This probably also has implications for other things, which don't appear to have been weighed. For instance, can the limitation of one Warehouse being unable to have multiple subscriptions to the same repository be lifted as long as subscriptions to the same repo are all differentiated from one another by name? And if that were the case, it has implications for some of the expression functions like |
|
@krancour — thank you for the thorough review and for the additional context via #5729. Really helpful to understand the bigger picture you have in mind. I agree with all three points. Here's my plan: 1. Uniqueness validation — I'll add name uniqueness checking to the webhook's 2. Name propagation to Freight artifacts — I'll add a 3. Same-repo restriction + expression functions — I understand the implications for I'll push an updated commit once 1 and 2 are done. |
|
@krancour Thanks for the thorough review! I've pushed an updated commit that addresses the three gaps you identified: 1. Uniqueness validation in webhook 2. SubscriptionName on discovery result types 3. SubscriptionName propagated to Freight On your open question about expression functions ( |
2eb2104 to
50e32b9
Compare
Closes akuity#2839 Today, subscriptions are anonymous sub-elements of a Warehouse — when a Warehouse has multiple subscriptions of the same type (e.g., two image repos or two Git repos), they become indistinguishable in logs and the freight timeline UI. Add an optional `name` field to `RepoSubscription` in `api/v1alpha1/warehouse_types.go`. The field is: - Purely additive and backward-compatible (existing Warehouses need no migration; the field defaults to empty). - Limited to 253 characters (Kubernetes label-value convention). - Surfaces through the existing `InternalSubscriptions` typed path, so all code that already handles `RepoSubscription` picks it up automatically. Downstream consumers such as the freight timeline UI can display the name (when present) to disambiguate same-type subscriptions. Signed-off-by: mail2sudheerobbu-oss <mail2sudheerobbu@gmail.com> Signed-off-by: Claude user <claudeuser@Sunithas-MacBook-Pro.local> Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
- Fix addSub in warehouse webhook: entries were never added to uniqueSubSet map, so duplicate subscriptions were never caught. Add s[k] = f after each type-specific check. - Add name uniqueness validation in addSub so two subscriptions cannot share the same Name (case-insensitive). - Add SubscriptionName field to GitDiscoveryResult, ImageDiscoveryResult, and ChartDiscoveryResult in warehouse_types.go. - Add SubscriptionName field to GitCommit (freight_types.go) and Image, Chart (stage_types.go); update DeepEquals for all three. - Populate SubscriptionName from sub.Name in discoverArtifacts switch cases, and propagate it to GitCommit/Image/Chart structs in buildFreightFromLatestArtifacts. Closes akuity#2839 Signed-off-by: Claude user <claudeuser@Sunithas-MacBook-Pro.local> Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
12cba7e to
0e86f69
Compare
Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
0e86f69 to
5787ddc
Compare
|
@krancour — gentle ping! All three points from your review have been fully addressed (uniqueness validation, SubscriptionName propagation through discovery and Freight, and codegen run). All 16 CI checks are passing. Would you be able to take another look when you get a chance? Happy to address any further feedback. 🙏 |
|
@krancour — re-review request after addressing all 3 of your comments: (1) added name uniqueness validation per Warehouse in webhook, (2) propagated |
|
@krancour — thanks for the detailed review! To clarify the scope question: I'd like to keep this PR focused on just the
This way the core field addition can land cleanly, and each follow-up can be designed with the full context of how the field gets used downstream. Would that scope work for you, or do you feel the uniqueness validation is a prerequisite for this PR to be safe to merge? |
5787ddc to
88416c8
Compare
| // SubscriptionName is the optional human-readable name of the subscription | ||
| // that discovered this commit. | ||
| // | ||
| // +optional | ||
| SubscriptionName string `json:"subscriptionName,omitempty" protobuf:"bytes,9,opt,name=subscriptionName"` |
There was a problem hiding this comment.
Nit: It's odd to describe this as optional, given that this field, if non-empty, would have been populated by the system.
There was a problem hiding this comment.
Same comment applies elsewhere as well.
There was a problem hiding this comment.
Thanks for the thorough review @krancour!
Addressed in commit f93d344:
- Re-ran codegen: updated all generated files (generated.proto, generated_pb.ts, TypeScript v2 models, JSON schemas, CRD YAMLs, swagger.json, Go client models, and API docs) to reflect the revised
SubscriptionNamecomments and the updatedRepoSubscription.namedescription. - Added the
TODO(krancour)comment aboveaddSubin webhook.go as suggested.
CI check-codegen should now pass. Let me know if anything else needs attention.
There was a problem hiding this comment.
Thanks for the thorough review @krancour!
Addressed in commit f93d344:
- Re-ran codegen: updated all generated files (generated.proto, generated_pb.ts, TypeScript v2 models, JSON schemas, CRD YAMLs, swagger.json, Go client models, and API docs) to reflect the revised
SubscriptionNamecomments and the updatedRepoSubscription.namedescription. - Added the
TODO(krancour)comment aboveaddSubin webhook.go as suggested.
CI check-codegen should now pass. Let me know if anything else needs attention.
There was a problem hiding this comment.
Thanks for the thorough review @krancour!
Addressed in commit f93d344:
- Re-ran codegen: updated all generated files (generated.proto, generated_pb.ts, TypeScript v2 models, JSON schemas, CRD YAMLs, swagger.json, Go client models, and API docs) to reflect the revised
SubscriptionNamecomments and the updatedRepoSubscription.namedescription. - Added the
TODO(krancour)comment aboveaddSubin webhook.go as suggested.
CI check-codegen should now pass. Let me know if anything else needs attention.
There was a problem hiding this comment.
Thanks for the thorough review @krancour!
Addressed in commit f93d344:
- Re-ran codegen: updated all generated files (generated.proto, generated_pb.ts, TypeScript v2 models, JSON schemas, CRD YAMLs, swagger.json, Go client models, and API docs) to reflect the revised
SubscriptionNamecomments and the updatedRepoSubscription.namedescription. - Added the
TODO(krancour)comment aboveaddSubin webhook.go as suggested.
CI check-codegen should now pass. Let me know if anything else needs attention.
|
Fixed in b8041a2 — removed "optional" from the The |
… is system-populated) Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
b8041a2 to
7e858cf
Compare
|
@mail2sudheerobbu-oss this comment speaks to the outstanding question of scope. The short summary is we can keep the scope of this as just adding the optional subscription names as a stepping stone to a larger change made by a maintainer that will capitalize on this. |
This isn't entirely accurate. Since |
…e SubscriptionName into subscribers Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
|
All four of @krancour's review points have been addressed in the latest push (f71485f):
|
|
All four of @krancour's review points have been addressed in the latest push (f71485f):
|
|
https://github.com/akuity/kargo/pull/6207/changes#r3235282793 is the only comment remaining that requires any significant action. The back end parts of this looks ok to me. I am going to have Claude review further. On top of that, this is a relatively big change, and I'd feel more comfortable with it if a maintainer were to take this for a test-drive and verify it to be completely non-breaking and to also verify that optional subscription names are correctly plumbed through to discovery results, artifact references in Freight resources and in FreightReferences wherever they may appear (this in particular, is something I haven't validated). @fuskovic I am wondering if you could please test drive this? Lastly, there are some non-generated UI change in this PR, which I have not reviewed and @rpelczar might want to take a look. @mail2sudheerobbu-oss thank you for all the work on this. I do want to ask for your continued patience please. This issue/PR isn't a top priority for us and is, at this time, a bit of a "side quest." Everyone involved is reviewing purely on a best-effort basis. |
Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
|
Thanks for the thorough review @krancour! Addressed in commit f93d344:
CI check-codegen should now pass. Let me know if anything else needs attention. |
|
While I'm largely pleased with how this is shaping up, AI-assisted review 1. Tests. This adds a new field, a new uniqueness check, propagation through three subscriber implementations, and three updated 2. Name normalization is inconsistent with the existing generic 3. 4. The hash functions in 5. PR description rationale is wrong. "Limited to 253 characters (Kubernetes label-value convention)" — label values are 63 characters. 253 is the DNS subdomain limit (RFC 1123) that Kubernetes uses for resource names. I would knock it down to 63 which is generous and more consistent. 6. Docs. No prose changes under |
- Move RepoSubscription.Name uniqueness check from addSub into validateSubs so the error field path is spec.subscriptions[N].name instead of the incorrect spec.subscriptions[N].<type>.name - Use strings.TrimSpace+ToLower for case-insensitive name uniqueness check - MaxLength: 253 -> 63 (Kubernetes label-value limit) - Add Pattern: ^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$ - commitHashPart/imageHashPart/chartHashPart: append SubscriptionName when non-empty; empty SubscriptionName leaves IDs byte-identical (backward-compat) - TestSubscriptionNameAffectsFreightID: verifies all three hash functions produce distinct IDs when SubscriptionName is non-empty - TestValidateSpec: 'subscription names must be unique' case asserts error at spec.subscriptions[1].name (not .image.name / .git.name / .chart.name) Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
Three CI failures introduced by the round-4 commit:
1. webhook_test.go (test-unit / lint-go):
The 'subscription names must be unique' test case was injected at
3-tab indent inside the 'success' test case struct instead of as a
new element at 2-tab indent, causing 'mixture of field:value and
value elements in struct literal' at lines 248 and 356.
Fixes:
- Move test case to correct indent level (after 'success', not inside)
- Add missing 'webhook' field to avoid nil-pointer panic
- Add ObjectMeta.Namespace so ValidateCreate's project check passes
- Use Spec.InternalSubscriptions (what validateSpec actually walks)
instead of Spec.Subscriptions
- Remove one extra stale closing brace left by the injection
2. api/v1alpha1/generated.proto (check-codegen):
Sync MaxLength=253 → MaxLength=63 and add Pattern annotation in the
RepoSubscription.name field comment, matching warehouse_types.go.
3. ui/src/gen/api/v1alpha1/generated_pb.ts (check-codegen):
Same annotation update in JSDoc format for the TS protobuf binding.
4. docs/docs/90-api-documentation.md (check-codegen):
Remove trailing whitespace on the RepoSubscription name row.
Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
Two CI failures on commit 3c3baff: 1. lint-go (gci/gofmt): pkg/api/freight_test.go:259 — struct literal fields in TestSubscriptionNameAffectsFreightID used alignment spaces instead of tab-based gofmt style. Fix: applied gofmt -w. 2. check-codegen (docs): docs template emits a leading space for every line in the proto comment — including the blank separator + 3 kubebuilder lines — producing 4 trailing spaces before | on the name row. Previous fix compressed those to 1 space. Fix: restored 4 trailing spaces. Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
codegen produces 5 trailing spaces before the closing pipe in the RepoSubscription.name row (1 from the blank // separator + 3 from the +kubebuilder: annotation lines + 1 from the trailing newline in the proto description field), not 4 as previously assumed. Fixes check-codegen CI failure on PR akuity#6207. Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
|
@krancour — heads-up on the |
Address @krancour's review comments: 1. Tests for DeepEquals with SubscriptionName: - TestGitCommitDeepEquals: add 'subscription names differ' and 'perfect match with subscription name' cases - TestImageDeepEquals: same additions for Image type - TestChartDeepEquals: same additions for Chart type 2. Tests for name uniqueness normalization in webhook: - 'subscription name uniqueness is case-insensitive': Alpha vs ALPHA must be rejected (TrimSpace+ToLower normalization) - 'subscription name uniqueness ignores leading/trailing whitespace': 'foo' vs 'foo ' must be rejected 3. Docs: add 'Naming Subscriptions' section to the warehouse user guide explaining the optional name field, uniqueness rules, and length/ pattern constraints. Items 3, 4, and 5 from @krancour's review were already addressed in previous commits (Pattern/MaxLength=63 markers on field, SubscriptionName included in hash functions, PR description updated). Signed-off-by: Sudheer Obbu <mail2sudheerobbu@gmail.com>
6c6fe53 to
7d09ea6
Compare
Closes #2839
Today, subscriptions are anonymous sub-elements of a Warehouse — when a Warehouse has multiple subscriptions of the same type (e.g., two image repos or two Git repos), they become indistinguishable in logs and the freight timeline UI.
Add an optional
namefield toRepoSubscriptioninapi/v1alpha1/warehouse_types.go. The field is:InternalSubscriptionstyped path, so all code that already handlesRepoSubscriptionpicks it up automatically.Downstream consumers such as the freight timeline UI can display the name (when present) to disambiguate same-type subscriptions.