segmentio / topicctl

Tool for declarative management of Kafka topics
MIT License
590 stars 55 forks source link

delete topic #163

Open petedannemann opened 11 months ago

petedannemann commented 11 months ago

Repl has been set to read only mode to prevent accidental deletes, configurable through CLI flag.

Delete operation must be confirmed with a yes/no

Finishing up the great work started in https://github.com/segmentio/topicctl/pull/100

Functional test / demo:

$ go run cmd/topicctl/main.go delete
Deletes instances of a particular type.

Usage:
  topicctl delete [command]

Available Commands:
  topic       Delete a topic

Flags:
  -b, --broker-addr string       Broker address
      --cluster-config string    Cluster config
      --expand-env               Expand environment in cluster config
  -h, --help                     help for delete
      --sasl-mechanism string    SASL mechanism if using SASL (choices: AWS-MSK-IAM, PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512)
      --sasl-password string     SASL password if using SASL; will override value set in cluster config
      --sasl-username string     SASL username if using SASL; will override value set in cluster config
      --tls-ca-cert string       Path to client CA cert PEM file if using TLS
      --tls-cert string          Path to client cert PEM file if using TLS
      --tls-enabled              Use TLS for communication with brokers
      --tls-key string           Path to client private key PEM file if using TLS
      --tls-server-name string   Server name to use for TLS cert verification
      --tls-skip-verify          Skip hostname verification when using TLS
  -z, --zk-addr string           ZooKeeper address
      --zk-prefix string         Prefix for cluster-related nodes in zk

Global Flags:
      --debug        enable debug logging
      --no-spinner   disable all UI spinners

Use "topicctl delete [command] --help" for more information about a command.

$ go run cmd/topicctl/main.go get topics --cluster-config examples/local-cluster/cluster.yaml
[2023-11-09 10:41:13]  INFO Topics:
-----------------+------------+-------------+-----------+------------
       NAME      | PARTITIONS | REPLICATION | RETENTION |   RACKS
                 |            |             |   MINS    | (MIN,MAX)
-----------------+------------+-------------+-----------+------------
  topic-default  | 3          | 2           | 100       | (1,1)
  topic-in-rack3 | 9          | 2           | 100       | (1,1)
  topic-static   | 10         | 2           | 290       | (1,2)
-----------------+------------+-------------+-----------+-----------

$ go run cmd/topicctl/main.go delete topic topic-default --cluster-config examples/local-cluster/cluster.yaml
[2023-11-09 10:41:47]  INFO Checking if topic topic-default exists...
[2023-11-09 10:41:47]  INFO Topic topic-default exists in the cluster!
Delete topic "topic-default" (yes/no) yes
[2023-11-09 10:41:51]  INFO Topic topic-default successfully deleted

$ go run cmd/topicctl/main.go get topics --cluster-config examples/local-cluster/cluster.yaml
[2023-11-09 10:41:56]  INFO Topics:
-----------------+------------+-------------+-----------+------------
       NAME      | PARTITIONS | REPLICATION | RETENTION |   RACKS
                 |            |             |   MINS    | (MIN,MAX)
-----------------+------------+-------------+-----------+------------
  topic-in-rack3 | 9          | 2           | 100       | (1,1)
  topic-static   | 10         | 2           | 290       | (1,2)
-----------------+------------+-------------+-----------+------------
silvadenisaraujo commented 9 months ago

Any chances to keep pushing here @petedannemann ? Looks like it's almost there 🔥

isaacd9 commented 7 months ago

Is there anything blocking merging this? It'd be a huge help in my deployment.

mvfolino68 commented 4 months ago

@petedannemann, checking in on the status of this to see if it's something that you're considering merging.