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

Function migrate

cli/cmd/migrate.go:40–236  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

38}
39
40func migrate(cmd *cobra.Command, args []string) error {
41 cqDir, err := cmd.Flags().GetString("cq-dir")
42 if err != nil {
43 return err
44 }
45
46 licenseFile, err := cmd.Flags().GetString("license")
47 if err != nil {
48 return err
49 }
50
51 cqColumnsNotNull, err := cmd.Flags().GetBool("cq-columns-not-null")
52 if err != nil {
53 return err
54 }
55
56 ctx := cmd.Context()
57 log.Info().Strs("args", args).Msg("Loading spec(s)")
58 fmt.Printf("Loading spec(s) from %s\n", strings.Join(args, ", "))
59 specReader, err := specs.NewSpecReader(args)
60 if err != nil {
61 return fmt.Errorf("failed to load spec(s) from %s. Error: %w", strings.Join(args, ", "), err)
62 }
63 sources := specReader.Sources
64 destinations := specReader.Destinations
65 transformers := specReader.Transformers
66
67 transformerSpecsByName := make(map[string]specs.Transformer)
68 for _, transformer := range transformers {
69 transformerSpecsByName[transformer.Name] = *transformer
70 }
71
72 // dlToken/teamName authenticate plugin download against cloud (headless
73 // cqpd_ token, else cloud login). See cqplatform.DownloadAuth.
74 dlToken, teamName, err := cqplatform.DownloadAuth(ctx, log.Logger, sources, destinations, transformers)
75 if err != nil {
76 return err
77 }
78 // Headless cqpd_: let plugins authenticate premium-table validation + usage
79 // against cloud (they read CLOUDQUERY_API_KEY from their inherited env).
80 cqplatform.PropagatePluginCredential(dlToken)
81
82 pluginVersionWarner, _ := managedplugin.NewPluginVersionWarner(log.Logger, dlToken)
83 specs.WarnOnOutdatedVersions(ctx, pluginVersionWarner, sources, destinations, transformers)
84
85 opts := []managedplugin.Option{
86 managedplugin.WithLogger(log.Logger),
87 managedplugin.WithAuthToken(dlToken),
88 managedplugin.WithTeamName(teamName),
89 managedplugin.WithLicenseFile(licenseFile),
90 }
91 if logConsole {
92 opts = append(opts, managedplugin.WithNoProgress())
93 }
94 if cqDir != "" {
95 opts = append(opts, managedplugin.WithDirectory(cqDir))
96 }
97 if disableSentry {

Callers

nothing calls this directly

Calls 11

SpecRegistryToPluginFunction · 0.85
enrichClientErrorFunction · 0.85
findMaxCommonVersionFunction · 0.85
migrateConnectionV3Function · 0.85
migrateConnectionV2Function · 0.85
migrateConnectionV1Function · 0.85
PrintfMethod · 0.80
ErrorfMethod · 0.80
RegistryInferredMethod · 0.80
PrintlnMethod · 0.80
ContextMethod · 0.45

Tested by

no test coverage detected