From 7ba4f75935f9e8579c5bb9a829c4ceea315ad61a Mon Sep 17 00:00:00 2001 From: CloudQuery Bot <102256036+cq-bot@users.noreply.github.com> Date: Tue, 4 Oct 2022 17:39:51 +0300 Subject: [PATCH 1/3] chore: Update CLI version to v1.0.2 (#2388) Updates the CLI latest version to v1.0.2 --- sites/versions/v2/cli.json | 2 +- sites/versions/vercel.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sites/versions/v2/cli.json b/sites/versions/v2/cli.json index c212f93c215e58..e109d5c107df37 100644 --- a/sites/versions/v2/cli.json +++ b/sites/versions/v2/cli.json @@ -1 +1 @@ -{ "latest": "cli-v1.0.1" } +{ "latest": "cli-v1.0.2" } diff --git a/sites/versions/vercel.json b/sites/versions/vercel.json index 1222ddfd51b9ea..af36021565d337 100644 --- a/sites/versions/vercel.json +++ b/sites/versions/vercel.json @@ -6,7 +6,7 @@ { "source": "/latest/v1/:binary", "permanent": false, - "destination": "https://github.com/cloudquery/cloudquery/releases/download/cli-v1.0.1/:binary" + "destination": "https://github.com/cloudquery/cloudquery/releases/download/cli-v1.0.2/:binary" } ] } From f3335a8a1f71fb519628bc3721b8299ff133b824 Mon Sep 17 00:00:00 2001 From: Herman Schaaf Date: Tue, 4 Oct 2022 16:24:58 +0100 Subject: [PATCH 2/3] fix: Add back missing plugin logs (#2389) This fixes an issue where plugin logs were not being streamed to `cloudquery.log`. It also adds a test for this to catch future regressions. --- cli/cmd/sync.go | 19 ++++++++++++++++--- cli/cmd/sync_test.go | 15 +++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/cli/cmd/sync.go b/cli/cmd/sync.go index b2b10e1c08c92a..db4dc466955732 100644 --- a/cli/cmd/sync.go +++ b/cli/cmd/sync.go @@ -37,10 +37,11 @@ func NewCmdSync() *cobra.Command { func sync(cmd *cobra.Command, args []string) error { ctx := cmd.Context() - + log.Info().Strs("args", args).Msg("Loading spec(s)") fmt.Printf("Loading spec(s) from %s\n", strings.Join(args, ", ")) specReader, err := specs.NewSpecReader(args) if err != nil { + log.Error().Strs("args", args).Err(err).Msg("Failed to load spec(s)") return fmt.Errorf("failed to load spec(s) from %s. Error: %w", strings.Join(args, ", "), err) } @@ -65,8 +66,18 @@ func sync(cmd *cobra.Command, args []string) error { } func syncConnection(ctx context.Context, sourceSpec specs.Source, destinationsSpecs []specs.Destination) error { + destinationNames := make([]string, len(destinationsSpecs)) + for i := range destinationsSpecs { + destinationNames[i] = destinationsSpecs[i].Name + } syncTime := time.Now().UTC() - sourceClient, err := clients.NewSourceClient(ctx, sourceSpec.Registry, sourceSpec.Path, sourceSpec.Version) + + log.Info().Str("source", sourceSpec.Name).Strs("destinations", destinationNames).Time("sync_time", syncTime).Msg("Start sync") + defer log.Info().Str("source", sourceSpec.Name).Strs("destinations", destinationNames).Time("sync_time", syncTime).Msg("End sync") + + sourceClient, err := clients.NewSourceClient(ctx, sourceSpec.Registry, sourceSpec.Path, sourceSpec.Version, + clients.WithSourceLogger(log.Logger), + ) if err != nil { return fmt.Errorf("failed to get source plugin client for %s: %w", sourceSpec.Name, err) } @@ -91,7 +102,9 @@ func syncConnection(ctx context.Context, sourceSpec specs.Source, destinationsSp } }() for i, destinationSpec := range destinationsSpecs { - destClients[i], err = clients.NewDestinationClient(ctx, destinationSpec.Registry, destinationSpec.Path, destinationSpec.Version) + destClients[i], err = clients.NewDestinationClient(ctx, destinationSpec.Registry, destinationSpec.Path, destinationSpec.Version, + clients.WithDestinationLogger(log.Logger), + ) if err != nil { return fmt.Errorf("failed to create destination plugin client for %s: %w", destinationSpec.Name, err) } diff --git a/cli/cmd/sync_test.go b/cli/cmd/sync_test.go index 62f2ad483d1885..4691c733dbda35 100644 --- a/cli/cmd/sync_test.go +++ b/cli/cmd/sync_test.go @@ -1,12 +1,17 @@ package cmd import ( + "os" "path" "runtime" "testing" ) func TestSync(t *testing.T) { + t.Cleanup(func() { + os.RemoveAll("cloudquery.log") + }) + // this works but some funny stuff is going on _, filename, _, _ := runtime.Caller(0) currentDir := path.Dir(filename) @@ -16,4 +21,14 @@ func TestSync(t *testing.T) { if err := cmd.Execute(); err != nil { t.Fatal(err) } + + // check that log was written and contains some lines from the plugin + b, err := os.ReadFile("cloudquery.log") + if err != nil { + t.Fatal("failed to read cloudquery.log:", err) + } + content := string(b) + if len(content) == 0 { + t.Fatalf("cloudquery.log empty; expected some logs") + } } From cc3601b9a6f6d6ce77edc80152e6ccd3b0a3cc9d Mon Sep 17 00:00:00 2001 From: CloudQuery Bot <102256036+cq-bot@users.noreply.github.com> Date: Tue, 4 Oct 2022 18:32:20 +0300 Subject: [PATCH 3/3] chore(main): Release cli v1.0.3 (#2390) :robot: I have created a release *beep* *boop* --- ## [1.0.3](https://github.com/cloudquery/cloudquery/compare/cli-v1.0.2...cli-v1.0.3) (2022-10-04) ### Bug Fixes * Add back missing plugin logs ([#2389](https://github.com/cloudquery/cloudquery/issues/2389)) ([f3335a8](https://github.com/cloudquery/cloudquery/commit/f3335a8a1f71fb519628bc3721b8299ff133b824)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- .release-please-manifest.json | 2 +- cli/CHANGELOG.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fffa4c77069630..179c706a8d5346 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,5 @@ { - "cli": "1.0.2", + "cli": "1.0.3", "cli+FILLER": "0.0.0", "plugins/source/aws": "1.0.1", "plugins/source/aws+FILLER": "0.0.0", diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index eee39ce0163779..bf1f200e03fd69 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to CloudQuery will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.3](https://github.com/cloudquery/cloudquery/compare/cli-v1.0.2...cli-v1.0.3) (2022-10-04) + + +### Bug Fixes + +* Add back missing plugin logs ([#2389](https://github.com/cloudquery/cloudquery/issues/2389)) ([f3335a8](https://github.com/cloudquery/cloudquery/commit/f3335a8a1f71fb519628bc3721b8299ff133b824)) + ## [1.0.2](https://github.com/cloudquery/cloudquery/compare/cli-v1.0.1...cli-v1.0.2) (2022-10-04)