Skip to content

Commit 026002a

Browse files
authored
[receiver/googlecloudpubsub] Support for Google Trusted Partner Cloud project naming convention (#43988)
#### Description Adds support for Google's Trusted Partner Cloud (TPC) project naming convention which now includes a `:` character. #### Link to tracking issue n/a #### Testing This has been tested within the sandbox environment of Google's German TPC partner. New unit tests have also been introduced. #### Documentation Please see https://documentation.s3ns.fr/docs/overview/tpc-key-differences#key_differences_for_developers for information about this new project naming convention within a TPC.
1 parent b58632a commit 026002a

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

.chloggen/tpc_regex.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: receiver/googlecloudpubsub
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Adjusts the subscription regex to accommodate new project naming used for Google Trusted Partner Clouds.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [43988]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

receiver/googlecloudpubsubreceiver/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"go.opentelemetry.io/collector/exporter/exporterhelper"
1111
)
1212

13-
var subscriptionMatcher = regexp.MustCompile(`projects/[a-z][a-z0-9\-]*/subscriptions/`)
13+
var subscriptionMatcher = regexp.MustCompile(`projects/[a-z][a-z0-9\-]*(:[a-z0-9\-]+)?/subscriptions/`)
1414

1515
type Config struct {
1616
// Google Cloud Project ID where the Pubsub client will connect to

receiver/googlecloudpubsubreceiver/config_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,16 @@ func TestConfigValidation(t *testing.T) {
7070
assert.Error(t, c.validate())
7171
c.Subscription = "projects/my-project/subscriptions/my-subscription"
7272
assert.NoError(t, c.validate())
73+
// Test for project IDs with a single colon (not at start, not at end)
74+
c.Subscription = "projects/s3ns:my-project/subscriptions/my-subscription"
75+
assert.NoError(t, c.validate())
76+
// Invalid: colon at the start
77+
c.Subscription = "projects/:invalid/subscriptions/my-subscription"
78+
assert.Error(t, c.validate())
79+
// Invalid: colon at the end
80+
c.Subscription = "projects/invalid:/subscriptions/my-subscription"
81+
assert.Error(t, c.validate())
82+
// Invalid: multiple colons
83+
c.Subscription = "projects/s3ns:invalid:invalid/subscriptions/my-subscription"
84+
assert.Error(t, c.validate())
7385
}

0 commit comments

Comments
 (0)