Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Datree
Commits
3e3cb37a
Commit
3e3cb37a
authored
4 years ago
by
Dima Brusilovsky
Browse files
Options
Download
Email Patches
Plain Diff
fix: fail config set for invalid input
parent
3d30620a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/config/set.go
+16
-1
cmd/config/set.go
with
16 additions
and
1 deletion
+16
-1
cmd/config/set.go
+
16
-
1
View file @
3e3cb37a
package
config
import
(
"errors"
"fmt"
"reflect"
"github.com/datreeio/datree/bl/messager"
"github.com/spf13/cobra"
...
...
@@ -26,7 +28,20 @@ func NewSetCommand(ctx *ConfigCommandContext) *cobra.Command {
ctx
.
Printer
.
PrintMessage
(
msg
.
MessageText
+
"
\n
"
,
msg
.
MessageColor
)
}
},
Args
:
cobra
.
ExactArgs
(
2
),
Args
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
!=
2
{
return
errors
.
New
(
"requires exactly 2 arguments"
)
}
validKeys
:=
make
(
map
[
string
]
bool
)
validKeys
[
"token"
]
=
true
if
val
,
ok
:=
validKeys
[
args
[
0
]];
!
ok
||
!
val
{
return
fmt
.
Errorf
(
"key must be one of: %s"
,
reflect
.
ValueOf
(
validKeys
)
.
MapKeys
())
}
return
nil
},
}
return
setCommand
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment