1
1
package clinamespace
2
2
3
3
import (
4
- "os"
5
-
6
4
"fmt"
5
+ "os"
6
+ "sort"
7
+ "strings"
7
8
8
9
"github.com/containerum/chkit/pkg/cli/prerun"
9
10
"github.com/containerum/chkit/pkg/context"
10
11
"github.com/containerum/chkit/pkg/util/activekit"
11
- "github.com/containerum/chkit/pkg/util/angel"
12
12
"github.com/containerum/chkit/pkg/util/coblog"
13
+ "github.com/containerum/chkit/pkg/util/text"
13
14
"github.com/containerum/kube-client/pkg/model"
14
15
"github.com/sirupsen/logrus"
15
16
"github.com/spf13/cobra"
@@ -21,12 +22,18 @@ func SetAccess(ctx *context.Context) *cobra.Command {
21
22
Aliases : accessAliases ,
22
23
SuggestFor : accessAliases ,
23
24
Short : "set namespace access" ,
24
- Example : "chkit set access $USERNAME $ACCESS_LEVEL [--namespace $ID]" ,
25
- PreRun : func (cmd * cobra.Command , args []string ) {
26
- if err := prerun .PreRun (ctx ); err != nil {
27
- angel .Angel (ctx , err )
25
+ Long : "Set access level to namespace.\n " +
26
+ "Available access levels are:\n " + func () string {
27
+ var levels []string
28
+ for _ , lvl := range model .Levels () {
29
+ levels = append (levels , lvl .String ())
28
30
}
29
- },
31
+ sort .Strings (levels )
32
+ var lvlsInfo = strings .Join (levels , "\n " )
33
+ return text .Indent (lvlsInfo , 2 )
34
+ }(),
35
+ Example : "chkit set access $USERNAME $ACCESS_LEVEL [--namespace $ID]" ,
36
+ PreRun : prerun .PreRunFunc (ctx ),
30
37
Run : func (cmd * cobra.Command , args []string ) {
31
38
var logger = coblog .Logger (cmd )
32
39
if len (args ) != 2 {
0 commit comments