From a4dab2a0752e1532a8aed39b319e3cd692512a13 Mon Sep 17 00:00:00 2001 From: Leonardo Di Donato Date: Thu, 22 Nov 2018 21:20:06 +0100 Subject: [PATCH] feat(pkg/cmd): delete subcommand --- pkg/cmd/delete.go | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 pkg/cmd/delete.go diff --git a/pkg/cmd/delete.go b/pkg/cmd/delete.go new file mode 100644 index 00000000..af23ed7c --- /dev/null +++ b/pkg/cmd/delete.go @@ -0,0 +1,53 @@ +package cmd + +import ( + "fmt" + + "github.com/davecgh/go-spew/spew" + "github.com/spf13/cobra" + "k8s.io/cli-runtime/pkg/genericclioptions" + // "k8s.io/kubernetes/pkg/kubectl/util/templates" +) + +var ( + deleteShort = `Delete a bpftrace program execution` // Wrap with i18n.T() + deleteLong = ` +...` + + deleteExamples = ` + # Delete a specific bpftrace program + %[1]s trace delete k656ee75a-ee3c-11e8-9e7a-8c164500a77e + + # Delete all bpftrace programs in a specific namespace + %[1]s trace delete -n myns"` +) + +// DeleteOptions ... +type DeleteOptions struct { + genericclioptions.IOStreams +} + +// NewDeleteOptions provides an instance of DeleteOptions with default values. +func NewDeleteOptions(streams genericclioptions.IOStreams) *DeleteOptions { + return &DeleteOptions{ + IOStreams: streams, + } +} + +// NewDeleteCommand provides the delete command wrapping DeleteOptions. +func NewDeleteCommand(streams genericclioptions.IOStreams) *cobra.Command { + o := NewDeleteOptions(streams) + + cmd := &cobra.Command{ + Use: "delete TRACE_ID", + Short: deleteShort, + Long: deleteLong, // Wrap with templates.LongDesc() + Example: fmt.Sprintf(deleteExamples, "kubectl"), // Wrap with templates.Examples() + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("delete") + spew.Dump(o) + }, + } + + return cmd +}