Skip to content

Commit 89191f1

Browse files
refactor(annotations): simplify nesting for ProviderSpecificAnnotations method (#5813)
Signed-off-by: ivan katliarchuk <[email protected]>
1 parent b8fee6a commit 89191f1

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

source/annotations/provider_specific.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,18 @@ func ProviderSpecificAnnotations(annotations map[string]string) (endpoint.Provid
3333
for k, v := range annotations {
3434
if k == SetIdentifierKey {
3535
setIdentifier = v
36-
} else if strings.HasPrefix(k, AWSPrefix) {
37-
attr := strings.TrimPrefix(k, AWSPrefix)
36+
} else if attr, ok := strings.CutPrefix(k, AWSPrefix); ok {
3837
providerSpecificAnnotations = append(providerSpecificAnnotations, endpoint.ProviderSpecificProperty{
3938
Name: fmt.Sprintf("aws/%s", attr),
4039
Value: v,
4140
})
42-
} else if strings.HasPrefix(k, SCWPrefix) {
43-
attr := strings.TrimPrefix(k, SCWPrefix)
41+
} else if attr, ok := strings.CutPrefix(k, SCWPrefix); ok {
4442
providerSpecificAnnotations = append(providerSpecificAnnotations, endpoint.ProviderSpecificProperty{
4543
Name: fmt.Sprintf("scw/%s", attr),
4644
Value: v,
4745
})
48-
} else if strings.HasPrefix(k, WebhookPrefix) {
46+
} else if attr, ok := strings.CutPrefix(k, WebhookPrefix); ok {
4947
// Support for wildcard annotations for webhook providers
50-
attr := strings.TrimPrefix(k, WebhookPrefix)
5148
providerSpecificAnnotations = append(providerSpecificAnnotations, endpoint.ProviderSpecificProperty{
5249
Name: fmt.Sprintf("webhook/%s", attr),
5350
Value: v,

0 commit comments

Comments
 (0)