Git Product home page Git Product logo

plugin-sdk's Introduction

CloudQuery Plugin SDK

Go Reference Go Report Card Unit tests

CloudQuery SDK enables building CloudQuery source and destination plugins.

Source plugins allows developers to extract information from third party APIs and enjoying built-in transformations, concurrency, logging, testing and database agnostic support via destination plugins.

Destinations plugins allows writing the data from any of the source plugins to an additional database, message queue, storage or any other destination without recompiling any of the source plugins.

The plugin SDK is imported as a dependency by CloudQuery plugins. When starting a new plugin, you should use the Scaffold tool.

Getting Started & Documentation

Supported plugins

https://www.cloudquery.io/plugins

If you want us to add a new plugin or resource please open an Issue.

plugin-sdk's People

Contributors

amanenk avatar bbernays avatar candiduslynx avatar cq-bot avatar cychiang avatar daniil-ushkov avatar disq avatar erezrokah avatar hermanschaaf avatar irmatov avatar maaarcelino avatar michelvocks avatar mnorbury avatar murarustefaan avatar roneli avatar shimonp21 avatar spangenberg avatar yevgenypats avatar zagronitay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

plugin-sdk's Issues

feature: Allow selective child-table filtering/inclusion

If a resource has many child tables and the user just wants a few synced, they should be able to achieve that by including those tables (and possibly all their dependent parent tables, if we don't want implicit behaviour) in the config.

This is the opposite of #340 but needs more changes in the handling side of things, not just input validation.

Consolidate `ParentResourceFieldResolver` and `ParentPathResolver`

Seems like they both serve the same purpose of getting data from the parent.

ParentResourceFieldResolver works on table columns (probably should be called ParentColumnResolver) and goes only 1 level deep.

ParentPathResolver works on structs and can go any level deep.

Maybe we should only have a single API to access parent data? Also I think we should probably only access table columns as accessing struct data misses any post resolving done by the parent resource

Bug(config): Can't use multiple sources in the same sync

Describe the bug

With the following config:

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

The CLI errors out with Error: failed to load spec(s) from <path>. Error: destination postgresql is used by multiple sources cloudquery/azure with different versions

Expected Behavior

Using multiple sources should work

Steps to Reproduce

Create a YAML file with the above configuration, run cloudquery sync <file>

Possible Solution

Fix the config validation

Provider and CloudQuery version

v1.5.5

Additional Context

No response

Registry github does not work on windows

Describe the bug

When I try to sync on windows using github registry cloudquery returns

Error: failed to sync source aws: failed to initialize destination plugin client for postgresql: destination configure: failed to call Configure: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp: address unix://C:\\Users\\andre\\AppData\\Local\\Temp/cq-SzttZHuEzsslQeXr.sock: too many colons in address"

To achieve this result I have removed grpc.WithBlock() option in grpc.DialContext. With the option the program just blocks when cli tries to dial to plugin.

Expected Behavior

it should work on windows

Steps to Reproduce

cd cli
go run main.go sync ./examples/aws_github --log-level debug

Possible Solution

No response

Provider and CloudQuery version

main branch

Additional Context

No response

Remove `ParentIDResolver`

ParentIDResolver uses an internal id (cq_id) to link between tables and relations.

Since relations are always explicitly set by a developer I think we shouldn't use an internal ID to link tables and force the developer to specify a field via ParentResourceFieldResolver.

Another reason for dropping ParentIDResolver is that our naming convention for relation id fields are <parent_resource>_id for example sql_server_id to link server<->database. (sql_server_id is on the database table).

It makes sense to populate that column with the server ID and not an internal ID

Replace `strcase.ToSnake` with a better alternative

We use strcase.ToSnake to create tables and column names:

return strcase.ToSnake(name)

It fails in many cases which forces consumers to override columns:
https://github.com/cloudquery/cloudquery/pull/1903/files#diff-696d2ccebfefda5499a79ed759bdb24563eb1a510b7d320f8d61e37298de76deR55
https://github.com/cloudquery/cloudquery/blob/edb6e0ed01ccdb4c1b218b67d57c75c36e0815bd/plugins/source/azure/codegen/recipes/compute.go#L70

We should a library that handles those cases for us.

Maybe also do a sanity check by doing ToSnake then ToCamel and see that we get the field name

feat(destinations): Don't stop the sync if a single write operation fails

At the moment if a single write operation fails we close the gRPC destination stream and stop syncing.
Usually a write fails when a table violates primary key constraints (e.g. setting a NULL value).
I'm not sure a failure to write a single resource should prevent us from syncing all others.

Relevant code is

return s.Plugin.Write(ctx, tables, sourceName, syncTime, resources)

We pass ctx to the plugin Write method which propagates all the way down, for example:
https://github.com/cloudquery/cloudquery/blob/d74ac122a4ed1f4378a485293fa66ffee836ff29/plugins/destination/postgresql/client/write.go#L48

If there's an error during Write the context is cancelled, we fall to the case here:

case <-ctx.Done():

and return an error.
This means the the stream is closed and we reported an error here:
return fmt.Errorf("failed to send tables: %w", err)

(Please note we report the wrong error, which is fixed by #460)

When redirecting the plugin output to a file, colors are added to the output

Describe the bug

Not sure if this belongs here or in https://github.com/cloudquery/cloudquery.

When doing go run main.go serve > output.txt in a plugin's repo (after cloning it), the file will contain the following:

�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_datalake_analytics_accounts
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_frontdoor_doors
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_datalake_store_accounts
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_compute_virtual_machines
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_eventhub_namespaces
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_cdn_profiles
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_iothub_devices
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_container_registries
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_container_managed_clusters
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_compute_disks
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_keyvault_managed_hsms
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_compute_virtual_machine_scale_sets
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_authorization_role_assignments
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_keyvault_vaults
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_batch_accounts
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_authorization_role_definitions
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_logic_workflows
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_mariadb_servers
�[90m11:40AM�[0m �[32mINF�[0m fetch start �[36mtable=�[0mazure_cosmosdb_accounts

This makes it harder to debug plugins

Expected Behavior

The output file should not have special characters

Steps to Reproduce

  1. [email protected]:cloudquery/cloudquery.git
  2. cd plugins/source/gcp
  3. go run main.go serve > output.txt

Examine content of output.txt

Possible Solution

Support NO_COLOR=true env variable and/or automatically set it when piping output to a file

Provider and CloudQuery version

v2

Additional Context

No response

Run benchmarks in CI

We have a couple of benchmarks now, and it would be good to run them in CI and comment on the PR if there are signifcant changes.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

Renovate tried to run on this repository, but found these problems.

  • WARN: Package lookup failures

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • fix(deps): Update golang.org/x/exp digest to 814bf88
  • fix(deps): Update google.golang.org/genproto/googleapis/api digest to 6ceb2ff
  • fix(deps): Update google.golang.org/genproto/googleapis/rpc digest to 6ceb2ff
  • fix(deps): Update module github.com/klauspost/compress to v1.17.7
  • fix(deps): Update module github.com/klauspost/cpuid/v2 to v2.2.7
  • fix(deps): Update module github.com/tdewolff/minify/v2 to v2.20.18
  • fix(deps): Update module github.com/tdewolff/parse/v2 to v2.7.12
  • fix(deps): Update module github.com/ugorji/go/codec to v1.2.12
  • chore(deps): Update dependency golangci/golangci-lint to v1.56.2
  • fix(deps): Update module github.com/bytedance/sonic to v1.11.1
  • fix(deps): Update module github.com/deepmap/oapi-codegen to v1.16.2
  • fix(deps): Update module github.com/getsentry/sentry-go to v0.27.0
  • fix(deps): Update module github.com/go-logr/logr to v1.4.1
  • fix(deps): Update module github.com/go-playground/validator/v10 to v10.18.0
  • fix(deps): Update module github.com/google/uuid to v1.6.0
  • fix(deps): Update module github.com/grpc-ecosystem/grpc-gateway/v2 to v2.19.1
  • fix(deps): Update module github.com/invopop/jsonschema to v0.12.0
  • fix(deps): Update module github.com/leodido/go-urn to v1.4.0
  • fix(deps): Update module github.com/pelletier/go-toml/v2 to v2.1.1
  • fix(deps): Update module github.com/rs/zerolog to v1.32.0
  • fix(deps): Update module github.com/spf13/cobra to v1.8.0
  • fix(deps): Update module go.opentelemetry.io/proto/otlp to v1.1.0
  • fix(deps): Update module golang.org/x/arch to v0.7.0
  • fix(deps): Update module golang.org/x/crypto to v0.20.0
  • fix(deps): Update module golang.org/x/mod to v0.15.0
  • fix(deps): Update module golang.org/x/net to v0.21.0
  • fix(deps): Update module golang.org/x/sys to v0.17.0
  • fix(deps): Update module golang.org/x/tools to v0.18.0
  • fix(deps): Update module google.golang.org/grpc to v1.62.0
  • fix(deps): Update opentelemetry-go monorepo to v1.24.0 (go.opentelemetry.io/otel, go.opentelemetry.io/otel/exporters/otlp/otlptrace, go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp, go.opentelemetry.io/otel/metric, go.opentelemetry.io/otel/sdk, go.opentelemetry.io/otel/trace)
  • fix(deps): Update actions/checkout action to v4
  • fix(deps): Update actions/github-script action to v7
  • fix(deps): Update actions/setup-go action to v5
  • fix(deps): Update actions/upload-artifact action to v4
  • fix(deps): Update golangci/golangci-lint-action action to v4
  • fix(deps): Update google-github-actions/release-please-action action to v4
  • fix(deps): Update module github.com/deepmap/oapi-codegen to v2
  • fix(deps): Update module github.com/flosch/pongo2/v4 to v6

Warning

Renovate failed to look up the following dependencies: Could not determine new digest for update (go package github.com/apache/arrow/go/v15), Could not determine new digest for update (go package github.com/apache/arrow/go/v13).

Files affected: examples/simple_plugin/go.mod, go.mod


Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/add_tags.yml
  • bcoe/conventional-release-labels v1
.github/workflows/lint_golang.yml
  • actions/checkout v3
  • actions/setup-go v4
  • golangci/golangci-lint-action v3
.github/workflows/lint_markdown.yml
  • actions/checkout v3
  • errata-ai/vale-action v2
  • actions/checkout v3
  • nosborn/github-action-markdown-cli v3.3.0
.github/workflows/pr_title.yml
  • amannn/action-semantic-pull-request v5
.github/workflows/release-pr.yml
  • google-github-actions/release-please-action v3
  • booxmedialtd/ws-action-parse-semver 7784200024d6b3fc01253e617ec0168daf603de3
  • tubone24/update_release 1cfa79ccf7422570d9a9c6b6de749ff4b280e48b
  • actions/github-script v6
.github/workflows/unittest-post.yml
  • haya14busa/action-workflow_run-status v1
  • dawidd6/action-download-artifact v2
  • netlify/delta-action v4
.github/workflows/unittest.yml
  • actions/checkout v3
  • actions/setup-go v4
  • actions/upload-artifact v3
gomod
examples/simple_plugin/go.mod
  • go 1.21.5
  • github.com/apache/arrow/go/v15 v15.0.0-20240114144300-7e703aae55c1@7e703aae55c1
  • github.com/cloudquery/plugin-sdk/v4 v4.31.0
  • github.com/rs/zerolog v1.30.0
  • go.opentelemetry.io/otel/metric v1.20.0
  • go.opentelemetry.io/otel/trace v1.20.0
  • github.com/BurntSushi/toml v1.3.2
  • github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53@33d98a066a53
  • github.com/CloudyKit/jet/v6 v6.2.0
  • github.com/Joker/jade v1.1.3
  • github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06@8cddb4f5de06
  • github.com/adrg/xdg v0.4.0
  • github.com/andybalholm/brotli v1.1.0
  • github.com/apache/arrow/go/v13 v13.0.0-20230731205701-112f94971882@112f94971882
  • github.com/apapsch/go-jsonmerge/v2 v2.0.0
  • github.com/aymerick/douceur v0.2.0
  • github.com/bahlo/generic-list-go v0.2.0
  • github.com/buger/jsonparser v1.1.1
  • github.com/bytedance/sonic v1.10.2
  • github.com/cenkalti/backoff/v4 v4.2.1
  • github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d@296ad89f973d
  • github.com/chenzhuoyu/iasm v0.9.1
  • github.com/cloudquery/cloudquery-api-go v1.7.5
  • github.com/cloudquery/plugin-pb-go v1.19.0
  • github.com/cloudquery/plugin-sdk/v2 v2.7.0
  • github.com/davecgh/go-spew v1.1.1
  • github.com/deepmap/oapi-codegen v1.15.0
  • github.com/fatih/structs v1.1.0
  • github.com/flosch/pongo2/v4 v4.0.2
  • github.com/gabriel-vasile/mimetype v1.4.3
  • github.com/getsentry/sentry-go v0.24.1
  • github.com/ghodss/yaml v1.0.0
  • github.com/gin-contrib/sse v0.1.0
  • github.com/gin-gonic/gin v1.9.1
  • github.com/go-logr/logr v1.3.0
  • github.com/go-logr/stdr v1.2.2
  • github.com/go-playground/locales v0.14.1
  • github.com/go-playground/universal-translator v0.18.1
  • github.com/go-playground/validator/v10 v10.14.0
  • github.com/goccy/go-json v0.10.2
  • github.com/golang/protobuf v1.5.3
  • github.com/golang/snappy v0.0.4
  • github.com/gomarkdown/markdown v0.0.0-20231222211730-1d6d20845b47@1d6d20845b47
  • github.com/google/flatbuffers v23.5.26+incompatible
  • github.com/google/uuid v1.5.0
  • github.com/gorilla/css v1.0.1
  • github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1
  • github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0
  • github.com/inconshreveable/mousetrap v1.1.0
  • github.com/invopop/jsonschema v0.10.0
  • github.com/iris-contrib/schema v0.0.6
  • github.com/josharian/intern v1.0.0
  • github.com/json-iterator/go v1.1.12
  • github.com/kataras/blocks v0.0.8
  • github.com/kataras/golog v0.1.11
  • github.com/kataras/iris/v12 v12.2.10
  • github.com/kataras/pio v0.0.13
  • github.com/kataras/sitemap v0.0.6
  • github.com/kataras/tunnel v0.0.4
  • github.com/klauspost/compress v1.17.5
  • github.com/klauspost/cpuid/v2 v2.2.6
  • github.com/labstack/echo/v4 v4.11.4
  • github.com/labstack/gommon v0.4.2
  • github.com/leodido/go-urn v1.2.4
  • github.com/mailgun/raymond/v2 v2.0.48
  • github.com/mailru/easyjson v0.7.7
  • github.com/mattn/go-colorable v0.1.13
  • github.com/mattn/go-isatty v0.0.20
  • github.com/microcosm-cc/bluemonday v1.0.26
  • github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd@bacd9c7ef1dd
  • github.com/modern-go/reflect2 v1.0.2
  • github.com/pelletier/go-toml/v2 v2.0.8
  • github.com/pierrec/lz4/v4 v4.1.21
  • github.com/pmezard/go-difflib v1.0.0
  • github.com/russross/blackfriday/v2 v2.1.0
  • github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
  • github.com/schollz/closestmatch v2.1.0+incompatible
  • github.com/sirupsen/logrus v1.9.3
  • github.com/spf13/cobra v1.6.1
  • github.com/spf13/pflag v1.0.5
  • github.com/stretchr/testify v1.8.4
  • github.com/tdewolff/minify/v2 v2.20.16
  • github.com/tdewolff/parse/v2 v2.7.11
  • github.com/thoas/go-funk v0.9.3
  • github.com/twitchyliquid64/golang-asm v0.15.1
  • github.com/ugorji/go/codec v1.2.11
  • github.com/valyala/bytebufferpool v1.0.0
  • github.com/valyala/fasttemplate v1.2.2
  • github.com/vmihailenco/msgpack/v5 v5.4.1
  • github.com/vmihailenco/tagparser/v2 v2.0.0
  • github.com/wk8/go-ordered-map/v2 v2.1.8
  • github.com/yosssi/ace v0.0.5
  • github.com/zeebo/xxh3 v1.0.2
  • go.opentelemetry.io/otel v1.20.0
  • go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.20.0
  • go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.20.0
  • go.opentelemetry.io/otel/sdk v1.20.0
  • go.opentelemetry.io/proto/otlp v1.0.0
  • golang.org/x/arch v0.3.0
  • golang.org/x/crypto v0.18.0
  • golang.org/x/exp v0.0.0-20240119083558-1b970713d09a@1b970713d09a
  • golang.org/x/mod v0.14.0
  • golang.org/x/net v0.20.0
  • golang.org/x/sync v0.6.0
  • golang.org/x/sys v0.16.0
  • golang.org/x/text v0.14.0
  • golang.org/x/time v0.5.0
  • golang.org/x/tools v0.17.0
  • golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028@104605ab7028
  • google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe@1f4bbc51befe
  • google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe@1f4bbc51befe
  • google.golang.org/grpc v1.60.1
  • google.golang.org/protobuf v1.32.0
  • gopkg.in/ini.v1 v1.67.0
  • gopkg.in/yaml.v2 v2.4.0
  • gopkg.in/yaml.v3 v3.0.1
go.mod
  • go 1.21.5
  • github.com/apache/arrow/go/v15 v15.0.0-20240114144300-7e703aae55c1@7e703aae55c1
  • github.com/bradleyjkemp/cupaloy/v2 v2.8.0
  • github.com/cloudquery/cloudquery-api-go v1.7.5
  • github.com/cloudquery/plugin-pb-go v1.19.0
  • github.com/cloudquery/plugin-sdk/v2 v2.7.0
  • github.com/getsentry/sentry-go v0.24.1
  • github.com/goccy/go-json v0.10.2
  • github.com/google/go-cmp v0.6.0
  • github.com/google/uuid v1.5.0
  • github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1
  • github.com/invopop/jsonschema v0.10.0
  • github.com/rs/zerolog v1.29.1
  • github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
  • github.com/spf13/cobra v1.6.1
  • github.com/stretchr/testify v1.8.4
  • github.com/thoas/go-funk v0.9.3
  • go.opentelemetry.io/otel v1.20.0
  • go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.20.0
  • go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.20.0
  • go.opentelemetry.io/otel/sdk v1.20.0
  • golang.org/x/exp v0.0.0-20240119083558-1b970713d09a@1b970713d09a
  • golang.org/x/sync v0.6.0
  • golang.org/x/text v0.14.0
  • google.golang.org/grpc v1.60.1
  • google.golang.org/protobuf v1.32.0
  • github.com/BurntSushi/toml v1.3.2
  • github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53@33d98a066a53
  • github.com/CloudyKit/jet/v6 v6.2.0
  • github.com/Joker/jade v1.1.3
  • github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06@8cddb4f5de06
  • github.com/adrg/xdg v0.4.0
  • github.com/andybalholm/brotli v1.1.0
  • github.com/apache/arrow/go/v13 v13.0.0-20230731205701-112f94971882@112f94971882
  • github.com/apapsch/go-jsonmerge/v2 v2.0.0
  • github.com/aymerick/douceur v0.2.0
  • github.com/bahlo/generic-list-go v0.2.0
  • github.com/buger/jsonparser v1.1.1
  • github.com/bytedance/sonic v1.10.2
  • github.com/cenkalti/backoff/v4 v4.2.1
  • github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d@296ad89f973d
  • github.com/chenzhuoyu/iasm v0.9.1
  • github.com/davecgh/go-spew v1.1.1
  • github.com/deepmap/oapi-codegen v1.15.0
  • github.com/fatih/structs v1.1.0
  • github.com/flosch/pongo2/v4 v4.0.2
  • github.com/gabriel-vasile/mimetype v1.4.3
  • github.com/ghodss/yaml v1.0.0
  • github.com/gin-contrib/sse v0.1.0
  • github.com/gin-gonic/gin v1.9.1
  • github.com/go-logr/logr v1.3.0
  • github.com/go-logr/stdr v1.2.2
  • github.com/go-playground/locales v0.14.1
  • github.com/go-playground/universal-translator v0.18.1
  • github.com/go-playground/validator/v10 v10.14.0
  • github.com/golang/protobuf v1.5.3
  • github.com/golang/snappy v0.0.4
  • github.com/gomarkdown/markdown v0.0.0-20231222211730-1d6d20845b47@1d6d20845b47
  • github.com/google/flatbuffers v23.5.26+incompatible
  • github.com/gorilla/css v1.0.1
  • github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0
  • github.com/inconshreveable/mousetrap v1.1.0
  • github.com/iris-contrib/schema v0.0.6
  • github.com/josharian/intern v1.0.0
  • github.com/json-iterator/go v1.1.12
  • github.com/kataras/blocks v0.0.8
  • github.com/kataras/golog v0.1.11
  • github.com/kataras/iris/v12 v12.2.10
  • github.com/kataras/pio v0.0.13
  • github.com/kataras/sitemap v0.0.6
  • github.com/kataras/tunnel v0.0.4
  • github.com/klauspost/compress v1.17.5
  • github.com/klauspost/cpuid/v2 v2.2.6
  • github.com/labstack/echo/v4 v4.11.4
  • github.com/labstack/gommon v0.4.2
  • github.com/leodido/go-urn v1.2.4
  • github.com/mailgun/raymond/v2 v2.0.48
  • github.com/mailru/easyjson v0.7.7
  • github.com/mattn/go-colorable v0.1.13
  • github.com/mattn/go-isatty v0.0.20
  • github.com/microcosm-cc/bluemonday v1.0.26
  • github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd@bacd9c7ef1dd
  • github.com/modern-go/reflect2 v1.0.2
  • github.com/pelletier/go-toml/v2 v2.0.8
  • github.com/pierrec/lz4/v4 v4.1.21
  • github.com/pmezard/go-difflib v1.0.0
  • github.com/russross/blackfriday/v2 v2.1.0
  • github.com/schollz/closestmatch v2.1.0+incompatible
  • github.com/sirupsen/logrus v1.9.3
  • github.com/spf13/pflag v1.0.5
  • github.com/tdewolff/minify/v2 v2.20.16
  • github.com/tdewolff/parse/v2 v2.7.11
  • github.com/twitchyliquid64/golang-asm v0.15.1
  • github.com/ugorji/go/codec v1.2.11
  • github.com/valyala/bytebufferpool v1.0.0
  • github.com/valyala/fasttemplate v1.2.2
  • github.com/vmihailenco/msgpack/v5 v5.4.1
  • github.com/vmihailenco/tagparser/v2 v2.0.0
  • github.com/wk8/go-ordered-map/v2 v2.1.8
  • github.com/yosssi/ace v0.0.5
  • github.com/zeebo/xxh3 v1.0.2
  • go.opentelemetry.io/otel/metric v1.20.0
  • go.opentelemetry.io/otel/trace v1.20.0
  • go.opentelemetry.io/proto/otlp v1.0.0
  • golang.org/x/arch v0.3.0
  • golang.org/x/crypto v0.18.0
  • golang.org/x/mod v0.14.0
  • golang.org/x/net v0.20.0
  • golang.org/x/sys v0.16.0
  • golang.org/x/time v0.5.0
  • golang.org/x/tools v0.17.0
  • golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028@104605ab7028
  • google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe@1f4bbc51befe
  • google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe@1f4bbc51befe
  • gopkg.in/ini.v1 v1.67.0
  • gopkg.in/yaml.v2 v2.4.0
  • gopkg.in/yaml.v3 v3.0.1
regex
.github/workflows/lint_golang.yml
  • golangci/golangci-lint v1.55.2
.github/workflows/lint_golang.yml
.github/workflows/unittest.yml
.github/workflows/lint_golang.yml
  • golangci/golangci-lint v1.55.2
.github/workflows/lint_golang.yml
.github/workflows/unittest.yml

Improve destination Read API

Currently we have Read API for destination plugins. This is mostly used by our testing framework.

One current issue is that in our testing we assume the order of read is the order of insertion but destination plugins don't have such requirements. We might need to change this API to read a specific ID rather then read everything by _cq_source_name column.

Other things to consider is potential future implementation of cursor where this might be needed.

Consider making column resolver a requirement

With the new template based codegen we generate PathResolver for all columns using field names, so extracting fields always works.

Also we still have the fallback of using ToPascal on the column name to try and extract values:

v := funk.Get(resource.Item, caser.ToPascal(c.Name), funk.WithAllowZero())

We've seen casing conversions can be hard to get quite right, and we can only catch such mistakes if we have unit/mock tests for all plugins and all tables.

Should we make column.Resolver mandatory? That way plugin authors must configure how data is extracted and we don't rely on a convention that only works some of the time

batch per tables

Describe the bug

Right now we implement batching in all plugins and this cause number of issues:

  1. batching is mostly implemented on a X resource basis and not per table. This will mean that if there is an issue in one table it can affect all others instead of affecting just a single one.

The solution to that will be implementing batching on the SDK level for destinations.

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/add_tags.yml
  • bcoe/conventional-release-labels v1
.github/workflows/issue_to_project.yml
  • leonsteinhaeuser/project-beta-automations v1.3.0
.github/workflows/lint_golang.yml
  • actions/checkout v3
  • actions/setup-go v3
  • golangci/golangci-lint-action v3
.github/workflows/pr_title.yml
  • amannn/action-semantic-pull-request v4
.github/workflows/release-pr.yml
  • google-github-actions/release-please-action v3
  • booxmedialtd/ws-action-parse-semver undefined
  • tubone24/update_release undefined
.github/workflows/unittest.yml
  • actions/setup-go v3
  • actions/checkout v3
  • actions/cache v3
  • actions/upload-artifact v3
gomod
go.mod
  • github.com/cloudquery/faker/v3 v3.7.7
  • github.com/ghodss/yaml v1.0.0
  • github.com/gofrs/uuid v4.2.0+incompatible
  • github.com/google/go-cmp v0.5.8
  • github.com/google/uuid v1.3.0
  • github.com/grpc-ecosystem/go-grpc-middleware/providers/zerolog/v2 v2.0.0-rc.2
  • github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.2
  • github.com/iancoleman/strcase v0.2.0
  • github.com/modern-go/reflect2 v1.0.2
  • github.com/rs/zerolog v1.28.0
  • github.com/spf13/cast v1.5.0
  • github.com/spf13/cobra v1.5.0
  • github.com/stretchr/testify v1.8.0
  • github.com/thoas/go-funk v0.9.2
  • github.com/xeipuuv/gojsonschema v1.2.0
  • golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde
  • golang.org/x/tools v0.1.12
  • google.golang.org/grpc v1.49.0
  • google.golang.org/protobuf v1.28.1
  • gopkg.in/yaml.v3 v3.0.1
regex
.github/workflows/lint_golang.yml
  • golangci/golangci-lint v1.47.3
.github/workflows/lint_golang.yml
  • go 1.18
.github/workflows/unittest.yml
  • go 1.18
.github/workflows/lint_golang.yml
  • golangci/golangci-lint v1.47.3
.github/workflows/lint_golang.yml
  • go 1.18
.github/workflows/unittest.yml
  • go 1.18

Fix additional newlines in markdown files

When generating markdown docs, we often get extra newlines that are hard to fix with Go templates themselves (while still handling all possible cases). The semantics of {{- and -}} seem too limited for this purpose.

I'm open to anyone trying to fix all the cases of unnecessary newlines using templating, but another idea is to rather run a post-processor (maybe a markdown formatter?) on the files to make them uniform. It might be as simple as replacing 3+ occurrences of \nwith \n\n.

feat: Provide a better error when someone references an env variable that doesn't exist

We support env variables resolution in our config, for example:

kind: destination
spec:
  name: postgresql
  version: v1.2.0
  spec:
    connection_string: ${CQ_DSN}

However if CQ_DSN is not configured we fail with a confusing error:

Loading spec(s) from examples
Error: failed to sync source azure: failed to initialize destination plugin client for postgresql: destination configure: failed to call Configure: rpc error: code = Unknown desc = failed to connect to postgresql: failed to connect to `host=/private/tmp user=<user> database=`: dial error (dial unix /private/tmp/.s.PGSQL.5432: connect: no such file or directory)
exit status 1

We should provide a clear error message in these cases

Resolver Context Timeout

Currently we expect all resources to resolve in less than 1 minute

ctx, cancel := context.WithTimeout(ctx, time.Minute)

I don't think that this is a large enough time value as we have already encountered 2 users that have resources that take longer than 1 minute to fully resolve.

I suggest that either we make this value much larger (like 10-20 minutes) and/or make it a configurable via the config file

Bug(config-windows): Putting multiple configurations in the same file doesn't work on Windows

Describe the bug

The following config:

kind: source
spec:
  name: aws
  version: v3.8.0
  destinations: [test,csv]
  path: cloudquery/aws
---
kind: destination
spec:
  name: test
  version: v1.2.11
  spec:
    connection_string: postgresql://postgres:pass@localhost:5432/postgres
---
kind: destination
spec:
  name: csv
  version: v1.0.0
  write_mode: append

Fails on Windows with the following error Error: expecting at least one destination

Expected Behavior

The above config should work on Windows

Steps to Reproduce

Run a sync on a Windows machine with the supplied configuration

Possible Solution

Probably related to how we split strings in

for _, doc := range strings.Split(string(data), "\n---\n") {

Provider and CloudQuery version

v1.5.5

Additional Context

No response

listAndValidateTables should not return child tables

listAndValidateTables can in some circumstances return child tables right now, and this will probably cause a panic. We should either disallow child tables from being listed in the config, or filter the child tables out before returning the list if their parents are included (or both)

See comment here for details: #339 (comment)_

Proposal: Use a dedicated `id` property instead of forcing a unique `name`

Background

To support overwrite-delete-stale we've added a constraint for plugins names to be unique.
Also as a result we're planning to make the path required, as to allow users to change the name.

Problem

I believe it's quite hard to communicate the reason name has to be unique, and easy for users to miss that requirement (also if users split their config across multiple machines we can't really validate it either).

Additionally since we're planning to make path required due to the uniqueness of name, it adds friction for people onboarding CloudQuery.

Proposal

Instead of making name unique we can add a dedicated id configuration (it can default to name) and use that instead.
As a result we can achieve the following:

  1. Keep the meaning of name and path the same
  2. Keep path optional, as we can resolve it from name
  3. Users that don't need to run CloudQuery in parallel don't need to know anything about uniqueness
  4. Easier to understand why an id property needs to be unique

TLDR: Only users that split their configuration (e.g. run in parallel) should care about having a unique identifier.

Refactor code related to flattenened tables

Flattened lists of tables have caused a few bugs now, because once they are returned it's hard to know what kind of list you are working with. Is it a flattened list or a normal list? Calling code that expects one but not the other can cause issues like tables getting traversed twice.

listAndValidateTables is one example of a function that returns a flattened list, and has so far been the main culprit

func (p *SourcePlugin) listAndValidateTables(tables, skipTables []string) (schema.Tables, error) {

Flattened lists of tables are useful, but we should clearly distinguish flattened lists of tables from normal top-level lists. My reading is that we currently only use flattened lists for two things:

  • getting the total number of tables
  • checking if a table is in the top-level list by using GetTopLevel

These two things can both be achieved by a "set" type. If listAndValidateTables returned an abstracted "set" type that hid its internals and exposed only two methods: Size() int and Contains(table) bool, most of the bugs we've had so far would have been avoided. I think we should try to refactor the code to work something along those lines, so that it is easier to reason about and harder to make mistakes.

feat(codegen): `codegen` should fail if column names clash (after adding extra columns, naturally)

type A struct {
    Abc string
}

If we feed struct A to codegen it will naturally produce column named abc.
If we add an extra column with the same name and forget to add filed Abc to be skipped, we end up with duplicate names in the resulting resource table.

Now, this will result in cloudquery CLI failing on the sync/init part as it checks for the data integrity then. There will be something like panic: found duplicate columns in source plugin: test: duplicate column abc in table test_resource.

The proposal is to add this check to codegen, too, so that such issues are highlighted during the development.

old docs should be romoved during docs generation

Describe the bug

When there are changes in table names, new doc files are added, but old files are not removed, which makes the GitHub action that checks docs fail.

Expected Behavior

remove all the files from destination directory before generating files

Steps to Reproduce

create table
generate docs
remove table
generate docs
run github action

Possible Solution

No response

Provider and CloudQuery version

Additional Context

No response

Should the SDK handle downloading plugins?

Looks like #208 moved the code that downloads plugins from the CLI to the SDK.

I'm not sure the SDK should be aware to how we structure our releases in the monorepo. We basically have a circular dependency now.

Also since we download plugins in the SDK, we lost the progress bar during download.
Also since our releases are a bit different on multiple OSes, we'll need to add cross platform tests for the SDK.

Relevant code in

func DownloadPluginFromGithub(ctx context.Context, localPath string, org string, name string, version string, typ PluginType, writers ...io.Writer) error {

Question: Should we be counting resources from relations under the total count?

We count the total number of resources including relations:

totalResources += rel.Resolve(ctx, meta, syncTime, resource, resolvedResources)

However when we print it we use the top level table name:

p.logger.Info().Str("table", table.Name).Int("total_resources", totalTableResources).TimeDiff("duration", time.Now(), tableStartTime).Msg("fetch table finished")

Which can be confusing as if the user takes the name of the table from the logs and run a count on the database, they might experience a different number of resources.

Should we only consider top level resources in the count? Maybe find a better way to print the count?

Use JSON schema to validate configuration

With #181, we use custom code to validate our configuration files.

We should consider using a JSON schema file and use a library to manage validation for us.

This should allow us to define the configuration in a declarative way.

Having a JSON schema should also allow code editors to auto complete configuration files based on the schema (though we shouldn't really think about this now)

Spec `Path` and `Registry` should not be a part of the JSON configuration

I think we can just expose Name with the following use cases:

# GitHub `cloudquery/azure`
name: azure

# GitHub `org/cq-plugin-datadog`
name: org/cq-plugin-datadog

# Local (notice value starts with `.`)
name: ./path-to-binary

# gRPC (notice value starts with http://)
name: http://localhost:7777

We should also consider dropping Local or gRPC as they serve the same purpose.

Internally we have still parse name into Path and Registry but it doesn't need to be a part of the configuration file

Are json fiels can't be marshaled from strings?

Describe the bug

Some fields of AWS resources like aws_route53_traffic_policy_versions have string fields that are actually JSONs, fields like policy documents.
The check here: https://github.com/cloudquery/plugin-sdk/blob/main/plugins/source_testing.go#L98-L101
does not allow to use strings.

Expected Behavior

allow string fields to be cased as json.

Steps to Reproduce

change string column type to json

Possible Solution

remove the check

Provider and CloudQuery version

9cd9dab30204baf96ea7e78ba130258cd190eb88

Additional Context

No response

feat: Add typing system

Currently we don't have a real typing system in CQ which is a pre-requirement to multiple destinations. There is wip in #298

Alot was discussed offline so sorry for the lack of details here in the issue.

feat: Return application level errors as a part of the gRPC response

TLDR: We should consider having application level errors as a part of the gRPC responses, to make it easier to identify them.

For example in the following line:

return fmt.Errorf("failed to CloseAndRecv client: %w", err)

failed to CloseAndRecv is not necessarily correct, as err is whatever is returned from the following function:
func (s *DestinationServer) Write2(msg pb.Destination_Write2Server) error {
.

Not sure what's the best solution (need to do some research), but we could add an error(s) field to gRPC responses so we have a clear separation between application level errors and gRPC/communication level ones.

Also due to grpc/grpc-go#2934 we can't unwrap errors.

Relations with PreResourceResolver parents are called with wrong parent

Describe the bug

If the parent has a PreResourceResolver defined, relations are called with the Resolver's output and not the "new item" from the PreResourceResolver.

This also works fine in mock tests as it should be, which is interesting.

Expected Behavior

Relation Resolver methods should be called with the result from the parent PreResourceResolver item as the parent.

Steps to Reproduce

Sentry issue SOURCE-AWS-A:

interface conversion: interface {} is types.KeyListEntry, not *types.KeyMetadata
goroutine 9995245 [running]:
runtime/debug.Stack()
	/opt/hostedtoolcache/go/1.19.2/x64/src/runtime/debug/stack.go:24 +0x65
github.com/cloudquery/plugin-sdk/plugins.(*SourcePlugin).resolveTableDfs.func1.1()
	/home/runner/go/pkg/mod/github.com/cloudquery/[email protected]/plugins/source_scheduler_dfs.go:77 +0x78
panic({0x776c700, 0xc07debab40})
	/opt/hostedtoolcache/go/1.19.2/x64/src/runtime/panic.go:884 +0x212
github.com/cloudquery/cloudquery/plugins/source/aws/resources/services/kms.fetchKmsKeyGrants({0x8a92270?, 0xc0008927b0?}, {0x89b9340?, 0xc06e902a80?}, 0x89b9340?, 0xc00030f600?)
	/home/runner/work/cloudquery/cloudquery/plugins/source/aws/resources/services/kms/key_grants_fetch.go:14 +0x3b8
github.com/cloudquery/plugin-sdk/plugins.(*SourcePlugin).resolveTableDfs.func1()
	/home/runner/go/pkg/mod/github.com/cloudquery/[email protected]/plugins/source_scheduler_dfs.go:87 +0xbb
created by github.com/cloudquery/plugin-sdk/plugins.(*SourcePlugin).resolveTableDfs
	/home/runner/go/pkg/mod/github.com/cloudquery/[email protected]/plugins/source_scheduler_dfs.go:74 +0x585

Fixing the key_grants_fetch.go to be:

	k := parent.Item.(*types.KeyListEntry)
	config := kms.ListGrantsInput{
		KeyId: k.KeyArn,

Should fix the problem temporarily, but it breaks the mock test in keys_mock_test.go. So the mock tests case works OK somehow.

Possible Solution

No response

Provider and CloudQuery version

4.14.0

Additional Context

No response

doc generation doesn't list relations of relations in index

Describe the bug

When generating docs from source plugin it is expected to see all resources (even highly-nested ones) in the index.
However, only the top-level resources + 1st-level relations are shown.

Expected Behavior

All nested resources are present in the index.

Steps to Reproduce

Generate doc from provider that has relation underneath a relation.

Possible Solution

No response

Provider and CloudQuery version

current

Additional Context

No response

feature: Support cursor-based syncing

It has come up a couple of times that it would be good for the SDK to support cursor-based syncing. For APIs that allow it, this would allow resources to be fetched once, with only updates being fetched after the first sync. For some resource types, this optimization would be a significant performance boost.

This would be especially useful in cases where the APIs allow for time-based querying, and it is known that resources never change once they are created (like logs, reports, audit trails).

One concrete example where this would be beneficial is the Heroku audit trail event: https://devcenter.heroku.com/articles/platform-api-reference#audit-trail-event . It allows querying by day, so an optimized implementation would only fetch historical days the first time, then in subsequent runs fetch the days that have been added since the previous sync.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: *.yml
Error type: Invalid regular expression: *.yml

Change Caser Public API to Go standard API

Currently Caser using globals and not providing any way of adding options and expanding the api.

This is a heavily used public API that we need change asap to avoid breakage across all official and soon community plugins (I think yandex already uses those.)

Should follow the standard

New(required_options, ...CaserOption) pattern

Discussion: Dep update strategy

I think we should discuss how we want to do dep update. having a PR for every dep is quite heavy imo and create burden (at least emotionally for me :) ).

I think if we have one PR with all deps (I think we have in our main repo) can be a better approach and maybe run the dep checks once a month should be fine or once a week, and we can go through this and decide what we want to update and what not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.