Files
kforge/cmd/root.go
T
nate.lubitz 532b912ffb
Build and Deploy / build-and-deploy (push) Failing after 20s
add tool to gitea
2026-06-05 02:34:00 +10:00

50 lines
1.2 KiB
Go

package cmd
import (
"fmt"
"os"
"kforge/internal/config"
"github.com/spf13/cobra"
)
var cfgFile string
var rootCmd = &cobra.Command{
Use: "kforge",
Short: "kforge — Kubernetes manifest generator for your homelab",
Long: `kforge reads a kforge.yml file and generates flat Kubernetes
manifests for each environment. It handles namespacing, TLS,
ingress, infrastructure (CNPG, Valkey, NATS, Minio, Meilisearch),
cron jobs, and DNS record creation via Cloudflare.
Get started:
kforge validate Check your kforge.yml and secrets
kforge generate Generate manifests for all environments
kforge generate --env production --dry-run
kforge secrets list Show required secrets checklist`,
}
func init() {
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "kforge.yml",
"Path to kforge.yml")
}
// Execute runs the root command. Called from main().
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
// loadConfig is a shared helper used by all subcommands.
func loadConfig() (*config.KforgeConfig, error) {
cfg, err := config.Load(cfgFile)
if err != nil {
return nil, fmt.Errorf("loading %s: %w", cfgFile, err)
}
return cfg, nil
}