MCPcopy
hub / github.com/caddyserver/caddy / UnmarshalCaddyfile

Method UnmarshalCaddyfile

modules/caddytls/acmeissuer.go:448–697  ·  view source on GitHub ↗

UnmarshalCaddyfile deserializes Caddyfile tokens into iss. ... acme [<directory_url>] { dir <directory_url> test_dir <test_directory_url> email <email> profile <profile_name> timeout <duration> disable_http_challenge disable_tlsalpn_challenge alt_http_port

(d *caddyfile.Dispenser)

Source from the content-addressed store, hash-verified

446// }
447// }
448func (iss *ACMEIssuer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
449 d.Next() // consume issuer name
450
451 if d.NextArg() {
452 iss.CA = d.Val()
453 if d.NextArg() {
454 return d.ArgErr()
455 }
456 }
457
458 for d.NextBlock(0) {
459 switch d.Val() {
460 case "lifetime":
461 var lifetimeStr string
462 if !d.AllArgs(&lifetimeStr) {
463 return d.ArgErr()
464 }
465 lifetime, err := caddy.ParseDuration(lifetimeStr)
466 if err != nil {
467 return d.Errf("invalid lifetime %s: %v", lifetimeStr, err)
468 }
469 if lifetime < 0 {
470 return d.Errf("lifetime must be >= 0: %s", lifetime)
471 }
472 iss.CertificateLifetime = caddy.Duration(lifetime)
473
474 case "dir":
475 if iss.CA != "" {
476 return d.Errf("directory is already specified: %s", iss.CA)
477 }
478 if !d.AllArgs(&iss.CA) {
479 return d.ArgErr()
480 }
481
482 case "test_dir":
483 if !d.AllArgs(&iss.TestCA) {
484 return d.ArgErr()
485 }
486
487 case "email":
488 if !d.AllArgs(&iss.Email) {
489 return d.ArgErr()
490 }
491
492 case "profile":
493 if !d.AllArgs(&iss.Profile) {
494 return d.ArgErr()
495 }
496
497 case "timeout":
498 var timeoutStr string
499 if !d.AllArgs(&timeoutStr) {
500 return d.ArgErr()
501 }
502 timeout, err := caddy.ParseDuration(timeoutStr)
503 if err != nil {
504 return d.Errf("invalid timeout duration %s: %v", timeoutStr, err)
505 }

Callers

nothing calls this directly

Calls 12

UnmarshalModuleFunction · 0.92
JSONModuleObjectFunction · 0.92
NextArgMethod · 0.80
ValMethod · 0.80
ArgErrMethod · 0.80
NextBlockMethod · 0.80
AllArgsMethod · 0.80
ErrfMethod · 0.80
DurationMethod · 0.80
RemainingArgsMethod · 0.80
NextMethod · 0.65

Tested by

no test coverage detected