mirror of
https://github.com/daeuniverse/dae.git
synced 2025-01-05 13:08:57 +07:00
feat: add default value and required to outline file
This commit is contained in:
parent
f3845bd452
commit
87c9b9d6a5
@ -21,6 +21,7 @@ type Global struct {
|
|||||||
UdpCheckDns string `mapstructure:"udp_check_dns" default:"dns.google:53"`
|
UdpCheckDns string `mapstructure:"udp_check_dns" default:"dns.google:53"`
|
||||||
CheckInterval time.Duration `mapstructure:"check_interval" default:"30s"`
|
CheckInterval time.Duration `mapstructure:"check_interval" default:"30s"`
|
||||||
CheckTolerance time.Duration `mapstructure:"check_tolerance" default:"0"`
|
CheckTolerance time.Duration `mapstructure:"check_tolerance" default:"0"`
|
||||||
|
// Deprecated:
|
||||||
DnsUpstream string `mapstructure:"dns_upstream" default:"<empty>"`
|
DnsUpstream string `mapstructure:"dns_upstream" default:"<empty>"`
|
||||||
LanInterface []string `mapstructure:"lan_interface"`
|
LanInterface []string `mapstructure:"lan_interface"`
|
||||||
// Deprecated:
|
// Deprecated:
|
||||||
|
@ -21,8 +21,9 @@ type OutlineElem struct {
|
|||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Mapping string `json:"mapping,omitempty"`
|
Mapping string `json:"mapping,omitempty"`
|
||||||
IsArray bool `json:"isArray,omitempty"`
|
IsArray bool `json:"isArray,omitempty"`
|
||||||
|
DefaultValue string `json:"defaultValue,omitempty"`
|
||||||
|
Required bool `json:"required,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
ElemType string `json:"elemType,omitempty"`
|
|
||||||
Desc string `json:"desc,omitempty"`
|
Desc string `json:"desc,omitempty"`
|
||||||
Structure []*OutlineElem `json:"structure,omitempty"`
|
Structure []*OutlineElem `json:"structure,omitempty"`
|
||||||
}
|
}
|
||||||
@ -101,10 +102,13 @@ func (e *outlineExporter) exportStruct(t reflect.Type, descSource Desc, inheritS
|
|||||||
// Record leaves.
|
// Record leaves.
|
||||||
e.leaves[typ.String()] = typ
|
e.leaves[typ.String()] = typ
|
||||||
}
|
}
|
||||||
|
_, required := section.Tag.Lookup("required")
|
||||||
outlines = append(outlines, &OutlineElem{
|
outlines = append(outlines, &OutlineElem{
|
||||||
Name: section.Name,
|
Name: section.Name,
|
||||||
Mapping: section.Tag.Get("mapstructure"),
|
Mapping: section.Tag.Get("mapstructure"),
|
||||||
IsArray: isArray,
|
IsArray: isArray,
|
||||||
|
DefaultValue: section.Tag.Get("default"),
|
||||||
|
Required: required,
|
||||||
Type: typ.String(),
|
Type: typ.String(),
|
||||||
Desc: desc,
|
Desc: desc,
|
||||||
Structure: children,
|
Structure: children,
|
||||||
|
Loading…
Reference in New Issue
Block a user