Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions specs/spec_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ func (r *SpecReader) validate() error {
if r.Destinations[destination] == nil {
return fmt.Errorf("source %s references unknown destination %s", source.Name, destination)
}
if destinationSourceMap[destination] == "" {
destinationSourceMap[destination] = source.Path + "@" + source.Version
} else if destinationSourceMap[destination] != source.Path+"@"+source.Version {
destinationToSourceKey := fmt.Sprintf("%s-%s", destination, source.Path)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to destination name and not destination.Path as those destination names are unique by definition in a single sync

if destinationSourceMap[destinationToSourceKey] == "" {
destinationSourceMap[destinationToSourceKey] = source.Path + "@" + source.Version
} else if destinationSourceMap[destinationToSourceKey] != source.Path+"@"+source.Version {
return fmt.Errorf("destination %s is used by multiple sources %s with different versions", destination, source.Path)
}
}
Expand Down
7 changes: 7 additions & 0 deletions specs/spec_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ var specLoaderTestCases = []specLoaderTestCase{
path: []string{"testdata/gcp.yml", "testdata/gcpv2.yml"},
err: "destination postgresqlv2 is used by multiple sources cloudquery/gcp with different versions",
},
{
name: "multiple sources success",
path: []string{"testdata/multiple_sources.yml"},
err: "",
sources: 2,
destinations: 1,
},
}

func TestLoadSpecs(t *testing.T) {
Expand Down
20 changes: 20 additions & 0 deletions specs/testdata/multiple_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
kind: source
spec:
name: aws
version: v4.6.1
destinations: [postgresql]
path: cloudquery/aws
---
kind: source
spec:
name: azure
version: v1.3.3
destinations: [postgresql]
path: cloudquery/azure
---
kind: destination
spec:
name: postgresql
version: v1.6.3
spec:
connection_string: postgresql://postgres:pass@localhost:5432/postgres