Skip to content

Structured Input

Repeatable rows of structured form inputs for metadata, taints, rules, and similar list-shaped data.

Default Rendered example
Usage Example
@structuredinput.StructuredInput(structuredinput.Config{
    ID:   "labels",
    Name: "labels",
    Columns: []structuredinput.Column{
        {Key: "key", Label: "Key", Placeholder: "key", Separator: "="},
        {Key: "value", Label: "Value", Placeholder: "value"},
    },
    Entries: []structuredinput.Entry{
        {"key": "app", "value": "web"},
        {"key": "env", "value": "prod"},
    },
})

Select Column

Rows can combine text inputs with select columns for enumerated values like Kubernetes taint effects.

Select Column Rendered example
Select Column
@structuredinput.StructuredInput(structuredinput.Config{
    ID:   "taints",
    Name: "taints",
    Columns: []structuredinput.Column{
        {Key: "key", Label: "Key", Placeholder: "key", Separator: "="},
        {Key: "value", Label: "Value", Placeholder: "value", Separator: ":"},
        {
            Key: "effect",
            Label: "Effect",
            Type: structuredinput.ColumnSelect,
            Options: []structuredinput.Option{
                {Value: "NoSchedule", Label: "NoSchedule"},
                {Value: "PreferNoSchedule", Label: "PreferNoSchedule"},
                {Value: "NoExecute", Label: "NoExecute"},
            },
        },
    },
    Entries: []structuredinput.Entry{
        {"key": "node-role.kubernetes.io/control-plane", "value": "true", "effect": "NoSchedule"},
    },
    AddActionLabel: "Add taint",
})

Empty Starter

With no entries the list starts empty and adds rows from the configured column defaults.

Empty Starter Rendered example
Empty Starter
@structuredinput.StructuredInput(structuredinput.Config{
    ID:   "rules",
    Name: "rules",
    Columns: []structuredinput.Column{
        {Key: "name", Label: "Name", Placeholder: "rule name"},
        {Key: "condition", Label: "Condition", Placeholder: "condition"},
        {
            Key: "priority",
            Label: "Priority",
            Type: structuredinput.ColumnSelect,
            Options: []structuredinput.Option{
                {Value: "high", Label: "High"},
                {Value: "medium", Label: "Medium"},
                {Value: "low", Label: "Low"},
            },
        },
    },
    AddActionLabel: "Add rule",
})

Go API

v0.2.7

The examples above cover behavior and composition. pkg.go.dev is the canonical reference for exported types, functions, methods, and Go documentation.

github.com/araihu/goshtoso/components/structuredinput
Open v0.2.7 API