Files
ilkerandClaude Opus 5.5 71b30a8ac3 setup: install onto a libvirt host
The second setup backend, SITE_KIND=libvirt:

  libvirt   reaches the KVM host as root (or a sudo login) with the
            provisioner key, pinning its host key the first time; checks
            libvirt, /dev/kvm, the management bridge, qemu-img and curl,
            and installs none of them; puts a directory pool and the cloud
            image in place. On a host that is the control plane itself it
            authorises its own key for root.
  template  builds a head image: the cloud image copied, a build VM with a
            seed made here, the same golden.yml as Proxmox (now shared as
            bakeHead), its disk kept under a new name per build - heads'
            disks are overlays on it, so it is never rewritten in place.
  config    sites.yaml (kind libvirt, the pinned known_hosts), the unit's
            environment file, site.auto.tfvars naming the image.
  verify    the same checks by using them, and discovery through the
            provider with the settings the portal reads.

The libvirt module no longer takes the host's name: setup writes its
configuration before it has reached the host. Placement is held to one
host by comparing the hosts it chose with each other.

deploy/site.env.libvirt.example is held to its own validation, like the
Proxmox one. The interactive installer refuses a non-Proxmox site and
points at -yes -config. Tests cover the fields, what config writes and
that the portal can build a provider from it, every site.auto.tfvars
variable being declared by its environment (both backends), and the
host key pinned once and held to.

Not yet run against a real host end to end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 12:48:53 +01:00

636 lines
21 KiB
Go

