- Add .gitignore: exclude compiled binaries, build artifacts, and Helm values files containing real secrets (authentik, prometheus) - Add all Kubernetes deployment manifests (deployment/) - Add services source code: ha-sync, device-inventory, games-console, paperclip, parts-inventory - Add Ansible orchestration: playbooks, roles, inventory, cloud-init - Add hardware specs, execution plans, scripts, HOMELAB.md - Add skills/homelab/SKILL.md + skills/install.sh to preserve Copilot skill - Remove previously-tracked inventory-cli binary from git index Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/vandachevici/games-console/internal/api"
|
|
"github.com/vandachevici/games-console/internal/k8s"
|
|
)
|
|
|
|
var (
|
|
port string
|
|
namespace string
|
|
)
|
|
|
|
var rootCmd = &cobra.Command{
|
|
Use: "games-console-server",
|
|
Short: "Games Console backend API server",
|
|
}
|
|
|
|
var serveCmd = &cobra.Command{
|
|
Use: "serve",
|
|
Short: "Start the REST API server",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
client, err := k8s.NewClient(namespace)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to create k8s client: %w", err)
|
|
}
|
|
|
|
router := api.NewRouter(client)
|
|
addr := ":" + port
|
|
fmt.Printf("games-console-server listening on %s (namespace: %s)\n", addr, namespace)
|
|
return http.ListenAndServe(addr, router)
|
|
},
|
|
}
|
|
|
|
func Execute() {
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
serveCmd.Flags().StringVarP(&port, "port", "p", "8080", "Port to listen on")
|
|
serveCmd.Flags().StringVarP(&namespace, "namespace", "n", "games", "Kubernetes namespace to manage")
|
|
rootCmd.AddCommand(serveCmd)
|
|
}
|