Gitfed
bastien-mrq/gitfed / cmd / gitfed-install / main.go
// gitfed-install is an interactive terminal wizard that deploys gitfed on
// a fresh VPS: installs k3s/cert-manager if missing, builds and imports
// the image with the correct tag, applies the manifests, waits for the
// pod to come up (diagnosing the ErrImageNeverPull tag-mismatch case
// specifically if it does), verifies the live endpoints, then hands off
// to gitfed-tui for the first account. See INSTALL.md for the same steps
// done by hand — this automates that guide, it doesn't replace it.
//
// Deliberately a separate binary from the four shipped in the gitfed
// container image (see deploy/docker/Dockerfile): it shells out to
// docker/kubectl/git on the *host*, before the pod even exists, so it can
// never run inside the container it's installing.
package main

import (
	"flag"
	"fmt"
	"os"

	tea "github.com/charmbracelet/bubbletea"
)

func main() {
	source := flag.String("source", defaultSourceURL, "gitfed source repository to clone and build")
	flag.Parse()

	m := initialModel(*source)
	p := tea.NewProgram(m)
	finalModel, err := p.Run()
	if err != nil {
		fmt.Fprintf(os.Stderr, "gitfed-install: %v\n", err)
		os.Exit(1)
	}
	if fm, ok := finalModel.(model); ok && fm.fatalErr != nil {
		fmt.Fprintf(os.Stderr, "gitfed-install: %v\n", fm.fatalErr)
		os.Exit(1)
	}
}