Skip to content

Commit

Permalink
Consistent use of remove/delete/rm for secrets/fns/namespaces
Browse files Browse the repository at this point in the history
Consistent "delete", "remove", and "rm" usage for secrets,
functions, and namespaces.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Sep 4, 2024
1 parent f509dd3 commit 565bbaf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 60 deletions.
23 changes: 12 additions & 11 deletions commands/namespace_delete.go → commands/namespace_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ import (
"github.com/spf13/cobra"
)

var namespaceDeleteCmd = &cobra.Command{
Use: `delete NAME`,
Short: "Delete existing namespace",
Long: "Delete existing namespace",
Example: ` faas-cli namespace delete NAME`,
RunE: deleteNamespace,
PreRunE: preDeleteNamespace,
var namespaceRemoveCmd = &cobra.Command{
Use: `remove NAME`,
Short: "Remove existing namespace",
Long: "Remove existing namespace",
Example: ` faas-cli namespace remove NAME`,
Aliases: []string{"rm", "delete"},
RunE: removeNamespace,
PreRunE: preRemoveNamespace,
}

func init() {
namespaceCmd.AddCommand(namespaceDeleteCmd)
namespaceCmd.AddCommand(namespaceRemoveCmd)
}

func preDeleteNamespace(cmd *cobra.Command, args []string) error {
func preRemoveNamespace(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return fmt.Errorf("namespace name required")
}
Expand All @@ -35,7 +36,7 @@ func preDeleteNamespace(cmd *cobra.Command, args []string) error {
return nil
}

func deleteNamespace(cmd *cobra.Command, args []string) error {
func removeNamespace(cmd *cobra.Command, args []string) error {
client, err := GetDefaultSDKClient()
if err != nil {
return err
Expand All @@ -48,7 +49,7 @@ func deleteNamespace(cmd *cobra.Command, args []string) error {
return err
}

fmt.Printf("Namespace Deleted: %s\n", ns)
fmt.Printf("Namespace Removed: %s\n", ns)

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package commands
import "testing"

func Test_preDeleteNamespace_NoArgs_Fails(t *testing.T) {
res := preDeleteNamespace(nil, []string{})
res := preRemoveNamespace(nil, []string{})

want := "namespace name required"
if res.Error() != want {
Expand All @@ -12,7 +12,7 @@ func Test_preDeleteNamespace_NoArgs_Fails(t *testing.T) {
}

func Test_preDeleteNamespace_MoreThan1Arg_Fails(t *testing.T) {
res := preDeleteNamespace(nil, []string{
res := preRemoveNamespace(nil, []string{
"secret1",
"secret2",
})
Expand All @@ -24,7 +24,7 @@ func Test_preDeleteNamespace_MoreThan1Arg_Fails(t *testing.T) {
}

func Test_preDeleteNamespace_ExtactlyOneArgIsFine(t *testing.T) {
res := preDeleteNamespace(nil, []string{
res := preRemoveNamespace(nil, []string{
"namespace1",
})

Expand Down
2 changes: 1 addition & 1 deletion commands/secret_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

var secretRemoveCmd = &cobra.Command{
Use: "remove [--tls-no-verify]",
Aliases: []string{"rm"},
Aliases: []string{"rm", "delete"},
Short: "remove a secret",
Long: `Remove a secret by name`,
Example: `faas-cli secret remove NAME
Expand Down
45 changes: 0 additions & 45 deletions schema/openfaas/v1alpha2/crd.go

This file was deleted.

0 comments on commit 565bbaf

Please sign in to comment.