Skip to content

Commit ca5e92f

Browse files
committed
conifg-patch: apply review
License: MIT Signed-off-by: Łukasz Magiera <[email protected]>
1 parent 128e6ba commit ca5e92f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

core/commands/config.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,9 @@ var configProfileApplyCmd = &cmds.Command{
298298
cmds.StringArg("profile", true, false, "The profile to apply to the config."),
299299
},
300300
Run: func(req cmds.Request, res cmds.Response) {
301-
args := req.Arguments()
302-
303-
profile, ok := config.Profiles[args[0]]
301+
profile, ok := config.Profiles[req.Arguments()[0]]
304302
if !ok {
305-
res.SetError(fmt.Errorf("%s in not a profile", args[0]), cmds.ErrNormal)
303+
res.SetError(fmt.Errorf("%s is not a profile", req.Arguments()[0]), cmds.ErrNormal)
306304
return
307305
}
308306

@@ -326,11 +324,9 @@ Backing up the config before running this command is advised.`,
326324
cmds.StringArg("profile", true, false, "The profile to apply to the config."),
327325
},
328326
Run: func(req cmds.Request, res cmds.Response) {
329-
args := req.Arguments()
330-
331-
profile, ok := config.Profiles[args[0]]
327+
profile, ok := config.Profiles[req.Arguments()[0]]
332328
if !ok {
333-
res.SetError(fmt.Errorf("%s in not a profile", args[0]), cmds.ErrNormal)
329+
res.SetError(fmt.Errorf("%s is not a profile", req.Arguments()[0]), cmds.ErrNormal)
334330
return
335331
}
336332

repo/config/profile.go

+4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package config
22

3+
// Transformer is a function which takes configuration and applies some filter to it
34
type Transformer func(c *Config) error
45

6+
// Profile applies some set of changes to the configuration
57
type Profile struct {
68
Apply Transformer
79
Unapply Transformer
@@ -32,11 +34,13 @@ var Profiles = map[string]*Profile{
3234
"/ip4/240.0.0.0/ipcidr/4",
3335
}
3436

37+
c.Addresses.NoAnnounce = append(c.Addresses.NoAnnounce, defaultServerFilters...)
3538
c.Swarm.AddrFilters = append(c.Swarm.AddrFilters, defaultServerFilters...)
3639
c.Discovery.MDNS.Enabled = false
3740
return nil
3841
},
3942
Unapply: func(c *Config) error {
43+
c.Addresses.NoAnnounce = []string{}
4044
c.Swarm.AddrFilters = []string{}
4145
c.Discovery.MDNS.Enabled = true
4246
return nil

0 commit comments

Comments
 (0)