From 68d195495ecad21458c2bd2441d0c8e80fabe7eb Mon Sep 17 00:00:00 2001 From: Shlok Chaudhari Date: Wed, 31 Jul 2024 12:26:41 -0500 Subject: [PATCH] Renaming "./kubestr browse" command to "./kubestr browse pvc" (#275) * Adding the kubestr browse pvc command. Handling kubestr browse support for backward compatibility. * Adding Deprecated msg to the 'browse' command * Updating Deprecated msg for 'browse' command * Making namespace, runAsUser & localport flags persistent --- cmd/rootCmd.go | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/cmd/rootCmd.go b/cmd/rootCmd.go index 8855912..4f36fd7 100644 --- a/cmd/rootCmd.go +++ b/cmd/rootCmd.go @@ -83,9 +83,20 @@ var ( }, } - pvcBrowseLocalPort int - pvcBrowseCmd = &cobra.Command{ - Use: "browse [PVC name]", + browseLocalPort int + browseCmd = &cobra.Command{ + Use: "browse", + Short: "Browse the contents of PVC or VolumeSnapshot", + Long: "Browse the contents of a CSI provisioned PVC or a CSI provisioned VolumeSnapshot.", + Deprecated: "use 'browse pvc' instead", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + return browsePvcCmd.RunE(cmd, args) + }, + } + + browsePvcCmd = &cobra.Command{ + Use: "pvc [PVC name]", Short: "Browse the contents of a CSI PVC via file browser", Long: "Browse the contents of a CSI provisioned PVC by cloning the volume and mounting it with a file browser.", Args: cobra.ExactArgs(1), @@ -94,7 +105,7 @@ var ( namespace, csiCheckVolumeSnapshotClass, csiCheckRunAsUser, - pvcBrowseLocalPort, + browseLocalPort, ) }, } @@ -164,12 +175,16 @@ func init() { csiCheckCmd.Flags().Int64VarP(&csiCheckRunAsUser, "runAsUser", "u", 0, "Runs the CSI check pod with the specified user ID (int)") csiCheckCmd.Flags().BoolVarP(&csiCheckSkipCFSCheck, "skipCFScheck", "k", false, "Use this flag to skip validating the ability to clone a snapshot.") - rootCmd.AddCommand(pvcBrowseCmd) - pvcBrowseCmd.Flags().StringVarP(&csiCheckVolumeSnapshotClass, "volumesnapshotclass", "v", "", "The name of a VolumeSnapshotClass. (Required)") - _ = pvcBrowseCmd.MarkFlagRequired("volumesnapshotclass") - pvcBrowseCmd.Flags().StringVarP(&namespace, "namespace", "n", fio.DefaultNS, "The namespace of the PersistentVolumeClaim.") - pvcBrowseCmd.Flags().Int64VarP(&csiCheckRunAsUser, "runAsUser", "u", 0, "Runs the inspector pod as a user (int)") - pvcBrowseCmd.Flags().IntVarP(&pvcBrowseLocalPort, "localport", "l", 8080, "The local port to expose the inspector") + rootCmd.AddCommand(browseCmd) + browseCmd.Flags().StringVarP(&csiCheckVolumeSnapshotClass, "volumesnapshotclass", "v", "", "The name of a VolumeSnapshotClass. (Required)") + _ = browseCmd.MarkFlagRequired("volumesnapshotclass") + browseCmd.PersistentFlags().StringVarP(&namespace, "namespace", "n", fio.DefaultNS, "The namespace of the PersistentVolumeClaim.") + browseCmd.PersistentFlags().Int64VarP(&csiCheckRunAsUser, "runAsUser", "u", 0, "Runs the inspector pod as a user (int)") + browseCmd.PersistentFlags().IntVarP(&browseLocalPort, "localport", "l", 8080, "The local port to expose the inspector") + + browseCmd.AddCommand(browsePvcCmd) + browsePvcCmd.Flags().StringVarP(&csiCheckVolumeSnapshotClass, "volumesnapshotclass", "v", "", "The name of a VolumeSnapshotClass. (Required)") + _ = browsePvcCmd.MarkFlagRequired("volumesnapshotclass") rootCmd.AddCommand(blockMountCmd) blockMountCmd.Flags().StringVarP(&storageClass, "storageclass", "s", "", "The name of a Storageclass. (Required)")