fielddesc

package
v1.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const BackupTarget = "backup-targets"

BackupTarget is the resource name of the backup destination form.

View Source
const DNSProvider = "dns-providers"

DNSProvider is the resource name of the per provider DNS credential form.

View Source
const EventWebhook = "event-webhooks"

EventWebhook is the resource name of an outbound event webhook.

View Source
const LogDrain = "log-drains"

LogDrain is the resource name of an app log drain.

View Source
const NotificationChannel = "notification-channels"

NotificationChannel is the resource name of the alert and deploy notification channel form.

View Source
const RegistryCredential = "registry-credentials" //nolint:gosec // resource name, not a credential

RegistryCredential is the resource name of the private image registry login form.

View Source
const SecretMask = "********"

SecretMask is what a read returns in place of a stored secret.

View Source
const StatusWebhook = "status-page-webhooks"

StatusWebhook is the resource name of a status page webhook subscriber.

Variables

This section is empty.

Functions

func DocsPage

func DocsPage(r Resource) string

DocsPage renders the whole generated docs file of a resource.

func FirstProblem

func FirstProblem(ps []Problem) string

FirstProblem returns the first problem as an error text, or empty when valid.

func Names

func Names() []string

Names lists registered resources, sorted.

func Register

func Register(r Resource)

Register adds a resource at init time; a duplicate name or field ID is a programming error.

Types

type Condition

type Condition struct {
	Field  string   `json:"field"`
	Equals []string `json:"equals"`
}

Condition shows a field only while another field holds one of Equals.

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).

func (Field) Visible

func (f Field) Visible(values map[string]string) bool

Visible reports whether f applies given the current form values.

type FlagSpec

type FlagSpec struct {
	Name  string
	Key   string
	Usage string
	File  bool
	Bool  bool
	Multi bool
}

FlagSpec is one CLI flag derived from the descriptors.

type Problem

type Problem struct {
	Key     string `json:"key"`
	Message string `json:"message"`
}

Problem is one validation failure, worded identically for every surface.

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 Get

func Get(name string) (Resource, bool)

Get returns a resource by name.

func (Resource) FlagSpecs

func (r Resource) FlagSpecs() []FlagSpec

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

func (r Resource) FlagSpecsWhen(values map[string]string) []FlagSpec

FlagSpecsWhen is FlagSpecs limited to the fields visible for values, so a per provider verb registers only that provider's flags.

func (Resource) Markdown

func (r Resource) Markdown() string

Markdown renders the docs table for a resource.

func (Resource) Masked

func (r Resource) Masked(values map[string]string) map[string]string

Masked returns a copy of values with every visible secret replaced by a fixed mask, so a read path can never echo a credential.

func (Resource) Validate

func (r Resource) Validate(values map[string]string) []Problem

Validate checks visible fields for required values and select options.

func (Resource) ValidateExcept

func (r Resource) ValidateExcept(values map[string]string, skip ...string) []Problem

ValidateExcept is Validate without the named keys, for updates where blank credentials mean "keep what is stored".

type Type

type Type string

Type is the input kind a surface renders for a field.

const (
	TypeString Type = "string"
	TypeText   Type = "text"
	TypeSecret Type = "secret"
	TypeSelect Type = "select"
	TypeBool   Type = "bool"
)

Input kinds a surface knows how to render.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL