Skip to content

Commit

Permalink
[DSMS-19] Fix SNS topic format issue (#2725)
Browse files Browse the repository at this point in the history
Co-authored-by: Dario Castañé <[email protected]>
  • Loading branch information
juliannzhou and darccio authored Jun 5, 2024
1 parent eeaff7c commit 2fb4ed0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/datastreams/pathway.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,27 @@ import (

var hashableEdgeTags = map[string]struct{}{"event_type": {}, "exchange": {}, "group": {}, "topic": {}, "type": {}, "direction": {}}

func isValidArn(arn string) bool {
separators := strings.Count(arn, ":")
if separators < 5 {
return false
}
if strings.HasPrefix(arn, "arn:") {
return true
}
return false
}

func isWellFormedEdgeTag(t string) bool {
if i := strings.IndexByte(t, ':'); i != -1 {
if j := strings.LastIndexByte(t, ':'); j == i {
if _, exists := hashableEdgeTags[t[:i]]; exists {
return true
}
}
if t[:i] == "topic" && isValidArn(t) {
return true
}
}
return false
}
Expand Down

0 comments on commit 2fb4ed0

Please sign in to comment.