Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
c573d3d0
Commit
c573d3d0
authored
Nov 25, 2017
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config-patch: update to new commands lib
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
9312fa5f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
core/commands/config.go
core/commands/config.go
+11
-11
No files found.
core/commands/config.go
View file @
c573d3d0
...
...
@@ -295,7 +295,7 @@ can't be undone.
}
var
configProfileCmd
=
&
cmds
.
Command
{
Helptext
:
cmd
s
.
HelpText
{
Helptext
:
cmd
kit
.
HelpText
{
Tagline
:
"Apply profiles to config."
,
},
...
...
@@ -306,48 +306,48 @@ var configProfileCmd = &cmds.Command{
}
var
configProfileApplyCmd
=
&
cmds
.
Command
{
Helptext
:
cmd
s
.
HelpText
{
Helptext
:
cmd
kit
.
HelpText
{
Tagline
:
"Apply profile to config."
,
},
Arguments
:
[]
cmd
s
.
Argument
{
cmd
s
.
StringArg
(
"profile"
,
true
,
false
,
"The profile to apply to the config."
),
Arguments
:
[]
cmd
kit
.
Argument
{
cmd
kit
.
StringArg
(
"profile"
,
true
,
false
,
"The profile to apply to the config."
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
profile
,
ok
:=
config
.
Profiles
[
req
.
Arguments
()[
0
]]
if
!
ok
{
res
.
SetError
(
fmt
.
Errorf
(
"%s is not a profile"
,
req
.
Arguments
()[
0
]),
cmd
s
.
ErrNormal
)
res
.
SetError
(
fmt
.
Errorf
(
"%s is not a profile"
,
req
.
Arguments
()[
0
]),
cmd
kit
.
ErrNormal
)
return
}
err
:=
transformConfig
(
req
.
InvocContext
()
.
ConfigRoot
,
profile
.
Apply
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmd
s
.
ErrNormal
)
res
.
SetError
(
err
,
cmd
kit
.
ErrNormal
)
return
}
},
}
var
configProfileRevertCmd
=
&
cmds
.
Command
{
Helptext
:
cmd
s
.
HelpText
{
Helptext
:
cmd
kit
.
HelpText
{
Tagline
:
"Revert profile changes."
,
ShortDescription
:
`Reverts profile-related changes to the config.
Reverting some profiles may damage the configuration or not be possible.
Backing up the config before running this command is advised.`
,
},
Arguments
:
[]
cmd
s
.
Argument
{
cmd
s
.
StringArg
(
"profile"
,
true
,
false
,
"The profile to apply to the config."
),
Arguments
:
[]
cmd
kit
.
Argument
{
cmd
kit
.
StringArg
(
"profile"
,
true
,
false
,
"The profile to apply to the config."
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
profile
,
ok
:=
config
.
Profiles
[
req
.
Arguments
()[
0
]]
if
!
ok
{
res
.
SetError
(
fmt
.
Errorf
(
"%s is not a profile"
,
req
.
Arguments
()[
0
]),
cmd
s
.
ErrNormal
)
res
.
SetError
(
fmt
.
Errorf
(
"%s is not a profile"
,
req
.
Arguments
()[
0
]),
cmd
kit
.
ErrNormal
)
return
}
err
:=
transformConfig
(
req
.
InvocContext
()
.
ConfigRoot
,
profile
.
Revert
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmd
s
.
ErrNormal
)
res
.
SetError
(
err
,
cmd
kit
.
ErrNormal
)
return
}
},
...
...
Write
Preview
Markdown
is supported
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