11package clinamespace
22
33import (
4- "os"
5-
64 "fmt"
5+ "os"
6+ "sort"
7+ "strings"
78
89 "github.com/containerum/chkit/pkg/cli/prerun"
910 "github.com/containerum/chkit/pkg/context"
1011 "github.com/containerum/chkit/pkg/util/activekit"
11- "github.com/containerum/chkit/pkg/util/angel"
1212 "github.com/containerum/chkit/pkg/util/coblog"
13+ "github.com/containerum/chkit/pkg/util/text"
1314 "github.com/containerum/kube-client/pkg/model"
1415 "github.com/sirupsen/logrus"
1516 "github.com/spf13/cobra"
@@ -21,12 +22,18 @@ func SetAccess(ctx *context.Context) *cobra.Command {
2122 Aliases : accessAliases ,
2223 SuggestFor : accessAliases ,
2324 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 ())
2830 }
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 ),
3037 Run : func (cmd * cobra.Command , args []string ) {
3138 var logger = coblog .Logger (cmd )
3239 if len (args ) != 2 {
0 commit comments