/
rename_namespace.go
43 lines (37 loc) · 1.2 KB
/
rename_namespace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* *******************************************************************************
* * Copyright (c) 2020 Edgeworx, Inc.
* *
* * This program and the accompanying materials are made available under the
* * terms of the Eclipse Public License v. 2.0 which is available at
* * http://www.eclipse.org/legal/epl-2.0
* *
* * SPDX-License-Identifier: EPL-2.0
* *******************************************************************************
*
*/
package cmd
import (
rename "github.com/eclipse-iofog/iofogctl/v3/internal/rename/namespace"
"github.com/eclipse-iofog/iofogctl/v3/pkg/util"
"github.com/spf13/cobra"
)
func newRenameNamespaceCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "namespace NAME NEW_NAME",
Short: "Rename a Namespace",
Long: `Rename a Namespace`,
Example: `iofogctl rename namespace NAME NEW_NAME`,
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
// Get name and new name of the namespace
name := args[0]
newName := args[1]
// Get an executor for the command
err := rename.Execute(name, newName)
util.Check(err)
util.PrintSuccess(getRenameSuccessMessage("Namespace", name, newName))
},
}
return cmd
}