diff --git a/go.mod b/go.mod index 0556ce4..60c44b2 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/davecgh/go-spew v1.1.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 // indirect golang.org/x/net v0.8.0 // indirect golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect diff --git a/go.sum b/go.sum index 2f6111c..dd3efc1 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,8 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw= github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= +golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o= +golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= diff --git a/specs/spec_reader.go b/specs/spec_reader.go index 1c48b29..347fa45 100644 --- a/specs/spec_reader.go +++ b/specs/spec_reader.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/ghodss/yaml" + "golang.org/x/exp/slices" ) type SpecReader struct { @@ -163,6 +164,17 @@ func (r *SpecReader) GetDestinationByName(name string) *Destination { return r.destinationsMap[name] } +func (r *SpecReader) GetDestinationNamesForSource(name string) []string { + var destinations []string + source := r.sourcesMap[name] + for _, destinationName := range source.Destinations { + if slices.Contains(source.Destinations, destinationName) { + destinations = append(destinations, r.destinationsMap[destinationName].Name) + } + } + return destinations +} + func NewSpecReader(paths []string) (*SpecReader, error) { reader := &SpecReader{ sourcesMap: make(map[string]*Source),