Add some fields to source specs
This commit is contained in:
parent
f467ee5059
commit
8362706c16
|
@ -21,6 +21,9 @@ type field struct {
|
|||
Placeholder string `json:"placeholder,omitempty"`
|
||||
Default string `json:"default,omitempty"`
|
||||
Choices []string `json:"choices,omitempty"`
|
||||
Required bool `json:"required,omitempty"`
|
||||
Secret bool `json:"secret,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
func getSourceSpecs(_ *config.Options, p httprouter.Params, body io.Reader) Response {
|
||||
|
@ -66,11 +69,20 @@ func getSourceSpec(_ *config.Options, p httprouter.Params, body io.Reader) Respo
|
|||
f.Placeholder = kv[1]
|
||||
case "default":
|
||||
f.Default = kv[1]
|
||||
case "description":
|
||||
f.Description = kv[1]
|
||||
case "choices":
|
||||
f.Choices = strings.Split(kv[1], ";")
|
||||
}
|
||||
} else {
|
||||
f.Label = kv[0]
|
||||
switch strings.ToLower(kv[0]) {
|
||||
case "required":
|
||||
f.Required = true
|
||||
case "secret":
|
||||
f.Secret = true
|
||||
default:
|
||||
f.Label = kv[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
fields = append(fields, f)
|
||||
|
|
|
@ -13,9 +13,9 @@ import (
|
|||
|
||||
type DDNSServer struct {
|
||||
Server string `json:"server,omitempty" happydns:"label=Server,placeholder=127.0.0.1"`
|
||||
KeyName string `json:"keyname,omitempty" happydns:"label=Key Name,placeholder=ddns."`
|
||||
KeyAlgo string `json:"algorithm,omitempty" happydns:"label=Key Algorithm,default=hmac-sha256.,choices=hmac-md5.sig-alg.reg.int.;hmac-sha1.;hmac-sha224.;hmac-sha256.;hmac-sha384.;hmac-sha512."`
|
||||
KeyBlob []byte `json:"keyblob,omitempty" happydns:"label=Secret Key,placeholder=a0b1c2d3e4f5=="`
|
||||
KeyName string `json:"keyname,omitempty" happydns:"label=Key Name,placeholder=ddns.,required"`
|
||||
KeyAlgo string `json:"algorithm,omitempty" happydns:"label=Key Algorithm,default=hmac-sha256.,choices=hmac-md5.sig-alg.reg.int.;hmac-sha1.;hmac-sha224.;hmac-sha256.;hmac-sha384.;hmac-sha512.,required"`
|
||||
KeyBlob []byte `json:"keyblob,omitempty" happydns:"label=Secret Key,placeholder=a0b1c2d3e4f5==,required,secret"`
|
||||
}
|
||||
|
||||
func (s *DDNSServer) base64KeyBlob() string {
|
||||
|
|
Loading…
Reference in New Issue
Block a user