Skip to content

Commit aaa3e0d

Browse files
committed
feat: Add GetDestinationNamesForSource
1 parent 7aa2461 commit aaa3e0d

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/davecgh/go-spew v1.1.0 // indirect
1717
github.com/golang/protobuf v1.5.2 // indirect
1818
github.com/pmezard/go-difflib v1.0.0 // indirect
19+
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 // indirect
1920
golang.org/x/net v0.8.0 // indirect
2021
golang.org/x/sys v0.6.0 // indirect
2122
golang.org/x/text v0.8.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
1515
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
1616
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
1717
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
18+
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o=
19+
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
1820
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
1921
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
2022
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=

specs/spec_reader.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strings"
1111

1212
"github.com/ghodss/yaml"
13+
"golang.org/x/exp/slices"
1314
)
1415

1516
type SpecReader struct {
@@ -163,6 +164,17 @@ func (r *SpecReader) GetDestinationByName(name string) *Destination {
163164
return r.destinationsMap[name]
164165
}
165166

167+
func (r *SpecReader) GetDestinationNamesForSource(name string) []string {
168+
var destinations []string
169+
source := r.sourcesMap[name]
170+
for _, destinationName := range source.Destinations {
171+
if slices.Contains(source.Destinations, destinationName) {
172+
destinations = append(destinations, r.destinationsMap[destinationName].Name)
173+
}
174+
}
175+
return destinations
176+
}
177+
166178
func NewSpecReader(paths []string) (*SpecReader, error) {
167179
reader := &SpecReader{
168180
sourcesMap: make(map[string]*Source),

0 commit comments

Comments
 (0)