From 36882b59f48431fbb8f5a7e2400ec554795fd6f2 Mon Sep 17 00:00:00 2001 From: Shlok Chaudhari Date: Wed, 24 Jul 2024 14:42:33 -0500 Subject: [PATCH 1/4] Adding the kubestr browse pvc command. Handling kubestr browse support for backward compatibility. --- cmd/rootCmd.go | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/cmd/rootCmd.go b/cmd/rootCmd.go index 8855912..4086252 100644 --- a/cmd/rootCmd.go +++ b/cmd/rootCmd.go @@ -83,9 +83,19 @@ 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.", + 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 +104,7 @@ var ( namespace, csiCheckVolumeSnapshotClass, csiCheckRunAsUser, - pvcBrowseLocalPort, + browseLocalPort, ) }, } @@ -164,12 +174,19 @@ 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.Flags().StringVarP(&namespace, "namespace", "n", fio.DefaultNS, "The namespace of the PersistentVolumeClaim.") + browseCmd.Flags().Int64VarP(&csiCheckRunAsUser, "runAsUser", "u", 0, "Runs the inspector pod as a user (int)") + browseCmd.Flags().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") + browsePvcCmd.Flags().StringVarP(&namespace, "namespace", "n", fio.DefaultNS, "The namespace of the PersistentVolumeClaim.") + browsePvcCmd.Flags().Int64VarP(&csiCheckRunAsUser, "runAsUser", "u", 0, "Runs the inspector pod as a user (int)") + browsePvcCmd.Flags().IntVarP(&browseLocalPort, "localport", "l", 8080, "The local port to expose the inspector") rootCmd.AddCommand(blockMountCmd) blockMountCmd.Flags().StringVarP(&storageClass, "storageclass", "s", "", "The name of a Storageclass. (Required)") From e523c2e019918ccc895ab2097ef38038280fc884 Mon Sep 17 00:00:00 2001 From: Shlok Chaudhari Date: Mon, 29 Jul 2024 15:08:30 -0500 Subject: [PATCH 2/4] Adding Deprecated msg to the 'browse' command --- cmd/rootCmd.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/rootCmd.go b/cmd/rootCmd.go index 4086252..f39e08b 100644 --- a/cmd/rootCmd.go +++ b/cmd/rootCmd.go @@ -85,10 +85,11 @@ var ( 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.", - Args: cobra.ExactArgs(1), + 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: "we recommend you to use command 'browse pvc' instead. Command 'browse pvc' will support newer updates for browsing through the contents of a PVC.", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { return browsePvcCmd.RunE(cmd, args) }, From 6b0373af6ec8d9f42042c28617576b008a647427 Mon Sep 17 00:00:00 2001 From: Shlok Chaudhari Date: Tue, 30 Jul 2024 15:40:29 -0500 Subject: [PATCH 3/4] Updating Deprecated msg for 'browse' command --- cmd/rootCmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/rootCmd.go b/cmd/rootCmd.go index f39e08b..411e5f0 100644 --- a/cmd/rootCmd.go +++ b/cmd/rootCmd.go @@ -88,7 +88,7 @@ var ( 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: "we recommend you to use command 'browse pvc' instead. Command 'browse pvc' will support newer updates for browsing through the contents of a PVC.", + Deprecated: "use 'browse pvc' instead", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { return browsePvcCmd.RunE(cmd, args) From 987234c8739877e9669c1118cccff1138a108e12 Mon Sep 17 00:00:00 2001 From: Shlok Chaudhari Date: Wed, 31 Jul 2024 10:57:57 -0500 Subject: [PATCH 4/4] Making namespace, runAsUser & localport flags persistent --- cmd/rootCmd.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/rootCmd.go b/cmd/rootCmd.go index 411e5f0..4f36fd7 100644 --- a/cmd/rootCmd.go +++ b/cmd/rootCmd.go @@ -178,16 +178,13 @@ func init() { rootCmd.AddCommand(browseCmd) browseCmd.Flags().StringVarP(&csiCheckVolumeSnapshotClass, "volumesnapshotclass", "v", "", "The name of a VolumeSnapshotClass. (Required)") _ = browseCmd.MarkFlagRequired("volumesnapshotclass") - browseCmd.Flags().StringVarP(&namespace, "namespace", "n", fio.DefaultNS, "The namespace of the PersistentVolumeClaim.") - browseCmd.Flags().Int64VarP(&csiCheckRunAsUser, "runAsUser", "u", 0, "Runs the inspector pod as a user (int)") - browseCmd.Flags().IntVarP(&browseLocalPort, "localport", "l", 8080, "The local port to expose the inspector") + 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") - browsePvcCmd.Flags().StringVarP(&namespace, "namespace", "n", fio.DefaultNS, "The namespace of the PersistentVolumeClaim.") - browsePvcCmd.Flags().Int64VarP(&csiCheckRunAsUser, "runAsUser", "u", 0, "Runs the inspector pod as a user (int)") - browsePvcCmd.Flags().IntVarP(&browseLocalPort, "localport", "l", 8080, "The local port to expose the inspector") rootCmd.AddCommand(blockMountCmd) blockMountCmd.Flags().StringVarP(&storageClass, "storageclass", "s", "", "The name of a Storageclass. (Required)")