Repository: microsoft/retina
File: cli/cmd/capture/create.go (Go)

Code before:
	DefaultNowait          bool          = true
	DefaultPacketSize      int           = 0
	DefaultS3Path          string        = "retina/captures"
	DefaultWaitPeriod      time.Duration = 1 * time.Minute
	DefaultWaitTimeout     time.Duration = 5 * time.Minute
	DefaultAllInterfaces   bool          = true
)

var createExample = templates.Examples(i18n.T(`
		# Select nodes by node name and copy the artifacts to the node host path
		kubectl retina capture create --host-path /mnt/retina/testcapture --node-names "<nodename1>,<nodename2>"

		# Select pods determined by pod-selectors and namespace-selectors
		kubectl retina capture create --namespace capture --pod-selectors="k8s-app=kube-dns" --namespace-selectors="kubernetes.io/metadata.name=kube-system"

		# Select nodes with label "agentpool=agentpool" and "version:v20"
		kubectl retina capture create --node-selectors="agentpool=agentpool,version:v20"

		# Select nodes using node-selector and set duration to 10s
		kubectl retina capture create --node-selectors="agentpool=agentpool" --duration=10s

		# Capture on specific network interfaces (instead of all interfaces)
		kubectl retina capture create --node-selectors="agentpool=agentpool" --interface="eth0,eth1"

		# Disable capturing on all interfaces (uses first available interface)
		kubectl retina capture create --node-selectors="agentpool=agentpool" --all-interfaces=false

		# Select nodes using node-selector and upload the artifacts to blob storage with SAS URL https://testaccount.blob.core.windows.net/<token>
		kubectl retina capture create --node-selectors="agentpool=agentpool" --blob-upload=https://testaccount.blob.core.windows.net/<token>

		# Select nodes using node-selector and upload the artifacts to AWS S3
		kubectl retina capture create --node-selectors="agentpool=agentpool" \
			--s3-bucket "your-bucket-name" \
			--s3-region "eu-central-1"\
			--s3-access-key-id "your-access-key-id" \
			--s3-secret-access-key "your-secret-access-key"

		# Select nodes using node-selector and upload the artifacts to S3-compatible service (like MinIO)
		kubectl retina capture create --node-selectors="agentpool=agentpool" \
			--s3-bucket "your-bucket-name" \
			--s3-endpoint "https://play.min.io:9000" \
			--s3-access-key-id "your-access-key-id" \
			--s3-secret-access-key "your-secret-access-key"
		`))

var createCapture = &cobra.Command{
	Use:     "create",
	Short:   "Create a Retina Capture",
	Example: createExample,
	RunE: func(*cobra.Command, []string) error {
		kubeConfig, err := opts.ToRESTConfig()

Review comment (suggestion):
I want the user experience to be this

`kubectl retina capture create --node-selectors="agentpool=agentpool"`

and then this will use the `-i any` to capture on all interfaces on linux/unix nodes by default

the alternate user experience is this

`kubectl retina capture create --node-selectors="agentpool=agentpool" --interfaces="eth0,eth1"`

and then this command will use those user specified interfaces
 

Code after:
	DefaultNowait          bool          = true
	DefaultPacketSize      int           = 0
	DefaultS3Path          string        = "retina/captures"
	DefaultWaitPeriod      time.Duration = 1 * time.Minute
	DefaultWaitTimeout     time.Duration = 5 * time.Minute
)

var createExample = templates.Examples(i18n.T(`
		# Select nodes by node name and copy the artifacts to the node host path
		kubectl retina capture create --host-path /mnt/retina/testcapture --node-names "<nodename1>,<nodename2>"

		# Select pods determined by pod-selectors and namespace-selectors
		kubectl retina capture create --namespace capture --pod-selectors="k8s-app=kube-dns" --namespace-selectors="kubernetes.io/metadata.name=kube-system"

		# Select nodes with label "agentpool=agentpool" and "version:v20"
		kubectl retina capture create --node-selectors="agentpool=agentpool,version:v20"

		# Select nodes using node-selector and set duration to 10s
		kubectl retina capture create --node-selectors="agentpool=agentpool" --duration=10s

		# Capture on specific network interfaces (instead of all interfaces)
		kubectl retina capture create --node-selectors="agentpool=agentpool" --interfaces="eth0,eth1"

		# Select nodes using node-selector and upload the artifacts to blob storage with SAS URL https://testaccount.blob.core.windows.net/<token>
		kubectl retina capture create --node-selectors="agentpool=agentpool" --blob-upload=https://testaccount.blob.core.windows.net/<token>

		# Select nodes using node-selector and upload the artifacts to AWS S3
		kubectl retina capture create --node-selectors="agentpool=agentpool" \
			--s3-bucket "your-bucket-name" \
			--s3-region "eu-central-1"\
			--s3-access-key-id "your-access-key-id" \
			--s3-secret-access-key "your-secret-access-key"

		# Select nodes using node-selector and upload the artifacts to S3-compatible service (like MinIO)
		kubectl retina capture create --node-selectors="agentpool=agentpool" \
			--s3-bucket "your-bucket-name" \
			--s3-endpoint "https://play.min.io:9000" \
			--s3-access-key-id "your-access-key-id" \
			--s3-secret-access-key "your-secret-access-key"
		`))

var createCapture = &cobra.Command{
	Use:     "create",
	Short:   "Create a Retina Capture",
	Example: createExample,
	RunE: func(*cobra.Command, []string) error {
		kubeConfig, err := opts.ToRESTConfig()
		if err != nil {
			return errors.Wrap(err, "failed to compose k8s rest config")
		}