MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / sync

Function sync

cli/cmd/sync.go:177–572  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

175}
176
177func sync(cmd *cobra.Command, args []string) error {
178 cqDir, err := cmd.Flags().GetString("cq-dir")
179 if err != nil {
180 return err
181 }
182
183 noMigrate, err := cmd.Flags().GetBool("no-migrate")
184 if err != nil {
185 return err
186 }
187
188 licenseFile, err := cmd.Flags().GetString("license")
189 if err != nil {
190 return err
191 }
192
193 shard, err := parseShard(cmd)
194 if err != nil {
195 return err
196 }
197
198 cqColumnsNotNull, err := cmd.Flags().GetBool("cq-columns-not-null")
199 if err != nil {
200 return err
201 }
202
203 // in the cloud sync environment, we pass only the relevant environment variables to the plugin
204 isolatePluginEnvironment := env.IsCloud()
205
206 ctx := cmd.Context()
207 log.Info().Strs("args", args).Msg("Loading spec(s)")
208 fmt.Printf("Loading spec(s) from %s\n", strings.Join(args, ", "))
209 // Validate after injection so a source-only spec isn't rejected before the
210 // platform destination is added.
211 specReader, err := specs.NewSpecReaderWithoutValidation(args)
212 if err != nil {
213 return fmt.Errorf("failed to load spec(s) from %s. Error: %w", strings.Join(args, ", "), err)
214 }
215
216 sources := specReader.Sources
217 destinations := specReader.Destinations
218 transformers := specReader.Transformers
219
220 tableMetricsLocation, err := cmd.Flags().GetString("tables-metrics-location")
221 if err != nil {
222 return err
223 }
224
225 summaryLocation, err := cmd.Flags().GetString("summary-location")
226 if err != nil {
227 return err
228 }
229
230 var otelReceiver *otel.OtelReceiver
231
232 // dlToken/teamName authenticate plugin download + usage against cloud
233 // (headless cqpd_ token, else cloud login). See cqplatform.DownloadAuth.
234 dlToken, teamName, err := cqplatform.DownloadAuth(ctx, log.Logger, sources, destinations, transformers)

Callers 1

newAirtablePluginFunction · 0.85

Calls 15

ShutdownMethod · 0.95
parseShardFunction · 0.85
SpecRegistryToPluginFunction · 0.85
filterPluginEnvFunction · 0.85
enrichClientErrorFunction · 0.85
findMaxCommonVersionFunction · 0.85
syncConnectionV3Function · 0.85
syncConnectionV2Function · 0.85
syncConnectionV1Function · 0.85
PrintfMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected