Skip to content

Commit d968032

Browse files
authored
feat: Update SDK to v0.10.1 (#2100)
Sync CLI supports now reading directories, files and files with multiple yaml objects.
1 parent c8f1e69 commit d968032

File tree

4 files changed

+15
-43
lines changed

4 files changed

+15
-43
lines changed

cli/cmd/sync.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ import (
1313
)
1414

1515
const (
16-
fetchShort = "Sync resources from configured source plugins to destination"
17-
fetchExample = `# Sync configured providers to PostgreSQL as configured in cloudquery.yml
18-
cloudquery sync ./directory`
16+
fetchShort = "Sync resources from configured source plugins to destinations"
17+
fetchExample = `# Sync resources from configuration in a directory
18+
cloudquery sync ./directory
19+
# Sync resources from directories and files
20+
cloudquery sync ./directory ./aws.yml ./pg.yml
21+
`
1922
)
2023

2124
func NewCmdSync() *cobra.Command {
2225
cmd := &cobra.Command{
23-
Use: "sync [directory]",
26+
Use: "sync [file or directories...]",
2427
Short: fetchShort,
2528
Long: fetchShort,
2629
Example: fetchExample,
27-
Args: cobra.MaximumNArgs(1),
30+
Args: cobra.MinimumNArgs(1),
2831
RunE: sync,
2932
}
3033
return cmd
@@ -37,29 +40,25 @@ func sync(cmd *cobra.Command, args []string) error {
3740
directory = args[0]
3841
}
3942
fmt.Println("Loading specs from directory: ", directory)
40-
specReader, err := specs.NewSpecReader(directory)
43+
specReader, err := specs.NewSpecReader(args)
4144
if err != nil {
4245
return fmt.Errorf("failed to load specs from directory %s: %w", directory, err)
4346
}
4447

45-
if len(specReader.GetSources()) == 0 {
46-
return fmt.Errorf("no sources found in directory: %s", directory)
47-
}
48-
4948
pm := plugins.NewPluginManager()
50-
for _, sourceSpec := range specReader.GetSources() {
49+
for _, sourceSpec := range specReader.Sources {
5150
if len(sourceSpec.Destinations) == 0 {
5251
return fmt.Errorf("no destinations found for source %s", sourceSpec.Name)
5352
}
5453
var destinationsSpecs []specs.Destination
5554
for _, destination := range sourceSpec.Destinations {
56-
spec := specReader.GetDestinationByName(destination)
55+
spec := specReader.Destinations[destination]
5756
if spec == nil {
5857
return fmt.Errorf("failed to find destination %s in source %s", destination, sourceSpec.Name)
5958
}
6059
destinationsSpecs = append(destinationsSpecs, *spec)
6160
}
62-
if err := syncConnection(ctx, pm, sourceSpec, destinationsSpecs); err != nil {
61+
if err := syncConnection(ctx, pm, *sourceSpec, destinationsSpecs); err != nil {
6362
return fmt.Errorf("failed to sync source %s: %w", sourceSpec.Name, err)
6463
}
6564
}

cli/go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/cloudquery/cloudquery/cli
33
go 1.19
44

55
require (
6-
github.com/cloudquery/plugin-sdk v0.9.0
6+
github.com/cloudquery/plugin-sdk v0.10.1
77
github.com/getsentry/sentry-go v0.13.0
88
github.com/rs/zerolog v1.28.0
99
github.com/schollz/progressbar/v3 v3.9.0
@@ -21,7 +21,6 @@ require (
2121
github.com/golang/protobuf v1.5.2 // indirect
2222
github.com/google/uuid v1.3.0 // indirect
2323
github.com/hashicorp/hcl v1.0.0 // indirect
24-
github.com/iancoleman/strcase v0.2.0 // indirect
2524
github.com/inconshreveable/mousetrap v1.0.1 // indirect
2625
github.com/magiconair/properties v1.8.6 // indirect
2726
github.com/mattn/go-colorable v0.1.13 // indirect

cli/go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P
4444
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
4545
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
4646
github.com/cloudquery/faker/v3 v3.7.7 h1:vODOmAXGhxAacVrUOjr4Jti2lFhXgkPjG6/L3C2REgQ=
47-
github.com/cloudquery/plugin-sdk v0.9.0 h1:1juj4bR8AXfnS5gGp3Ttldk8h1ojVhS3cfvFUsH6ixU=
48-
github.com/cloudquery/plugin-sdk v0.9.0/go.mod h1:SGHJV+4JE3sN9+VB7Lb185kGJDE2q7oxVrp3Cww769k=
47+
github.com/cloudquery/plugin-sdk v0.10.1 h1:8XD0+EM2RMtasrC/ReUqvSlBlC+20FiwFimpogXtTVE=
48+
github.com/cloudquery/plugin-sdk v0.10.1/go.mod h1:iVqMqfdjvImbDIF3BvKEXDpujpSITjPfEu4wxPL1xRQ=
4949
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
5050
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
5151
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
@@ -140,8 +140,6 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
140140
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
141141
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
142142
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
143-
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
144-
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
145143
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
146144
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
147145
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=

cli/internal/plugins/manager_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,12 @@ import (
1010
)
1111

1212
var getSourceClientTestCases = []specs.Source{
13-
{
14-
Name: "test",
15-
Registry: specs.RegistryGithub,
16-
Path: "cloudquery/test",
17-
Version: "latest",
18-
},
1913
{
2014
Name: "test",
2115
Registry: specs.RegistryGithub,
2216
Path: "cloudquery/test",
2317
Version: "v1.1.5",
2418
},
25-
{
26-
Name: "test",
27-
Registry: specs.RegistryGithub,
28-
Path: "yevgenypats/test",
29-
Version: "latest",
30-
},
3119
{
3220
Name: "test",
3321
Registry: specs.RegistryGithub,
@@ -61,24 +49,12 @@ func TestPluginManagerGetSourceClient(t *testing.T) {
6149
}
6250

6351
var getDestinationClientTestCases = []specs.Source{
64-
{
65-
Name: "test",
66-
Registry: specs.RegistryGithub,
67-
Path: "cloudquery/test",
68-
Version: "latest",
69-
},
7052
{
7153
Name: "test",
7254
Registry: specs.RegistryGithub,
7355
Path: "cloudquery/test",
7456
Version: "v1.1.0",
7557
},
76-
{
77-
Name: "test",
78-
Registry: specs.RegistryGithub,
79-
Path: "yevgenypats/test",
80-
Version: "latest",
81-
},
8258
{
8359
Name: "test",
8460
Registry: specs.RegistryGithub,

0 commit comments

Comments
 (0)