Skip to content

Commit 1f1828f

Browse files
authored
streaming_tenant: forwards compatiblity with 2.4 (#459)
The ID format has changed in version 2.4.x from tenantName to clusterName/tenantName. This update handles going from 2.4.x back to 2.3.x version.
1 parent a3c376a commit 1f1828f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
push:
77
branches:
88
- 'main'
9+
- '2.1.x'
10+
- '2.2.x'
11+
- '2.3.x'
912
jobs:
1013
docs:
1114
runs-on: ubuntu-latest

internal/provider/resource_streaming_tenant.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,16 @@ func setStreamingTenantData(ctx context.Context, d *schema.ResourceData, tenantR
313313
return nil
314314
}
315315

316+
// parseStreamingTenantID parses the tenant ID in the form "clusterID/tenantName" or just "tenantName"
317+
// and returns the tenantName, or error for invalid format.
316318
func parseStreamingTenantID(id string) (string, error) {
317319
idParts := strings.Split(strings.ToLower(id), "/")
318-
if len(idParts) != 1 {
319-
return "", errors.New("invalid tenant id format: expected tenantID/")
320+
if len(idParts) == 1 {
321+
return idParts[0], nil // tenantName only
322+
} else if len(idParts) == 2 {
323+
return idParts[1], nil // clusterName/tenantName
320324
}
321-
return idParts[0], nil
325+
return "", errors.New("invalid tenant id format: expected clusterName/tenantName")
322326
}
323327

324328
func streamingRegionSuppressDiff(k, oldValue, newValue string, d *schema.ResourceData) bool {

0 commit comments

Comments
 (0)