setConfig saves the config specified in request to fname.
(fname string, request url.URL)
| 123 | |
| 124 | // setConfig saves the config specified in request to fname. |
| 125 | func setConfig(fname string, request url.URL) error { |
| 126 | q := request.Query() |
| 127 | name := q.Get("config") |
| 128 | if name == "" { |
| 129 | return fmt.Errorf("invalid config name") |
| 130 | } |
| 131 | cfg := currentConfig() |
| 132 | if err := cfg.applyURL(q); err != nil { |
| 133 | return err |
| 134 | } |
| 135 | return editSettings(fname, func(s *settings) error { |
| 136 | for i, c := range s.Configs { |
| 137 | if c.Name == name { |
| 138 | s.Configs[i].config = cfg |
| 139 | return nil |
| 140 | } |
| 141 | } |
| 142 | s.Configs = append(s.Configs, namedConfig{Name: name, config: cfg}) |
| 143 | return nil |
| 144 | }) |
| 145 | } |
| 146 | |
| 147 | // removeConfig removes config from fname. |
| 148 | func removeConfig(fname, config string) error { |
searching dependent graphs…