writePlatformSourceOnlySpec scaffolds a source-only spec for a user with a CloudQuery Platform tenant: no destination block, since the CLI auto-injects the `platform` destination at sync time. It wires the source to that reserved destination name and tells the user where the data will land.
(apiClient *cqapi.ClientWithResponses, sourcePlugin cqapi.ListPlugin, specPath, platformURL string)
| 271 | // the `platform` destination at sync time. It wires the source to that reserved |
| 272 | // destination name and tells the user where the data will land. |
| 273 | func writePlatformSourceOnlySpec(apiClient *cqapi.ClientWithResponses, sourcePlugin cqapi.ListPlugin, specPath, platformURL string) error { |
| 274 | fmt.Printf("Getting configuration for source plugin %s...\n", bold.Sprintf("%s/%s@%s", sourcePlugin.TeamName, sourcePlugin.Name, *sourcePlugin.LatestVersion)) |
| 275 | sourceVersion, err := api.GetPluginVersion(apiClient, sourcePlugin.TeamName, sourcePlugin.Kind, sourcePlugin.Name, *sourcePlugin.LatestVersion) |
| 276 | if err != nil { |
| 277 | return fmt.Errorf("failed to get source plugin %s/%s@%s version %w", sourcePlugin.TeamName, sourcePlugin.Name, *sourcePlugin.LatestVersion, err) |
| 278 | } |
| 279 | |
| 280 | if specPath == "" { |
| 281 | specPath = sourcePlugin.Name + "_to_platform.yaml" |
| 282 | } |
| 283 | fmt.Printf("Writing spec to %s...\n", bold.Sprint(specPath)) |
| 284 | // Wire the source to the reserved `platform` destination name; the CLI adds |
| 285 | // the destination itself at sync time, so no destination block is written. |
| 286 | sourceConfig := configForSourcePlugin(sourcePlugin, sourceVersion) |
| 287 | yamlSpec := strings.ReplaceAll(sourceConfig, "DESTINATION_NAME", "platform") |
| 288 | if err := os.WriteFile(specPath, []byte(yamlSpec), 0644); err != nil { |
| 289 | return fmt.Errorf("failed to write spec file %w", err) |
| 290 | } |
| 291 | |
| 292 | successful.Println("Sync spec file generated successfully!") |
| 293 | fmt.Println() |
| 294 | fmt.Printf("This sync will write to your CloudQuery Platform at %s\n", bold.Sprint(platformURL)) |
| 295 | fmt.Println() |
| 296 | fmt.Println("Next steps:") |
| 297 | fmt.Printf("1. Review %s and fill in the source's authentication details:\n", bold.Sprint(specPath)) |
| 298 | fmt.Printf(" %s: %s\n", bold.Sprint(sourcePlugin.DisplayName), linkForPlugin(sourcePlugin)) |
| 299 | fmt.Println("2. Run the sync:") |
| 300 | bold.Printf("cloudquery sync %s\n", specPath) |
| 301 | return nil |
| 302 | } |
| 303 | |
| 304 | func initCmd(cmd *cobra.Command, args []string) (initCommandError error) { |
| 305 | ctx := cmd.Context() |
no test coverage detected