Browse Source
httpcaddyfile: Minor fixes to parsing storage options
master
Matthew Holt
5 years ago
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
2 changed files with
26 additions and
10 deletions
-
caddyconfig/httpcaddyfile/options.go
-
modules/filestorage/filestorage.go
|
|
@ -136,14 +136,13 @@ func parseOptOrder(d *caddyfile.Dispenser) ([]string, error) { |
|
|
|
} |
|
|
|
|
|
|
|
func parseOptStorage(d *caddyfile.Dispenser) (caddy.StorageConverter, error) { |
|
|
|
if !d.Next() { |
|
|
|
if !d.Next() { // consume option name
|
|
|
|
return nil, d.ArgErr() |
|
|
|
} |
|
|
|
args := d.RemainingArgs() |
|
|
|
if len(args) != 1 { |
|
|
|
if !d.Next() { // get storage module name
|
|
|
|
return nil, d.ArgErr() |
|
|
|
} |
|
|
|
modName := args[0] |
|
|
|
modName := d.Val() |
|
|
|
mod, err := caddy.GetModule("caddy.storage." + modName) |
|
|
|
if err != nil { |
|
|
|
return nil, d.Errf("getting storage module '%s': %v", modName, err) |
|
|
|
|
|
@ -48,14 +48,31 @@ func (s *FileStorage) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { |
|
|
|
if !d.Next() { |
|
|
|
return d.Err("expected tokens") |
|
|
|
} |
|
|
|
if d.NextArg() { |
|
|
|
s.Root = d.Val() |
|
|
|
} |
|
|
|
if d.NextArg() { |
|
|
|
return d.ArgErr() |
|
|
|
} |
|
|
|
for nesting := d.Nesting(); d.NextBlock(nesting); { |
|
|
|
switch d.Val() { |
|
|
|
case "root": |
|
|
|
if !d.NextArg() { |
|
|
|
return d.ArgErr() |
|
|
|
} |
|
|
|
if s.Root != "" { |
|
|
|
return d.Err("root already set") |
|
|
|
} |
|
|
|
s.Root = d.Val() |
|
|
|
if d.NextArg() { |
|
|
|
return d.ArgErr() |
|
|
|
} |
|
|
|
default: |
|
|
|
return d.Errf("unrecognized parameter '%s'", d.Val()) |
|
|
|
} |
|
|
|
} |
|
|
|
if s.Root == "" { |
|
|
|
return d.Err("missing root path (to use default, omit storage config entirely)") |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|