diff --git a/cli/cmd/generate.go b/cli/cmd/generate.go index bdf381cc36e..fc9f847c664 100644 --- a/cli/cmd/generate.go +++ b/cli/cmd/generate.go @@ -4,7 +4,6 @@ import ( "bufio" "fmt" "os" - "strings" "github.com/cloudquery/cloudquery/cli/internal/enum" diff --git a/cli/go.mod b/cli/go.mod index e4fd9e530a7..ecdd6cfb83f 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -3,7 +3,7 @@ module github.com/cloudquery/cloudquery/cli go 1.18 require ( - github.com/cloudquery/plugin-sdk v0.1.2 + github.com/cloudquery/plugin-sdk v0.2.4 github.com/getsentry/sentry-go v0.13.0 github.com/google/go-cmp v0.5.8 github.com/jackc/pgtype v1.12.0 diff --git a/cli/go.sum b/cli/go.sum index 79ebf5ea23d..d3bc061abe7 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -48,8 +48,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudquery/faker/v3 v3.7.7 h1:vODOmAXGhxAacVrUOjr4Jti2lFhXgkPjG6/L3C2REgQ= github.com/cloudquery/faker/v3 v3.7.7/go.mod h1:1b8WVG9Gh0T2hVo1a8dWeXfu0AhqSB6J/mmJaesqOeo= -github.com/cloudquery/plugin-sdk v0.1.2 h1:AEnCpGXdufcGadjZTrUWZTs/Xo4EUHtBCK9niBIppZU= -github.com/cloudquery/plugin-sdk v0.1.2/go.mod h1:koovnuG54fgQopmLhC+1KKewLiiZw8ZPinvq2/BDjFo= +github.com/cloudquery/plugin-sdk v0.2.4 h1:Me2f5utaAUk8RlrAXrzfNlJn2+Nt4GvjO7NrxFDKO0U= +github.com/cloudquery/plugin-sdk v0.2.4/go.mod h1:koovnuG54fgQopmLhC+1KKewLiiZw8ZPinvq2/BDjFo= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= diff --git a/cli/internal/destinations/postgresql/postgresql.go b/cli/internal/destinations/postgresql/postgresql.go index 68e08e69b19..31ff02c7191 100644 --- a/cli/internal/destinations/postgresql/postgresql.go +++ b/cli/internal/destinations/postgresql/postgresql.go @@ -234,7 +234,8 @@ func (p *Client) autoMigrateTable(ctx context.Context, table *schema.Table) erro } pgColumn := pgColumns.getPgColumn(c.Name) - if pgColumn == nil { + switch { + case pgColumn == nil: p.logger.Info().Str("table", table.Name).Str("column", c.Name).Msg("Column doesn't exist, creating") sql := "alter table " + tableName + " add column " + columnName + " " + columnType @@ -244,7 +245,7 @@ func (p *Client) autoMigrateTable(ctx context.Context, table *schema.Table) erro if _, err := p.conn.Exec(ctx, sql); err != nil { return fmt.Errorf("failed to add column %s on table %s: %w", c.Name, table.Name, err) } - } else if pgColumn.typ != columnType { + case pgColumn.typ != columnType: p.logger.Info().Str("table", table.Name).Str("column", c.Name).Str("old_type", pgColumn.typ).Str("new_type", columnType).Msg("Column exist but type is different, re-creating") // column exists but type is different @@ -261,7 +262,7 @@ func (p *Client) autoMigrateTable(ctx context.Context, table *schema.Table) erro if _, err := p.conn.Exec(ctx, sql); err != nil { return fmt.Errorf("failed to add column %s on table %s: %w", c.Name, table.Name, err) } - } else { + default: // column exists and type is the same but constraint might differ p.logger.Info().Str("table", table.Name).Str("column", c.Name).Str("type", c.Type.String()).Msg("Column exists with the same type") if pgPKs.columnExist(columnName) != c.CreationOptions.PrimaryKey { @@ -336,7 +337,7 @@ func upsert(table string, data map[string]interface{}) (string, []interface{}) { sb.WriteString(") values (") } } - for i, _ := range values { + for i := range values { sb.WriteString(fmt.Sprintf("$%d", i+1)) if i < len(values)-1 { sb.WriteString(",") diff --git a/cli/internal/plugins/plugins.go b/cli/internal/plugins/plugins.go index d8e4e10f85b..dbb328ecb16 100644 --- a/cli/internal/plugins/plugins.go +++ b/cli/internal/plugins/plugins.go @@ -7,6 +7,7 @@ package plugins import ( "archive/zip" "bufio" + "context" "encoding/json" "fmt" "io" @@ -16,8 +17,6 @@ import ( "runtime" "strings" - "context" - "github.com/cloudquery/cloudquery/cli/internal/destinations/postgresql" "github.com/cloudquery/cloudquery/cli/internal/versions" "github.com/cloudquery/plugin-sdk/clients" diff --git a/plugins/source/gcp/client/client.go b/plugins/source/gcp/client/client.go index 3e2f4f5b290..25efc93ea0d 100644 --- a/plugins/source/gcp/client/client.go +++ b/plugins/source/gcp/client/client.go @@ -27,7 +27,6 @@ type Client struct { } const ( - defaultProjectIdName = "" serviceAccountEnvKey = "CQ_SERVICE_ACCOUNT_KEY_JSON" ) diff --git a/plugins/source/gcp/client/client_test.go b/plugins/source/gcp/client/client_test.go deleted file mode 100644 index 00b1085f479..00000000000 --- a/plugins/source/gcp/client/client_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package client - -import ( - "context" - "encoding/json" - "net/http" - "net/http/httptest" - "strconv" - "strings" - "testing" - - "github.com/cloudquery/plugin-sdk/faker" - "github.com/julienschmidt/httprouter" - "github.com/stretchr/testify/assert" - "google.golang.org/api/cloudresourcemanager/v3" - "google.golang.org/api/option" -) - -func TestAppendWithoutDupes(t *testing.T) { - cases := []struct { - Base []string - Add []string - Expected []string - }{ - { - Base: nil, - Add: []string{"a", "b", "a"}, - Expected: []string{"a", "b"}, - }, - { - Base: []string{"a", "b"}, - Add: []string{"c", "b", "a"}, - Expected: []string{"a", "b", "c"}, - }, - { - Base: []string{"a", "b"}, - Add: []string{"b"}, - Expected: []string{"a", "b"}, - }, - } - for _, tc := range cases { - appendWithoutDupes(&tc.Base, tc.Add) - assert.Equal(t, tc.Expected, tc.Base) - } -} - -func TestListFolders(t *testing.T) { - svc, err := mockCRMFolders() - if err != nil { - assert.NoError(t, err) - } - - cases := []struct { - BaseFolder string - MaxDepth int - Expected []string - }{ - { - BaseFolder: "", - MaxDepth: 20, - Expected: []string{"", "root_0", "root_1", "root1.sub1_0", "root1.sub1.sub2_0", "root1.sub1.sub2_1", "root1.sub1.sub21.sub3_0", "root1.sub1.sub21.sub3_1", "root1.sub1.sub21.sub3_2", "root1.sub1.sub21.sub3_3", "root1.sub1.sub21.sub3_4", "root1.sub1.sub2_2", "root1.sub1_1", "root_2"}, - }, - { - BaseFolder: "", - MaxDepth: 3, - Expected: []string{"", "root_0", "root_1", "root1.sub1_0", "root1.sub1.sub2_0", "root1.sub1.sub2_1", "root1.sub1.sub2_2", "root1.sub1_1", "root_2"}, - }, - { - BaseFolder: "root_1", - MaxDepth: 1, - Expected: []string{"root_1", "root1.sub1_0", "root1.sub1_1"}, - }, - { - BaseFolder: "root_1", - MaxDepth: 2, - Expected: []string{"root_1", "root1.sub1_0", "root1.sub1.sub2_0", "root1.sub1.sub2_1", "root1.sub1.sub2_2", "root1.sub1_1"}, - }, - } - - for i, tc := range cases { - ret, err := listFolders(context.Background(), svc, tc.BaseFolder, tc.MaxDepth) - assert.NoError(t, err) - assert.Equalf(t, tc.Expected, ret, "Test #%d", i+1) - } -} - -func mockCRMFolders() (*cloudresourcemanager.FoldersService, error) { - makeFolders := func(baseName string, num int) []*cloudresourcemanager.Folder { - folders := make([]*cloudresourcemanager.Folder, num) - for i := 0; i < num; i++ { - var folder cloudresourcemanager.Folder - _ = faker.FakeObject(&folder) - folder.State = "ACTIVE" - folder.Name = baseName + "_" + strconv.Itoa(i) // we're omitting the 'folders/' prefix here to simplify the testdata - folders[i] = &folder - } - return folders - } - - mux := httprouter.New() - mux.GET("/v3/folders", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - _ = r.ParseForm() - - resp := &cloudresourcemanager.ListFoldersResponse{} - - switch strings.TrimPrefix(r.Form.Get("parent"), "folders/") { - case "": - resp.Folders = makeFolders("root", 3) - case "root_1": - resp.Folders = makeFolders("root1.sub1", 2) - case "root1.sub1_0": - resp.Folders = makeFolders("root1.sub1.sub2", 3) - case "root1.sub1.sub2_1": - resp.Folders = makeFolders("root1.sub1.sub21.sub3", 5) - } - - b, _ := json.Marshal(resp) - if _, err := w.Write(b); err != nil { - http.Error(w, "failed to write", http.StatusBadRequest) - return - } - }) - ts := httptest.NewServer(mux) - svc, err := cloudresourcemanager.NewService(context.Background(), option.WithoutAuthentication(), option.WithEndpoint(ts.URL)) - if err != nil { - return nil, err - } - return svc.Folders, nil -} diff --git a/plugins/source/gcp/go.mod b/plugins/source/gcp/go.mod index 413ebb0a292..9f8cd2e3f8f 100644 --- a/plugins/source/gcp/go.mod +++ b/plugins/source/gcp/go.mod @@ -17,7 +17,7 @@ require ( cloud.google.com/go/secretmanager v1.5.0 cloud.google.com/go/serviceusage v1.2.0 cloud.google.com/go/storage v1.26.0 - github.com/cloudquery/plugin-sdk v0.1.2 + github.com/cloudquery/plugin-sdk v0.2.4 github.com/golang/mock v1.6.0 github.com/googleapis/gax-go/v2 v2.5.1 github.com/iancoleman/strcase v0.2.0 @@ -25,7 +25,6 @@ require ( github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.28.0 github.com/spf13/cast v1.5.0 - github.com/stretchr/testify v1.8.0 github.com/thoas/go-funk v0.9.2 google.golang.org/api v0.94.0 google.golang.org/genproto v0.0.0-20220819153447-c7cd466b0e09 @@ -36,7 +35,6 @@ require ( cloud.google.com/go v0.102.1 // indirect cloud.google.com/go/iam v0.3.0 // indirect github.com/cloudquery/faker/v3 v3.7.7 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/getsentry/sentry-go v0.13.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/gofrs/uuid v4.2.0+incompatible // indirect @@ -51,7 +49,6 @@ require ( github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/cobra v1.5.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect @@ -69,5 +66,4 @@ require ( google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/plugins/source/gcp/go.sum b/plugins/source/gcp/go.sum index 6d1625e701e..755f3624d0f 100644 --- a/plugins/source/gcp/go.sum +++ b/plugins/source/gcp/go.sum @@ -100,8 +100,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudquery/faker/v3 v3.7.7 h1:vODOmAXGhxAacVrUOjr4Jti2lFhXgkPjG6/L3C2REgQ= github.com/cloudquery/faker/v3 v3.7.7/go.mod h1:1b8WVG9Gh0T2hVo1a8dWeXfu0AhqSB6J/mmJaesqOeo= -github.com/cloudquery/plugin-sdk v0.1.2 h1:AEnCpGXdufcGadjZTrUWZTs/Xo4EUHtBCK9niBIppZU= -github.com/cloudquery/plugin-sdk v0.1.2/go.mod h1:koovnuG54fgQopmLhC+1KKewLiiZw8ZPinvq2/BDjFo= +github.com/cloudquery/plugin-sdk v0.2.4 h1:Me2f5utaAUk8RlrAXrzfNlJn2+Nt4GvjO7NrxFDKO0U= +github.com/cloudquery/plugin-sdk v0.2.4/go.mod h1:koovnuG54fgQopmLhC+1KKewLiiZw8ZPinvq2/BDjFo= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -116,7 +116,6 @@ github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1 github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -286,15 +285,12 @@ github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/thoas/go-funk v0.9.2 h1:oKlNYv0AY5nyf9g+/GhMgS/UO2ces0QRdPKwkhY3VCk= github.com/thoas/go-funk v0.9.2/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= @@ -773,7 +769,6 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/plugins/source/gcp/resources/services/container/clusters_fetch.go b/plugins/source/gcp/resources/services/container/clusters_fetch.go index 126a1664b47..5ee0aca339c 100644 --- a/plugins/source/gcp/resources/services/container/clusters_fetch.go +++ b/plugins/source/gcp/resources/services/container/clusters_fetch.go @@ -7,7 +7,6 @@ import ( "github.com/cloudquery/plugin-sdk/schema" "github.com/cloudquery/plugins/source/gcp/client" "github.com/pkg/errors" - pb "google.golang.org/genproto/googleapis/container/v1" ) diff --git a/plugins/source/gcp/resources/services/kms/keyrings_fetch.go b/plugins/source/gcp/resources/services/kms/keyrings_fetch.go index b5872347a5f..b13c9a0b7b0 100644 --- a/plugins/source/gcp/resources/services/kms/keyrings_fetch.go +++ b/plugins/source/gcp/resources/services/kms/keyrings_fetch.go @@ -14,7 +14,7 @@ import ( func fetchKeyrings(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error { c := meta.(*client.Client) - locations, err := getAllKmsLocations(ctx, c) + locations, err := getAllKmsLocations(c) if err != nil { return errors.WithStack(fmt.Errorf("failed to get kms locations. %w", err)) } @@ -37,7 +37,7 @@ func fetchKeyrings(ctx context.Context, meta schema.ClientMeta, parent *schema.R return nil } -func getAllKmsLocations(ctx context.Context, c *client.Client) ([]*cloudkms.Location, error) { +func getAllKmsLocations(c *client.Client) ([]*cloudkms.Location, error) { var locations []*cloudkms.Location call := c.Services.KmsoldService.Projects.Locations.List("projects/" + c.ProjectId) nextPageToken := "" diff --git a/plugins/source/gcp/resources/services/kms/keyrings_mock_test.go b/plugins/source/gcp/resources/services/kms/keyrings_mock_test.go index 0b63b0684f9..c43a5988817 100644 --- a/plugins/source/gcp/resources/services/kms/keyrings_mock_test.go +++ b/plugins/source/gcp/resources/services/kms/keyrings_mock_test.go @@ -14,12 +14,10 @@ import ( "github.com/cloudquery/plugins/source/gcp/client" "github.com/julienschmidt/httprouter" kmsold "google.golang.org/api/cloudkms/v1" + "google.golang.org/api/option" + pb "google.golang.org/genproto/googleapis/cloud/kms/v1" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - - pb "google.golang.org/genproto/googleapis/cloud/kms/v1" - - "google.golang.org/api/option" ) func createKeyrings() (*client.Services, error) { @@ -91,7 +89,7 @@ type fakeKeyringsServer struct { pb.UnimplementedKeyManagementServiceServer } -func (f *fakeKeyringsServer) ListKeyRings(context.Context, *pb.ListKeyRingsRequest) (*pb.ListKeyRingsResponse, error) { +func (*fakeKeyringsServer) ListKeyRings(context.Context, *pb.ListKeyRingsRequest) (*pb.ListKeyRingsResponse, error) { resp := pb.ListKeyRingsResponse{} if err := faker.FakeObject(&resp); err != nil { return nil, fmt.Errorf("failed to fake data: %w", err) diff --git a/plugins/source/gcp/resources/services/sql/instances_mock_test.go b/plugins/source/gcp/resources/services/sql/instances_mock_test.go index 22623f46b3b..19c0cf90b50 100644 --- a/plugins/source/gcp/resources/services/sql/instances_mock_test.go +++ b/plugins/source/gcp/resources/services/sql/instances_mock_test.go @@ -10,10 +10,8 @@ import ( "github.com/cloudquery/plugin-sdk/faker" "github.com/cloudquery/plugins/source/gcp/client" "github.com/julienschmidt/httprouter" - - sql "google.golang.org/api/sqladmin/v1beta4" - "google.golang.org/api/option" + sql "google.golang.org/api/sqladmin/v1beta4" ) func createInstances() (*client.Services, error) { diff --git a/plugins/source/gcp/resources/services/storage/buckets_mock_test.go b/plugins/source/gcp/resources/services/storage/buckets_mock_test.go index 5ddc905f71b..f76a3edf46c 100644 --- a/plugins/source/gcp/resources/services/storage/buckets_mock_test.go +++ b/plugins/source/gcp/resources/services/storage/buckets_mock_test.go @@ -8,12 +8,10 @@ import ( "net/http/httptest" "testing" + "cloud.google.com/go/storage" "github.com/cloudquery/plugin-sdk/faker" "github.com/cloudquery/plugins/source/gcp/client" "github.com/julienschmidt/httprouter" - - "cloud.google.com/go/storage" - "google.golang.org/api/option" oldapi "google.golang.org/api/storage/v1" ) diff --git a/plugins/source/heroku/codegen/account_feature.go b/plugins/source/heroku/codegen/account_feature.go index e3815381334..e4ed6e6af5b 100644 --- a/plugins/source/heroku/codegen/account_feature.go +++ b/plugins/source/heroku/codegen/account_feature.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -51,6 +50,9 @@ func AccountFeatures() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/add_on.go b/plugins/source/heroku/codegen/add_on.go index 690bd51e85c..f67868ce1c7 100644 --- a/plugins/source/heroku/codegen/add_on.go +++ b/plugins/source/heroku/codegen/add_on.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -56,6 +55,9 @@ func AddOns() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/add_on_attachment.go b/plugins/source/heroku/codegen/add_on_attachment.go index 4316bceacd2..220ada23af7 100644 --- a/plugins/source/heroku/codegen/add_on_attachment.go +++ b/plugins/source/heroku/codegen/add_on_attachment.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -36,6 +35,9 @@ func AddOnAttachments() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "log_input_url", diff --git a/plugins/source/heroku/codegen/add_on_config.go b/plugins/source/heroku/codegen/add_on_config.go index 434244608b9..099795b3c68 100644 --- a/plugins/source/heroku/codegen/add_on_config.go +++ b/plugins/source/heroku/codegen/add_on_config.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/add_on_region_capability.go b/plugins/source/heroku/codegen/add_on_region_capability.go index b78fbd3f70a..81749e0db07 100644 --- a/plugins/source/heroku/codegen/add_on_region_capability.go +++ b/plugins/source/heroku/codegen/add_on_region_capability.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -26,6 +25,9 @@ func AddOnRegionCapabilities() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "region", diff --git a/plugins/source/heroku/codegen/add_on_service.go b/plugins/source/heroku/codegen/add_on_service.go index 6702cb9b422..95cb2ec97f6 100644 --- a/plugins/source/heroku/codegen/add_on_service.go +++ b/plugins/source/heroku/codegen/add_on_service.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -36,6 +35,9 @@ func AddOnServices() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/add_on_webhook.go b/plugins/source/heroku/codegen/add_on_webhook.go index d878df5e295..fa8676b4c6d 100644 --- a/plugins/source/heroku/codegen/add_on_webhook.go +++ b/plugins/source/heroku/codegen/add_on_webhook.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -26,6 +25,9 @@ func AddOnWebhooks() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "include", diff --git a/plugins/source/heroku/codegen/add_on_webhook_delivery.go b/plugins/source/heroku/codegen/add_on_webhook_delivery.go index 48c16c92616..7d8ff3e7af7 100644 --- a/plugins/source/heroku/codegen/add_on_webhook_delivery.go +++ b/plugins/source/heroku/codegen/add_on_webhook_delivery.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/add_on_webhook_event.go b/plugins/source/heroku/codegen/add_on_webhook_event.go index f38c22bc94b..2d09f757984 100644 --- a/plugins/source/heroku/codegen/add_on_webhook_event.go +++ b/plugins/source/heroku/codegen/add_on_webhook_event.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/app.go b/plugins/source/heroku/codegen/app.go index 85f373a4ced..66aa08030f8 100644 --- a/plugins/source/heroku/codegen/app.go +++ b/plugins/source/heroku/codegen/app.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -51,6 +50,9 @@ func Apps() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "internal_routing", diff --git a/plugins/source/heroku/codegen/app_feature.go b/plugins/source/heroku/codegen/app_feature.go index 23f77cab1f3..fc52961ca1a 100644 --- a/plugins/source/heroku/codegen/app_feature.go +++ b/plugins/source/heroku/codegen/app_feature.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -51,6 +50,9 @@ func AppFeatures() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/app_transfer.go b/plugins/source/heroku/codegen/app_transfer.go index 7fd489a71e5..6b3d9453299 100644 --- a/plugins/source/heroku/codegen/app_transfer.go +++ b/plugins/source/heroku/codegen/app_transfer.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -31,6 +30,9 @@ func AppTransfers() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "owner", diff --git a/plugins/source/heroku/codegen/app_webhook.go b/plugins/source/heroku/codegen/app_webhook.go index df435045e36..49d5d170751 100644 --- a/plugins/source/heroku/codegen/app_webhook.go +++ b/plugins/source/heroku/codegen/app_webhook.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/app_webhook_delivery.go b/plugins/source/heroku/codegen/app_webhook_delivery.go index 77fc0f08ed5..4a2c81fd756 100644 --- a/plugins/source/heroku/codegen/app_webhook_delivery.go +++ b/plugins/source/heroku/codegen/app_webhook_delivery.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -31,6 +30,9 @@ func AppWebhookDeliveries() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "last_attempt", diff --git a/plugins/source/heroku/codegen/app_webhook_event.go b/plugins/source/heroku/codegen/app_webhook_event.go index 42d3f97b261..aee43e35ebc 100644 --- a/plugins/source/heroku/codegen/app_webhook_event.go +++ b/plugins/source/heroku/codegen/app_webhook_event.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -26,6 +25,9 @@ func AppWebhookEvents() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "include", diff --git a/plugins/source/heroku/codegen/build.go b/plugins/source/heroku/codegen/build.go index ea66c875758..58a45a2e1a9 100644 --- a/plugins/source/heroku/codegen/build.go +++ b/plugins/source/heroku/codegen/build.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -36,6 +35,9 @@ func Builds() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "output_stream_url", diff --git a/plugins/source/heroku/codegen/buildpack_installation.go b/plugins/source/heroku/codegen/buildpack_installation.go index 959081231d8..be98aa22949 100644 --- a/plugins/source/heroku/codegen/buildpack_installation.go +++ b/plugins/source/heroku/codegen/buildpack_installation.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/collaborator.go b/plugins/source/heroku/codegen/collaborator.go index 77e88676ae6..c272ab5065a 100644 --- a/plugins/source/heroku/codegen/collaborator.go +++ b/plugins/source/heroku/codegen/collaborator.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -31,6 +30,9 @@ func Collaborators() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "permissions", diff --git a/plugins/source/heroku/codegen/credit.go b/plugins/source/heroku/codegen/credit.go index 99378df9163..59c51fa4800 100644 --- a/plugins/source/heroku/codegen/credit.go +++ b/plugins/source/heroku/codegen/credit.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -41,6 +40,9 @@ func Credits() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "title", diff --git a/plugins/source/heroku/codegen/domain.go b/plugins/source/heroku/codegen/domain.go index 791961ea464..852416bbec5 100644 --- a/plugins/source/heroku/codegen/domain.go +++ b/plugins/source/heroku/codegen/domain.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -51,6 +50,9 @@ func Domains() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "kind", diff --git a/plugins/source/heroku/codegen/dyno.go b/plugins/source/heroku/codegen/dyno.go index 1d9f6e58287..bd101f70b7d 100644 --- a/plugins/source/heroku/codegen/dyno.go +++ b/plugins/source/heroku/codegen/dyno.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -41,6 +40,9 @@ func Dynos() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/dyno_size.go b/plugins/source/heroku/codegen/dyno_size.go index f4e16de076e..f86b2f94024 100644 --- a/plugins/source/heroku/codegen/dyno_size.go +++ b/plugins/source/heroku/codegen/dyno_size.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -41,6 +40,9 @@ func DynoSizes() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "memory", diff --git a/plugins/source/heroku/codegen/enterprise_account.go b/plugins/source/heroku/codegen/enterprise_account.go index 391075c4695..a8113acd807 100644 --- a/plugins/source/heroku/codegen/enterprise_account.go +++ b/plugins/source/heroku/codegen/enterprise_account.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -26,6 +25,9 @@ func EnterpriseAccounts() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "identity_provider", diff --git a/plugins/source/heroku/codegen/enterprise_account_member.go b/plugins/source/heroku/codegen/enterprise_account_member.go index 5e70d420aff..4faa8738f20 100644 --- a/plugins/source/heroku/codegen/enterprise_account_member.go +++ b/plugins/source/heroku/codegen/enterprise_account_member.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -26,6 +25,9 @@ func EnterpriseAccountMembers() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "identity_provider", diff --git a/plugins/source/heroku/codegen/formation.go b/plugins/source/heroku/codegen/formation.go index 83f33c66481..541e2b5ba31 100644 --- a/plugins/source/heroku/codegen/formation.go +++ b/plugins/source/heroku/codegen/formation.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -36,6 +35,9 @@ func Formations() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "quantity", diff --git a/plugins/source/heroku/codegen/inbound_ruleset.go b/plugins/source/heroku/codegen/inbound_ruleset.go index d886ebd9b4c..6915d2cc25e 100644 --- a/plugins/source/heroku/codegen/inbound_ruleset.go +++ b/plugins/source/heroku/codegen/inbound_ruleset.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -31,6 +30,9 @@ func InboundRulesets() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "rules", diff --git a/plugins/source/heroku/codegen/invoice.go b/plugins/source/heroku/codegen/invoice.go index 0ecead21dd1..4a8cb899642 100644 --- a/plugins/source/heroku/codegen/invoice.go +++ b/plugins/source/heroku/codegen/invoice.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -36,6 +35,9 @@ func Invoices() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "number", diff --git a/plugins/source/heroku/codegen/key.go b/plugins/source/heroku/codegen/key.go index c44e57f2a19..f6ff51cffca 100644 --- a/plugins/source/heroku/codegen/key.go +++ b/plugins/source/heroku/codegen/key.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -41,6 +40,9 @@ func Keys() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "public_key", diff --git a/plugins/source/heroku/codegen/log_drain.go b/plugins/source/heroku/codegen/log_drain.go index 592d31bd95b..ec084d4c683 100644 --- a/plugins/source/heroku/codegen/log_drain.go +++ b/plugins/source/heroku/codegen/log_drain.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -31,6 +30,9 @@ func LogDrains() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "token", diff --git a/plugins/source/heroku/codegen/o_auth_authorization.go b/plugins/source/heroku/codegen/o_auth_authorization.go index 40e4df99d42..ea4acf129de 100644 --- a/plugins/source/heroku/codegen/o_auth_authorization.go +++ b/plugins/source/heroku/codegen/o_auth_authorization.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -41,6 +40,9 @@ func OAuthAuthorizations() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "refresh_token", diff --git a/plugins/source/heroku/codegen/o_auth_client.go b/plugins/source/heroku/codegen/o_auth_client.go index c5fb3354ec1..2dc3faf3c0d 100644 --- a/plugins/source/heroku/codegen/o_auth_client.go +++ b/plugins/source/heroku/codegen/o_auth_client.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -26,6 +25,9 @@ func OAuthClients() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "ignores_delinquent", diff --git a/plugins/source/heroku/codegen/outbound_ruleset.go b/plugins/source/heroku/codegen/outbound_ruleset.go index 1bcce29a865..a5096994efe 100644 --- a/plugins/source/heroku/codegen/outbound_ruleset.go +++ b/plugins/source/heroku/codegen/outbound_ruleset.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -31,6 +30,9 @@ func OutboundRulesets() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "rules", diff --git a/plugins/source/heroku/codegen/peering.go b/plugins/source/heroku/codegen/peering.go index ed5a6cac63f..67eeb5481d6 100644 --- a/plugins/source/heroku/codegen/peering.go +++ b/plugins/source/heroku/codegen/peering.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/permission_entity.go b/plugins/source/heroku/codegen/permission_entity.go index d03be0699ee..5a009a2a83e 100644 --- a/plugins/source/heroku/codegen/permission_entity.go +++ b/plugins/source/heroku/codegen/permission_entity.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -21,6 +20,9 @@ func PermissionEntities() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/pipeline.go b/plugins/source/heroku/codegen/pipeline.go index 0ba51d047a8..028aedfbdcd 100644 --- a/plugins/source/heroku/codegen/pipeline.go +++ b/plugins/source/heroku/codegen/pipeline.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -26,6 +25,9 @@ func Pipelines() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/pipeline_build.go b/plugins/source/heroku/codegen/pipeline_build.go index 96bdec3163d..b2cd234ee4b 100644 --- a/plugins/source/heroku/codegen/pipeline_build.go +++ b/plugins/source/heroku/codegen/pipeline_build.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/pipeline_coupling.go b/plugins/source/heroku/codegen/pipeline_coupling.go index 43458b03ade..c3e9fb1a5c1 100644 --- a/plugins/source/heroku/codegen/pipeline_coupling.go +++ b/plugins/source/heroku/codegen/pipeline_coupling.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -31,6 +30,9 @@ func PipelineCouplings() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "pipeline", diff --git a/plugins/source/heroku/codegen/pipeline_deployment.go b/plugins/source/heroku/codegen/pipeline_deployment.go index 46ac8cc5452..ec7ef44bc31 100644 --- a/plugins/source/heroku/codegen/pipeline_deployment.go +++ b/plugins/source/heroku/codegen/pipeline_deployment.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/pipeline_release.go b/plugins/source/heroku/codegen/pipeline_release.go index 0b316689d25..6138fe57f17 100644 --- a/plugins/source/heroku/codegen/pipeline_release.go +++ b/plugins/source/heroku/codegen/pipeline_release.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/region.go b/plugins/source/heroku/codegen/region.go index ce9e75c165f..46d8d04d42e 100644 --- a/plugins/source/heroku/codegen/region.go +++ b/plugins/source/heroku/codegen/region.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -36,6 +35,9 @@ func Regions() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "locale", diff --git a/plugins/source/heroku/codegen/release.go b/plugins/source/heroku/codegen/release.go index 88b4b148d3e..78ef158f6da 100644 --- a/plugins/source/heroku/codegen/release.go +++ b/plugins/source/heroku/codegen/release.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -46,6 +45,9 @@ func Releases() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "output_stream_url", diff --git a/plugins/source/heroku/codegen/review_app.go b/plugins/source/heroku/codegen/review_app.go index 389624dd4af..0c43a521c98 100644 --- a/plugins/source/heroku/codegen/review_app.go +++ b/plugins/source/heroku/codegen/review_app.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -56,6 +55,9 @@ func ReviewApps() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "message", diff --git a/plugins/source/heroku/codegen/space.go b/plugins/source/heroku/codegen/space.go index 19a5d7c0d91..6098688a8ab 100644 --- a/plugins/source/heroku/codegen/space.go +++ b/plugins/source/heroku/codegen/space.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -36,6 +35,9 @@ func Spaces() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/space_app_access.go b/plugins/source/heroku/codegen/space_app_access.go index 84c67fbd905..ec2af77cc3b 100644 --- a/plugins/source/heroku/codegen/space_app_access.go +++ b/plugins/source/heroku/codegen/space_app_access.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -26,6 +25,9 @@ func SpaceAppAccesses() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "permissions", diff --git a/plugins/source/heroku/codegen/stack.go b/plugins/source/heroku/codegen/stack.go index 98c0ba9f71f..9bbc83f7567 100644 --- a/plugins/source/heroku/codegen/stack.go +++ b/plugins/source/heroku/codegen/stack.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -31,6 +30,9 @@ func Stacks() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/team.go b/plugins/source/heroku/codegen/team.go index eeb3e9ecc25..142424c870c 100644 --- a/plugins/source/heroku/codegen/team.go +++ b/plugins/source/heroku/codegen/team.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -41,6 +40,9 @@ func Teams() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "identity_provider", diff --git a/plugins/source/heroku/codegen/team_app_permission.go b/plugins/source/heroku/codegen/team_app_permission.go index 14a953eedd2..b4de506ee6e 100644 --- a/plugins/source/heroku/codegen/team_app_permission.go +++ b/plugins/source/heroku/codegen/team_app_permission.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/team_feature.go b/plugins/source/heroku/codegen/team_feature.go index c8bd219e660..1a35d8bfd56 100644 --- a/plugins/source/heroku/codegen/team_feature.go +++ b/plugins/source/heroku/codegen/team_feature.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -51,6 +50,9 @@ func TeamFeatures() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "name", diff --git a/plugins/source/heroku/codegen/team_invitation.go b/plugins/source/heroku/codegen/team_invitation.go index ed922f7e6c5..931bd8ed3e0 100644 --- a/plugins/source/heroku/codegen/team_invitation.go +++ b/plugins/source/heroku/codegen/team_invitation.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -26,6 +25,9 @@ func TeamInvitations() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "invited_by", diff --git a/plugins/source/heroku/codegen/team_invoice.go b/plugins/source/heroku/codegen/team_invoice.go index e68285f5962..f0b259502d5 100644 --- a/plugins/source/heroku/codegen/team_invoice.go +++ b/plugins/source/heroku/codegen/team_invoice.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -51,6 +50,9 @@ func TeamInvoices() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "number", diff --git a/plugins/source/heroku/codegen/team_member.go b/plugins/source/heroku/codegen/team_member.go index 29af3b633c1..95444acf224 100644 --- a/plugins/source/heroku/codegen/team_member.go +++ b/plugins/source/heroku/codegen/team_member.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -36,6 +35,9 @@ func TeamMembers() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "identity_provider", diff --git a/plugins/source/heroku/codegen/team_space.go b/plugins/source/heroku/codegen/team_space.go index 042f0d9936f..b60eaaa0ec8 100644 --- a/plugins/source/heroku/codegen/team_space.go +++ b/plugins/source/heroku/codegen/team_space.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" diff --git a/plugins/source/heroku/codegen/vpn_connection.go b/plugins/source/heroku/codegen/vpn_connection.go index 01be81cbac0..1c7d805c647 100644 --- a/plugins/source/heroku/codegen/vpn_connection.go +++ b/plugins/source/heroku/codegen/vpn_connection.go @@ -4,7 +4,6 @@ package codegen import ( "context" - "github.com/cloudquery/cloudquery/plugins/source/heroku/client" "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" @@ -21,6 +20,9 @@ func VPNConnections() *schema.Table { Name: "id", Type: schema.TypeString, Resolver: schema.PathResolver("ID"), + CreationOptions: schema.ColumnCreationOptions{ + PrimaryKey: true, + }, }, { Name: "ike_version", diff --git a/plugins/source/heroku/codegenmain/main.go b/plugins/source/heroku/codegenmain/main.go index 6c91ccc90ee..5a5af7ada52 100644 --- a/plugins/source/heroku/codegenmain/main.go +++ b/plugins/source/heroku/codegenmain/main.go @@ -76,7 +76,12 @@ func generateResource(r recipes.Resource, mock bool) { if err != nil { log.Fatal(err) } - r.Table.Columns = append(r.DefaultColumns, r.Table.Columns...) + for i := range r.Table.Columns { + if r.Table.Columns[i].Name == r.PrimaryKey { + r.Table.Columns[i].Options.PrimaryKey = true + } + } + r.Table.Resolver = "fetch" + inflection.Plural(r.HerokuStructName) r.Table.Description = fmt.Sprintf("https://devcenter.heroku.com/articles/platform-api-reference#%s-attributes", strcase.ToKebab(r.HerokuStructName)) mainTemplate := r.Template + ".go.tpl" diff --git a/plugins/source/heroku/codegenmain/recipes/recipes.go b/plugins/source/heroku/codegenmain/recipes/recipes.go index 4021099f044..bfb75995911 100644 --- a/plugins/source/heroku/codegenmain/recipes/recipes.go +++ b/plugins/source/heroku/codegenmain/recipes/recipes.go @@ -4,13 +4,10 @@ import ( "reflect" "github.com/cloudquery/plugin-sdk/codegen" - "github.com/cloudquery/plugin-sdk/schema" heroku "github.com/heroku/heroku-go/v5" ) type Resource struct { - // DefaultColumns columns that will be appended to the main table - DefaultColumns []codegen.ColumnDefinition // Table is the table definition that will be used to generate the cloudquery table Table *codegen.TableDefinition // TableName can be used to override the default generated table name @@ -31,8 +28,7 @@ type Resource struct { Template string // SkipFields fields in go struct to skip when generating the table from the go struct SkipFields []string - // CreateTableOptions options to use to create the main table - CreateTableOptions schema.TableCreationOptions + PrimaryKey string } var listResources = []Resource{ @@ -262,7 +258,6 @@ var listResources = []Resource{ Template: "relational_resource_list", }, - // TODO: Add support for Archive //{ // HerokuStruct: &heroku.Archive{}, @@ -353,10 +348,9 @@ func All() []Resource { if r.HerokuPrimaryStruct != nil { r.HerokuPrimaryStructName = reflect.TypeOf(r.HerokuPrimaryStruct).Elem().Name() } - r.DefaultColumns = []codegen.ColumnDefinition{} r.SkipFields = []string{} - if resources[i].CreateTableOptions.PrimaryKeys == nil { - resources[i].CreateTableOptions.PrimaryKeys = []string{"id"} + if r.PrimaryKey == "" { + r.PrimaryKey = "id" } resources[i] = r } diff --git a/plugins/source/heroku/go.mod b/plugins/source/heroku/go.mod index d9f3d71fb76..da143eb0ac4 100644 --- a/plugins/source/heroku/go.mod +++ b/plugins/source/heroku/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/cloudquery/cq-gen v0.0.12 github.com/cloudquery/faker/v3 v3.7.7 - github.com/cloudquery/plugin-sdk v0.1.2 + github.com/cloudquery/plugin-sdk v0.2.4 github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.5.8 github.com/googleapis/gax-go/v2 v2.4.0 diff --git a/plugins/source/heroku/go.sum b/plugins/source/heroku/go.sum index faedf806ddd..937e3f958dd 100644 --- a/plugins/source/heroku/go.sum +++ b/plugins/source/heroku/go.sum @@ -86,8 +86,8 @@ github.com/cloudquery/cq-provider-sdk v0.14.7 h1:95yw0qc1IebxRAJyGdJjNM8gXJOHjMZ github.com/cloudquery/cq-provider-sdk v0.14.7/go.mod h1:fJNnqlYU+yKV7uH5luznZr6IA4XLllauGau1uRAsqmE= github.com/cloudquery/faker/v3 v3.7.7 h1:vODOmAXGhxAacVrUOjr4Jti2lFhXgkPjG6/L3C2REgQ= github.com/cloudquery/faker/v3 v3.7.7/go.mod h1:1b8WVG9Gh0T2hVo1a8dWeXfu0AhqSB6J/mmJaesqOeo= -github.com/cloudquery/plugin-sdk v0.1.1 h1:89TZAQZdpLtepikYp26qAgebsBRrc1HlF8MFurrLA8E= -github.com/cloudquery/plugin-sdk v0.1.1/go.mod h1:koovnuG54fgQopmLhC+1KKewLiiZw8ZPinvq2/BDjFo= +github.com/cloudquery/plugin-sdk v0.2.4 h1:Me2f5utaAUk8RlrAXrzfNlJn2+Nt4GvjO7NrxFDKO0U= +github.com/cloudquery/plugin-sdk v0.2.4/go.mod h1:koovnuG54fgQopmLhC+1KKewLiiZw8ZPinvq2/BDjFo= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=