fix(subscriptions): resolve named services from subscription annotations#458
Open
yugstar wants to merge 1 commit into
Open
fix(subscriptions): resolve named services from subscription annotations#458yugstar wants to merge 1 commit into
yugstar wants to merge 1 commit into
Conversation
iterate() set the service to only parts[1] when splitting the subscription annotation key, dropping any further name segments. A named service such as service.github.orgb (registered in the config as github.orgb) therefore resolved to just \"github\" and failed with \"notification service github is not supported\". Join the remaining segments so the full name (github.orgb) is used, matching the multi-segment keys that config.go already supports. Existing two-segment keys (subscribe.<trigger>.<service>) are unchanged. Closes argoproj#346 Signed-off-by: Aman Raj <aman.yug@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #458 +/- ##
==========================================
+ Coverage 55.41% 57.13% +1.72%
==========================================
Files 46 49 +3
Lines 4125 3782 -343
==========================================
- Hits 2286 2161 -125
+ Misses 1511 1263 -248
- Partials 328 358 +30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #346
Problem
iterate()inpkg/subscriptions/annotations.goparses a subscription annotation key likenotifications.argoproj.io/subscribe.<trigger>.<service>by splitting on.and takingservice = parts[1].For a named service the name is dropped. Example: a service registered in the config as
service.github.orgb(lookup keygithub.orgb) is subscribed with:The key splits to
[on-sync, github, orgb], soparts[1]is justgithub. Dispatch then looks upgithub(not registered) and fails withnotification service "github" is not supported.This breaks named services in general (
github.orgb,slack.teamA, …) and is the root cause behind the multiple-GitHub-app-installation use case in #346.Fix
Join the remaining segments instead of taking only the second one:
so the full name
github.orgbis preserved and resolves to the registered config key. This matches the multi-segment service naming thatconfig.goalready supports. Backward compatible: existing two-segment keys (subscribe.<trigger>.<service>) are unchanged.Test
Extended
TestIteratewith asubscribe.on-sync.github.orgbcase asserting the resolved service isgithub.orgb.Proven as a real regression test:
TestIteratefails —Not equal: expected "github.orgb", actual "github".go build ./...andgo vet ./pkg/subscriptions/are clean.