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
ed881796
Commit
ed881796
authored
Sep 22, 2017
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conifg-patch: apply review
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
d7376cda
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
core/commands/config.go
core/commands/config.go
+4
-8
repo/config/profile.go
repo/config/profile.go
+4
-0
No files found.
core/commands/config.go
View file @
ed881796
...
...
@@ -313,11 +313,9 @@ var configProfileApplyCmd = &cmds.Command{
cmds
.
StringArg
(
"profile"
,
true
,
false
,
"The profile to apply to the config."
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
args
:=
req
.
Arguments
()
profile
,
ok
:=
config
.
Profiles
[
args
[
0
]]
profile
,
ok
:=
config
.
Profiles
[
req
.
Arguments
()[
0
]]
if
!
ok
{
res
.
SetError
(
fmt
.
Errorf
(
"%s i
n
not a profile"
,
args
[
0
]),
cmds
.
ErrNormal
)
res
.
SetError
(
fmt
.
Errorf
(
"%s i
s
not a profile"
,
req
.
Arguments
()
[
0
]),
cmds
.
ErrNormal
)
return
}
...
...
@@ -341,11 +339,9 @@ Backing up the config before running this command is advised.`,
cmds
.
StringArg
(
"profile"
,
true
,
false
,
"The profile to apply to the config."
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
args
:=
req
.
Arguments
()
profile
,
ok
:=
config
.
Profiles
[
args
[
0
]]
profile
,
ok
:=
config
.
Profiles
[
req
.
Arguments
()[
0
]]
if
!
ok
{
res
.
SetError
(
fmt
.
Errorf
(
"%s i
n
not a profile"
,
args
[
0
]),
cmds
.
ErrNormal
)
res
.
SetError
(
fmt
.
Errorf
(
"%s i
s
not a profile"
,
req
.
Arguments
()
[
0
]),
cmds
.
ErrNormal
)
return
}
...
...
repo/config/profile.go
View file @
ed881796
package
config
// Transformer is a function which takes configuration and applies some filter to it
type
Transformer
func
(
c
*
Config
)
error
// Profile applies some set of changes to the configuration
type
Profile
struct
{
Apply
Transformer
Unapply
Transformer
...
...
@@ -32,11 +34,13 @@ var Profiles = map[string]*Profile{
"/ip4/240.0.0.0/ipcidr/4"
,
}
c
.
Addresses
.
NoAnnounce
=
append
(
c
.
Addresses
.
NoAnnounce
,
defaultServerFilters
...
)
c
.
Swarm
.
AddrFilters
=
append
(
c
.
Swarm
.
AddrFilters
,
defaultServerFilters
...
)
c
.
Discovery
.
MDNS
.
Enabled
=
false
return
nil
},
Unapply
:
func
(
c
*
Config
)
error
{
c
.
Addresses
.
NoAnnounce
=
[]
string
{}
c
.
Swarm
.
AddrFilters
=
[]
string
{}
c
.
Discovery
.
MDNS
.
Enabled
=
true
return
nil
...
...
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