Documentation
¶
Overview ¶
Package fielddesc is the one registry of resource form fields. The API serves it, the CLI builds flags from it, the dashboard renders forms from it and the docs table is generated from it, so adding a field is one entry here.
Index ¶
- Constants
- func DocsPage(r Resource) string
- func FirstProblem(ps []Problem) string
- func Names() []string
- func Register(r Resource)
- type Condition
- type Docs
- type Field
- type FlagSpec
- type Problem
- type Resource
- func (r Resource) FlagSpecs() []FlagSpec
- func (r Resource) FlagSpecsWhen(values map[string]string) []FlagSpec
- func (r Resource) Markdown() string
- func (r Resource) Masked(values map[string]string) map[string]string
- func (r Resource) Validate(values map[string]string) []Problem
- func (r Resource) ValidateExcept(values map[string]string, skip ...string) []Problem
- type Type
Constants ¶
const BackupTarget = "backup-targets"
BackupTarget is the resource name of the backup destination form.
const DNSProvider = "dns-providers"
DNSProvider is the resource name of the per provider DNS credential form.
const EventWebhook = "event-webhooks"
EventWebhook is the resource name of an outbound event webhook.
const LogDrain = "log-drains"
LogDrain is the resource name of an app log drain.
const NotificationChannel = "notification-channels"
NotificationChannel is the resource name of the alert and deploy notification channel form.
const RegistryCredential = "registry-credentials" //nolint:gosec // resource name, not a credential
RegistryCredential is the resource name of the private image registry login form.
const SecretMask = "********"
SecretMask is what a read returns in place of a stored secret.
const StatusWebhook = "status-page-webhooks"
StatusWebhook is the resource name of a status page webhook subscriber.
Variables ¶
This section is empty.
Functions ¶
func FirstProblem ¶
FirstProblem returns the first problem as an error text, or empty when valid.
Types ¶
type Docs ¶
type Docs struct {
File string // path under docs/, for example backup-target-fields.md
Title string
Description string
}
Docs places the generated docs page of a resource. It is not served over the API.
type Field ¶
type Field struct {
ID string `json:"id"`
Key string `json:"key"`
Type Type `json:"type"`
LabelKey string `json:"label_key"`
HelpKey string `json:"help_key"`
Default string `json:"default,omitempty"`
Options []string `json:"options,omitempty"`
Required bool `json:"required"`
Secret bool `json:"secret"`
ShowWhen []Condition `json:"show_when,omitempty"`
// Flag is the CLI flag name without dashes; empty means the field has no flag.
Flag string `json:"flag,omitempty"`
// FlagFile marks a flag that takes a file path whose content becomes the value.
FlagFile bool `json:"flag_file,omitempty"`
// Multi marks a flag that may repeat or take a comma list, joined into one value.
Multi bool `json:"multi,omitempty"`
// FormOnly marks a field the CLI infers instead of taking a flag.
FormOnly bool `json:"form_only,omitempty"`
// Placeholder and HelpURL are language neutral hints the dashboard shows beside the input.
Placeholder string `json:"placeholder,omitempty"`
HelpURL string `json:"help_url,omitempty"`
// Doc is the English one line description used by the CLI help and the docs table.
Doc string `json:"doc"`
}
Field describes one input of a resource form. ID is unique per resource; Key is the wire name and may repeat across disjoint ShowWhen variants (for example one key labelled per provider).
type Resource ¶
type Resource struct {
Name string `json:"name"`
Fields []Field `json:"fields"`
// Docs is required: the generator and the contract test read it for every resource.
Docs Docs `json:"-"`
}
Resource is the ordered field list of one resource kind.
func (Resource) FlagSpecs ¶
FlagSpecs lists each distinct flag once, in field order. Variants that share a wire key share one flag, so the first descriptor carrying the flag supplies its help.
func (Resource) FlagSpecsWhen ¶
FlagSpecsWhen is FlagSpecs limited to the fields visible for values, so a per provider verb registers only that provider's flags.
func (Resource) Masked ¶
Masked returns a copy of values with every visible secret replaced by a fixed mask, so a read path can never echo a credential.