// Package tui is `hpcod setup` for a person at a terminal: the same steps
// as the plain runner, in one full-screen frame. Proxmox is asked for and
// tested first, the site's choices are offered from what Proxmox actually
// has, and a test cluster is offered at the end.
package tui
import (
"context"
"errors"
"fmt"
"io"
"net/url"
"os"
"os/exec"
"strings"
"time"
"github.com/charmbracelet/huh"
"github.com/ilkermanap/hpcod/internal/setup"
)
// Options are what the command line hands the TUI.
type Options struct {
Exe string
Revision string
LogPath string
}
const (
actInstall = "install"
actVerify = "verify"
actSelftest = "selftest"
actTemplate = "template"
actQuit = "quit"
)
// Run is the whole interactive setup.
func Run(ctx context.Context, o Options) error {
logf, err := os.OpenFile(o.LogPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600)
if err != nil {
return err
}
defer logf.Close()
fmt.Fprintf(logf, "\n===== hpcod setup %s, %s\n", o.Revision, time.Now().Format(time.RFC3339))
site, installed := setup.Defaults(), false
if s, err := setup.LoadSite(setup.SiteFile); err == nil {
for k, v := range s {
site[k] = v
}
installed = true
}
// The forms below are Proxmox's: they sign in to it and offer its
// nodes and datastores. Another backend is installed from its file.
if site.Kind() != setup.DefaultKind {
return fmt.Errorf("%s describes a %s site, and the interactive installer knows Proxmox only.\n"+
"Run: sudo hpcod setup -yes -config %s", setup.SiteFile, site.Kind(), setup.SiteFile)
}
header.version = o.Revision
for {
header.inInstall = false
header.site = ""
act := actInstall
desc := "Nothing is installed on this host yet."
opts := []huh.Option[string]{huh.NewOption("Install hpcod on this host", actInstall)}
if installed {
header.site = site["PORTAL_DOMAIN"]
act = actVerify
where := site["PVE_ENDPOINT"]
if site.Sim() {
where = "a simulated Proxmox on this host"
}
desc = fmt.Sprintf("Installed for %s, building clusters on %s.", site["PORTAL_DOMAIN"], where)
opts = []huh.Option[string]{
huh.NewOption("Check the installation", actVerify),
huh.NewOption("Reconfigure and install again", actInstall),
huh.NewOption("Build a test cluster ~25 min", actSelftest),
huh.NewOption("Rebuild the head node template ~15 min", actTemplate),
}
}
opts = append(opts, huh.NewOption("Quit", actQuit))
err := ask(stStart, "Welcome", huh.NewForm(huh.NewGroup(
huh.NewNote().Title("HPC on Demand").Description(
"Builds HPC clusters on request, on Proxmox VE.\n"+desc),
huh.NewSelect[string]().Title("What would you like to do?").Options(opts...).Value(&act),
)))
if errors.Is(err, huh.ErrUserAborted) {
return nil
}
if err != nil {
return err
}
switch act {
case actInstall:
err = install(ctx, o, site, logf)
if err == nil {
installed = true
}
case actVerify:
err = verify(ctx, site)
case actSelftest:
err = selftest(ctx, o, logf)
case actTemplate:
e := &setup.Env{Site: site, Exe: o.Exe, Revision: o.Revision, RebuildTemplate: true}
var steps []setup.Step
if steps, err = setup.Select(site, []string{"template"}, nil); err == nil {
err = runSteps(ctx, "Rebuilding the head node template", e, steps, logf, o.LogPath)
}
case actQuit:
return nil
}
if err != nil && !errors.Is(err, huh.ErrUserAborted) {
pause(err)
}
}
}
// install asks for the site, then runs every step.
func install(ctx context.Context, o Options, site setup.Site, logf io.Writer) error {
header.inInstall = true
if err := ask(stProxmox, "Where clusters are built", huh.NewForm(huh.NewGroup(
huh.NewNote().Title("Proxmox VE").Description(
"hpcod builds every cluster as virtual machines on Proxmox VE.\n"+
"Without one, it can run a simulated Proxmox here, to try it."),
huh.NewSelect[string]().Title("Build clusters on").Options(
huh.NewOption("A Proxmox VE I already have", "real"),
huh.NewOption("A simulated Proxmox, in QEMU on this host", "sim"),
).Value(strPtr(site, "PVE_MODE")),
))); err != nil {
return err
}
commit(site)
var creds setup.Credentials
var probe *setup.Probe
if site.Sim() {
if miss := setup.SimPreflight(); len(miss) > 0 {
return fmt.Errorf("this host cannot run a simulated Proxmox:\n - %s", strings.Join(miss, "\n - "))
}
// Sized from the host the first time; whatever was chosen after.
if site["SIM_CORES"] == setup.Defaults()["SIM_CORES"] && site["SIM_MEMORY_GB"] == setup.Defaults()["SIM_MEMORY_GB"] {
c, m := setup.SimDefaults()
site["SIM_CORES"], site["SIM_MEMORY_GB"] = fmt.Sprint(c), fmt.Sprint(m)
}
// Nothing outside this host knows the names: serve them here.
if site["SERVE_MODE"] == "proxy" && site["SERVE_DNS"] == "false" {
site["SERVE_MODE"], site["SERVE_DNS"] = "direct", "true"
}
if err := ask(stProxmox, "Simulated Proxmox", huh.NewForm(huh.NewGroup(
huh.NewNote().Title("Proxmox VE in QEMU, on this host").Description(
"On a private network ("+setup.SimNet+".0/24) with NAT; it never touches yours.\n"+
"Clusters run inside it: give it room for a head and a compute node at least."),
input("SIM_CORES", site), input("SIM_MEMORY_GB", site), input("SIM_DISK_GB", site),
))); err != nil {
return err
}
commit(site)
site.ApplySim()
} else {
site.ClearSim()
var err error
if creds, probe, err = askProxmox(ctx, site); err != nil {
return err
}
}
if err := askSite(site, probe); err != nil {
return err
}
rebuild, go_ := false, true
fields := []huh.Field{huh.NewNote().Title("Ready to install").Description(summary(site))}
if _, err := os.Stat(setup.VarDir + "/head-template-revision"); err == nil {
fields = append(fields, huh.NewConfirm().Title("Rebuild the head node template too?").
Description("Needed after the roles change. About 15 minutes.").
Affirmative("Rebuild").Negative("Keep").Value(&rebuild))
}
fields = append(fields, huh.NewConfirm().Title("Install now?").Affirmative("Install").Negative("Back").Value(&go_))
if err := ask(stReview, "Review", huh.NewForm(huh.NewGroup(fields...))); err != nil || !go_ {
return quiet(err)
}
header.site = site["PORTAL_DOMAIN"]
e := &setup.Env{Site: site, Creds: creds, Exe: o.Exe, Revision: o.Revision, RebuildTemplate: rebuild}
steps, err := setup.StepsFor(site)
if err != nil {
return err
}
if err := runSteps(ctx, "Installing", e, steps, logf, o.LogPath); err != nil {
return err
}
if err := verify(ctx, site); err != nil {
return err
}
test, nodes := false, "1"
if err := ask(stTest, "Test cluster", huh.NewForm(huh.NewGroup(
huh.NewNote().Title("Prove it end to end").Description(
"A real cluster, built the way the portal builds one: a head node and\n"+
"compute nodes, Slurm, a job run across them, then taken down."),
huh.NewConfirm().Title("Build a test cluster now?").Description("About 25 minutes.").
Affirmative("Build it").Negative("Not now").Value(&test),
), huh.NewGroup(
huh.NewSelect[string]().Title("Compute nodes").
Options(huh.NewOption("1 · the scheduler works", "1"),
huh.NewOption("2 · and jobs span nodes", "2")).Value(&nodes),
).WithHideFunc(func() bool { return !test }))); err != nil || !test {
return quiet(err)
}
return selftestN(ctx, o, logf, nodes)
}
// askProxmox asks where Proxmox is and how to get in, and does not return
// until it has signed in - so everything after it is chosen from what is
// there rather than typed.
func askProxmox(ctx context.Context, site setup.Site) (setup.Credentials, *setup.Probe, error) {
method := "password"
var pw, disc, tf string
for {
f := huh.NewForm(
huh.NewGroup(
huh.NewNote().Title("Connect to Proxmox").Description(
"Setup signs in once, to create two API tokens and to let this host in\n"+
"over SSH. The password is not stored."),
input("PVE_ENDPOINT", site),
huh.NewSelect[string]().Title("Its certificate").Options(
huh.NewOption("Proxmox's own, self-signed", "true"),
huh.NewOption("A trusted one", "false")).Value(strPtr(site, "PVE_INSECURE_TLS")),
huh.NewSelect[string]().Title("Sign in with").Options(
huh.NewOption("root@pam's password · setup creates the tokens", "password"),
huh.NewOption("API tokens I made myself", "tokens")).Value(&method),
),
huh.NewGroup(
huh.NewInput().Title("root@pam password").EchoMode(huh.EchoModePassword).Value(&pw).
Validate(nonEmpty),
).WithHideFunc(func() bool { return method != "password" }),
huh.NewGroup(
huh.NewNote().Title("Tokens").Description(
"Discovery: PVEAuditor on /, privilege separation off.\n"+
"Terraform: root@pam's, privilege separation off - PCI passthrough is root's alone.\n"+
"Both as user@realm!id=secret. Add this host's SSH key to root yourself."),
huh.NewInput().Title("Discovery token").Value(&disc).Validate(tokenShape),
huh.NewInput().Title("Terraform token").EchoMode(huh.EchoModePassword).Value(&tf).Validate(tokenShape),
).WithHideFunc(func() bool { return method != "tokens" }),
)
if err := ask(stProxmox, "Proxmox", f); err != nil {
return setup.Credentials{}, nil, err
}
commit(site)
c := setup.Credentials{}
if method == "password" {
c.Password = pw
} else {
c.DiscoveryToken, c.TerraformToken = strings.TrimSpace(disc), strings.TrimSpace(tf)
}
var probe *setup.Probe
err := wait(stProxmox, "Proxmox", "Signing in to "+site["PVE_ENDPOINT"]+" ...", func() error {
var err error
probe, err = setup.ProbeProxmox(ctx, site, c)
if err == nil && c.DiscoveryToken != "" {
// Both tokens are tested, not only the one probed with.
if _, err = setup.ProbeProxmox(ctx, site, setup.Credentials{DiscoveryToken: c.DiscoveryToken}); err != nil {
err = fmt.Errorf("discovery token: %w", err)
}
}
return err
})
if errors.Is(err, context.Canceled) {
return c, nil, huh.ErrUserAborted
}
if err != nil {
pause(err)
continue
}
if site["PVE_HOST"] == "" {
if u, err := url.Parse(site["PVE_ENDPOINT"]); err == nil {
site["PVE_HOST"] = u.Hostname()
}
}
return c, probe, nil
}
}
// askSite asks for everything else, offering Proxmox's own names.
func askSite(site setup.Site, p *setup.Probe) error {
// The address users reach this host at: its route out, not the
// simulated Proxmox's bridge, which only this host can see.
if site["PUBLIC_IP"] == "" {
via := site["MGMT_GATEWAY"]
if site.Sim() || via == "" {
via = "1.1.1.1"
}
site["PUBLIC_IP"] = setup.DefaultPublicIP(via)
}
var groups []*huh.Group
nodeChoice = nil
if p != nil {
groups = append(groups, proxmoxGroup(site, p))
}
groups = append(groups,
huh.NewGroup(
huh.NewNote().Title("Names").Description("The portal's name, and the domain every cluster's portal is a subdomain of."),
input("PORTAL_DOMAIN", site),
input("CLUSTER_DOMAIN", site),
),
huh.NewGroup(
huh.NewNote().Title("How users reach the portal"),
huh.NewSelect[string]().Title("Serving").Options(
huh.NewOption("hpcod serves HTTPS itself, with its own certificate authority", "direct"),
huh.NewOption("Behind my own reverse proxy and certificate", "proxy"),
).Value(strPtr(site, "SERVE_MODE")),
huh.NewSelect[string]().Title("DNS for these names").Options(
huh.NewOption("hpcod answers DNS for them", "true"),
huh.NewOption("My DNS already resolves them", "false"),
).Value(strPtr(site, "SERVE_DNS")),
input("PUBLIC_IP", site),
),
)
// A simulated Proxmox's network is its own, and fixed.
if !site.Sim() {
groups = append(groups, huh.NewGroup(
huh.NewNote().Title("Management network").Description("The /24 this host, Proxmox and every head node share."),
input("MGMT_BRIDGE", site),
input("MGMT_GATEWAY", site),
input("MGMT_FIRST", site),
input("MGMT_COUNT", site),
input("BUILD_IP", site),
input("NAMESERVERS", site),
))
}
groups = append(groups, huh.NewGroup(
huh.NewNote().Title("Head nodes and images").Description("The defaults work; the images are public."),
input("HEAD_TEMPLATE_VMID", site),
input("CI_USER", site),
input("EXTRA_SSH_KEYS", site),
input("REGISTRY_HOST", site),
input("NODE_IMAGE_URI", site),
input("DESKTOP_IMAGE", site),
))
if err := ask(stSite, "Site", huh.NewForm(groups...)); err != nil {
return err
}
commit(site)
site.ApplySim()
// Once more as a whole: a field checked against a neighbour that was
// changed afterwards passed when it was entered.
if errs := site.Validate(); len(errs) > 0 {
var b strings.Builder
for _, e := range errs {
b.WriteString("\n " + e.Error())
}
pause(fmt.Errorf("still not right:%s", b.String()))
return askSite(site, p)
}
return nil
}
// proxmoxGroup asks for the node and datastores, from what Proxmox has.
func proxmoxGroup(site setup.Site, p *setup.Probe) *huh.Group {
if !contains(p.Nodes, site["PVE_NODE"]) && len(p.Nodes) > 0 {
site["PVE_NODE"] = p.Nodes[0]
}
var disks, files []huh.Option[string]
for _, s := range p.Storages {
label := fmt.Sprintf("%-14s %s · %s", s.ID, s.Type, strings.Join(s.Content, ","))
if s.Holds("images") {
disks = append(disks, huh.NewOption(label, s.ID))
}
// Snippets and imports are files, so they need a file-backed store.
switch s.Type {
case "dir", "nfs", "cifs", "cephfs", "glusterfs":
files = append(files, huh.NewOption(label, s.ID))
}
}
pick := func(key string, opts []huh.Option[string]) {
for _, o := range opts {
if o.Value == site[key] {
return
}
}
if len(opts) > 0 {
site[key] = opts[0].Value
}
}
pick("PVE_DATASTORE", disks)
pick("PVE_SNIPPET_DATASTORE", files)
if store, rest, ok := strings.Cut(site["PVE_IMAGE"], ":"); ok && !optionsHave(files, store) && len(files) > 0 {
site["PVE_IMAGE"] = files[0].Value + ":" + rest
}
zones := "none yet"
if len(p.Zones) > 0 {
zones = strings.Join(p.Zones, ", ")
}
fields := []huh.Field{
huh.NewNote().Title("Proxmox VE " + p.Version).Description("Chosen from what " + site["PVE_ENDPOINT"] + " has."),
huh.NewSelect[string]().Title("Node").
Description("Holds the head template; every head node runs here.").
Options(huh.NewOptions(p.Nodes...)...).Value(strPtr(site, "PVE_NODE")),
}
// In a Proxmox cluster, which of its nodes compute nodes may use. Ones
// left unticked are never touched.
nodeChoice = nil
if len(p.Nodes) > 1 {
var sel []string
for _, n := range site.Nodes() {
if contains(p.Nodes, n) {
sel = append(sel, n)
}
}
nodeChoice = &sel
fields = append(fields, huh.NewMultiSelect[string]().Title("Nodes clusters may use").
Description("Compute nodes are spread over these; more than one makes the SDN zone vxlan. Space ticks.").
Options(huh.NewOptions(p.Nodes...)...).Value(nodeChoice).
Validate(func(v []string) error {
if head := strings.TrimSpace(*strPtrPeek("PVE_NODE")); head != "" && !contains(v, head) {
return fmt.Errorf("tick %s too: the heads run there", head)
}
return nil
}))
}
return huh.NewGroup(append(fields,
huh.NewSelect[string]().Title("Datastore for VM disks").Options(disks...).Value(strPtr(site, "PVE_DATASTORE")),
huh.NewSelect[string]().Title("Datastore for cloud-init snippets").
Description("Setup enables snippets on it.").Options(files...).Value(strPtr(site, "PVE_SNIPPET_DATASTORE")),
input("PVE_IMAGE", site),
input("PVE_SDN_ZONE", site).Description("Existing zones: "+zones+". Created if missing."),
input("PVE_HOST", site),
input("SITE_ID", site),
input("SITE_NAME", site),
)...)
}
// strPtrPeek is the value a bound field holds right now.
func strPtrPeek(key string) *string {
if p, ok := bound[key]; ok {
return p
}
empty := ""
return &empty
}
// input is a text field bound to a site key and checked against the rest
// of the site as the form currently holds it.
func input(key string, site setup.Site) *huh.Input {
f, _ := setup.FieldByKey(key)
return huh.NewInput().Title(f.Label).Description(f.Help).Value(strPtr(site, key)).
Validate(func(v string) error { return f.Check(v, live(site)) })
}
// bound holds the pointer each form field writes through, by site key. huh
// updates these as the user types; the site map itself is only updated by
// commit, once a form is submitted.
var bound = map[string]*string{}
// strPtr binds a form field to a site value.
func strPtr(site setup.Site, key string) *string {
if p, ok := bound[key]; ok {
*p = site[key]
return p
}
v := new(string)
*v = site[key]
bound[key] = v
return v
}
// live is the site with what the form holds now laid over it, so a field
// checked against a neighbour sees the neighbour as typed, not as loaded.
func live(site setup.Site) setup.Site {
s := setup.Site{}
for k, v := range site {
s[k] = v
}
for k, p := range bound {
s[k] = strings.TrimSpace(*p)
}
if nodeChoice != nil {
s["PVE_NODES"] = strings.Join(*nodeChoice, ",")
}
return s
}
// commit writes the submitted form back into the site.
func commit(site setup.Site) {
for k, p := range bound {
site[k] = strings.TrimSpace(*p)
}
if nodeChoice != nil {
site["PVE_NODES"] = strings.Join(*nodeChoice, ",")
}
}
// nodeChoice holds the nodes ticked in a Proxmox cluster, when there is
// more than one to tick.
var nodeChoice *[]string
func summary(s setup.Site) string {
access := "behind your reverse proxy"
if s.Direct() {
access = "HTTPS served here at " + s["PUBLIC_IP"] + ", with its own CA"
}
if s.DNS() {
access += "; DNS answered here"
}
where := fmt.Sprintf("%s, node %s, disks on %s, snippets on %s",
s["PVE_ENDPOINT"], s["PVE_NODE"], s["PVE_DATASTORE"], s["PVE_SNIPPET_DATASTORE"])
if n := s.Nodes(); len(n) > 1 {
where = fmt.Sprintf("%s, heads on %s, compute on %s (vxlan), disks on %s, snippets on %s",
s["PVE_ENDPOINT"], s["PVE_NODE"], strings.Join(n, " "), s["PVE_DATASTORE"], s["PVE_SNIPPET_DATASTORE"])
}
if s.Sim() {
where = fmt.Sprintf("simulated, in QEMU here: %s cores, %s GiB, %s GiB disk",
s["SIM_CORES"], s["SIM_MEMORY_GB"], s["SIM_DISK_GB"])
}
row := func(k, v string) string { return sDim.Render(fmt.Sprintf("%-10s", k)) + " " + sText.Render(v) + "\n" }
return row("Portal", "https://"+s["PORTAL_DOMAIN"]+" (clusters: c<NNN>."+s["CLUSTER_DOMAIN"]+")") +
row("Access", access) +
row("Proxmox", where) +
row("Network", fmt.Sprintf("%s via %s; heads from %s (+%s)", s["MGMT_BRIDGE"], s["MGMT_GATEWAY"], s["MGMT_FIRST"], s["MGMT_COUNT"])) +
row("Heads", fmt.Sprintf("template %s, login %s", s["HEAD_TEMPLATE_VMID"], s["CI_USER"])) +
"\n" + sDim.Render("Installs PostgreSQL, Ansible and OpenTofu, the database, keys and service,\n"+
"prepares Proxmox, and builds the head node template if there is none.\n"+
"Every step reads back what it changed, and is safe to run again.")
}
// verify checks the installation and shows the result.
func verify(ctx context.Context, site setup.Site) error {
var rs []setup.Result
_ = wait(stCheck, "Check", "Checking the installation ...", func() error {
rs = setup.Verify(ctx, &setup.Env{Site: site})
return nil
})
page(stCheck, "Installation check", resultsText(rs, setup.UserInstructions(site)))
return nil
}
// PrintResults prints verification results grouped, with a verdict, for
// `hpcod verify` on a plain terminal.
func PrintResults(w io.Writer, rs []setup.Result) {
group := ""
fails, warns := 0, 0
for _, r := range rs {
if r.Group != group {
group = r.Group
fmt.Fprintln(w, sDim.Render(" "+group))
}
mark := sOK.Render("✓")
switch r.Status {
case setup.Fail:
mark, fails = sFail.Render("✗"), fails+1
case setup.Warn:
mark, warns = sWarn.Render("!"), warns+1
}
line := " " + mark + " " + r.Name
if r.Detail != "" {
line += sDim.Render(" " + r.Detail)
}
fmt.Fprintln(w, line)
}
fmt.Fprintln(w)
if fails > 0 {
fmt.Fprintln(w, sFail.Render(fmt.Sprintf("NOT READY: %d failed, %s", fails, plural(warns, "warning"))))
} else {
fmt.Fprintln(w, sOK.Render(fmt.Sprintf("READY: nothing failed, %s", plural(warns, "warning"))))
}
}
func selftest(ctx context.Context, o Options, logf io.Writer) error {
nodes := "1"
if err := ask(stTest, "Test cluster", huh.NewForm(huh.NewGroup(
huh.NewNote().Title("Prove it end to end").Description(
"Built the way the portal builds one, a job run across it, then taken down."),
huh.NewSelect[string]().Title("Compute nodes").
Options(huh.NewOption("1 · the scheduler works", "1"),
huh.NewOption("2 · and jobs span nodes", "2")).Value(&nodes),
))); err != nil {
return err
}
return selftestN(ctx, o, logf, nodes)
}
// selftestN runs `hpcod selftest` as a child: it re-runs itself as the
// service account, whose files Terraform's state must be.
func selftestN(ctx context.Context, o Options, logf io.Writer, nodes string) error {
return runTask(ctx, stTest, "Test cluster with "+nodes+" compute node(s)", func(ctx context.Context, out io.Writer) error {
cmd := exec.CommandContext(ctx, o.Exe, "selftest", "-compute", nodes)
cmd.Dir = "/"
cmd.Stdout, cmd.Stderr = out, out
return cmd.Run()
}, logf, o.LogPath)
}
func quiet(err error) error {
if errors.Is(err, huh.ErrUserAborted) {
return nil
}
return err
}
func nonEmpty(v string) error {
if v == "" {
return errors.New("required")
}
return nil
}
func tokenShape(v string) error {
v = strings.TrimSpace(v)
if !strings.Contains(v, "@") || !strings.Contains(v, "!") || !strings.Contains(v, "=") {
return errors.New("expected user@realm!id=secret")
}
return nil
}
func contains(l []string, v string) bool {
for _, x := range l {
if x == v {
return true
}
}
return false
}
func optionsHave(o []huh.Option[string], v string) bool {
for _, x := range o {
if x.Value == v {
return true
}
}
return false
}