Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/history_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
CQ_NO_TELEMETRY: 1

- name: Sanity Drop
run: go run ./main.go provider drop test --config=internal/test/test_history_config.hcl
run: go run ./main.go provider drop test --config=internal/test/test_history_config.hcl --force
env:
CQ_NO_TELEMETRY: 1

Expand Down
12 changes: 9 additions & 3 deletions cmd/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package cmd

import (
"context"
"fmt"
"time"

"github.com/cloudquery/cloudquery/pkg/client"
"github.com/cloudquery/cloudquery/pkg/ui"
"github.com/cloudquery/cloudquery/pkg/ui/console"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -56,14 +56,19 @@ var (
}),
}

providerForce bool
providerDropHelpMsg = "Drops provider schema from database"
providerDropCmd = &cobra.Command{
Use: "drop [provider]",
Short: providerDropHelpMsg,
Long: providerDropHelpMsg,
Args: cobra.ExactArgs(1),
Run: handleCommand(func(ctx context.Context, c *console.Client, cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return fmt.Errorf("missing provider name")
if !providerForce {
ui.ColorizedOutput(ui.ColorWarning, "WARNING! This will drop all tables for the given provider. If you wish to continue, use the --force flag.\n")
return &console.ExitCodeError{
ExitCode: 1,
}
}
_ = c.DropProvider(ctx, args[0])
return nil
Expand Down Expand Up @@ -117,6 +122,7 @@ func init() {
"last-update is the duration from current time we want to remove resources from the database. "+
"For example 24h will remove all resources that were not update in last 24 hours. Duration is a string with optional unit suffix such as \"2h45m\" or \"7d\"")
providerRemoveStaleCmd.Flags().BoolVar(&dryRun, "dry-run", true, "")
providerDropCmd.Flags().BoolVar(&providerForce, "force", false, "Really drop tables for the provider")
providerCmd.AddCommand(providerDownloadCmd, providerUpgradeCmd, providerDowngradeCmd, providerDropCmd, providerBuildSchemaCmd, providerRemoveStaleCmd)
rootCmd.AddCommand(providerCmd)
}