validate

package
v0.31.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package validate holds the field-level validators kubeaid-cli's interactive prompt runs at input time, exported so a consumer that isn't a terminal (the Obmondo add-cluster web form) can enforce the same rules — e.g. the Hetzner vSwitch VLAN ID range, the cluster name shape — before submitting.

Every function here is pure (string in, error out) and free of pkg/config/prompt's charmbracelet/huh dependency, so importing this package does not pull a terminal-UI library into a server binary. pkg/config/prompt's own huh forms delegate to these exact functions.

Index

Constants

View Source
const (
	MinHetznerVLANID = 4000
	MaxHetznerVLANID = 4091
)

MinHetznerVLANID / MaxHetznerVLANID bound the VLAN IDs Hetzner's vSwitch webservice accepts (inclusive).

Variables

View Source
var ErrRequired = errors.New("value is required")

ErrRequired is returned by NonEmpty when the input is empty.

Functions

func CIDRv4

func CIDRv4(s string) error

CIDRv4 validates that s parses as an IPv4 CIDR (e.g. 10.0.1.0/24).

func ClusterName

func ClusterName(s string) error

ClusterName validates a cluster.name value: non-empty, no dots (the name is spliced into DNS labels — the NetBird peer FQDN k8s-<name>, HCloud/Robot resource names), at most 63 characters, and RFC-1123 label shaped (CAPI's Cluster object name rule). Mirrors pkg/config/parser's validateClusterName.

func HTTPSURL

func HTTPSURL(s string) error

HTTPSURL validates that s is a non-empty https:// URL with a host.

func HetznerVLANID

func HetznerVLANID(s string) error

HetznerVLANID validates a Hetzner vSwitch VLAN ID: numeric and within MinHetznerVLANID-MaxHetznerVLANID — the range Hetzner's webservice accepts.

func IPv4

func IPv4(s string) error

IPv4 validates that s is a non-empty IPv4 address.

func IPv4InSubnet

func IPv4InSubnet(cidr string) func(string) error

IPv4InSubnet returns a validator requiring its input to be a valid IPv4 address inside cidr. An empty cidr disables the containment check, falling back to a plain IPv4 validation.

func NonEmpty

func NonEmpty(s string) error

NonEmpty rejects a blank (or whitespace-only) value.

func SSHGitURL

func SSHGitURL(s string) error

SSHGitURL validates that s is a non-empty SSH-form Git URL (scp-like git@host:path or ssh://…) — HTTPS URLs are rejected.

Types

This section is empty.

Jump to

Keyboard shortcuts

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