feat(archie): wire enterprise rekey, OIDC/SoD, audit, telemetry, and bundles (#2153, #2154, #2155, #2156, #2157, #2158)

This commit is contained in:
sam committed 2026-11-27 21:20:33 +11:00
1 parent 07d30c95ca
commit dd38d93a29
6 files changed
+687 -41

No files matched your search

+50 -1
View File
@@ -4,18 +4,27 @@ package main
import (
"context"
"errors"
"flag"
"fmt"
"os"
"os/signal"
"strings"
"syscall"
"github.com/samcharles93/archie-core/internal/app/archie"
"github.com/samcharles93/archie-core/internal/buildinfo"
)
type exitCodeError int
func (e exitCodeError) Error() string { return fmt.Sprintf("exit %d", int(e)) }
func main() {
if err := run(); err != nil {
if code, ok := errors.AsType[exitCodeError](err); ok {
os.Exit(int(code))
}
fmt.Fprintln(os.Stderr, "archie:", err)
os.Exit(1)
}
@@ -27,7 +36,7 @@ func run() error {
newIdentity := flag.Bool("new-age-identity", false, "print a new age identity for age_identity and exit")
showVersion := buildinfo.RegisterVersionFlag("archie")
flag.Usage = func() {
_, _ = fmt.Fprintln(flag.CommandLine.Output(), "usage: archie [flags]\n archie migrate apply database migrations and runtime grants\n archie bootstrap idempotently provision initial owner and SSO settings\n archie openapi print the API's OpenAPI document")
_, _ = fmt.Fprintln(flag.CommandLine.Output(), "usage: archie [flags]\n archie migrate apply database migrations and runtime grants\n archie bootstrap idempotently provision initial owner and SSO settings\n archie rekey rotate age sealing identities in one transaction\n archie bundle validate, export, diff, or apply promotion bundles\n archie openapi print the API's OpenAPI document")
flag.PrintDefaults()
}
flag.Parse()
@@ -45,6 +54,17 @@ func run() error {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
return archie.Bootstrap(ctx, *configPath, *specPath)
case "rekey":
return runRekey(*configPath, flag.Args()[1:])
case "bundle":
code, err := runBundle(*configPath, flag.Args()[1:])
if err != nil {
return err
}
if code != 0 {
return exitCodeError(code)
}
return nil
case "openapi":
doc, err := archie.Document()
if err != nil {
@@ -60,3 +80,32 @@ func run() error {
defer stop()
return archie.Run(ctx, *configPath)
}
func runRekey(configPath string, args []string) error {
fs := flag.NewFlagSet("rekey", flag.ContinueOnError)
oldIdentity := fs.String("old-identity", "", "current age identity (or ARCHIE_OLD_AGE_IDENTITY[_FILE])")
newIdentity := fs.String("new-identity", "", "replacement age identity (or ARCHIE_NEW_AGE_IDENTITY[_FILE])")
newBackupsRaw := fs.String("new-backups", "", "comma-separated age backup recipients for re-sealed values")
if err := fs.Parse(args); err != nil {
return err
}
var newBackups []string
for r := range strings.SplitSeq(*newBackupsRaw, ",") {
if r = strings.TrimSpace(r); r != "" {
newBackups = append(newBackups, r)
}
}
rcfg, err := archie.LoadRekeyConfig(*oldIdentity, *newIdentity, newBackups)
if err != nil {
return err
}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
return archie.Rekey(ctx, configPath, rcfg)
}
func runBundle(configPath string, args []string) (int, error) {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
return archie.RunBundleCLI(ctx, configPath, args, os.Stdout)
}