Separate tracked source from generated artifacts so the repo root stops accumulating helper scripts, manifests, and local runtime outputs. Move manual shell entrypoints under scripts/, manifests under config/, and the Firecracker API reference under docs/reference/. Make build and runtimebundle now target build/bin, build/runtime, and build/dist as the canonical source-checkout paths. Update runtime discovery, helper scripts, tests, and docs to follow the new layout while keeping legacy source-checkout runtime fallbacks for existing local bundles during migration. Validated with bash -n on the moved scripts, make build, and GOCACHE=/tmp/banger-gocache go test ./....
78 lines
1.8 KiB
Go
78 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"banger/internal/runtimebundle"
|
|
)
|
|
|
|
const (
|
|
defaultManifestPath = "config/runtime-bundle.toml"
|
|
defaultRuntimeDir = "build/runtime"
|
|
defaultArchivePath = "build/dist/banger-runtime.tar.gz"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) < 2 {
|
|
usage()
|
|
os.Exit(2)
|
|
}
|
|
switch os.Args[1] {
|
|
case "fetch":
|
|
if err := fetch(os.Args[2:]); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
case "package":
|
|
if err := pkg(os.Args[2:]); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
default:
|
|
usage()
|
|
os.Exit(2)
|
|
}
|
|
}
|
|
|
|
func fetch(args []string) error {
|
|
fs := flag.NewFlagSet("fetch", flag.ContinueOnError)
|
|
fs.SetOutput(os.Stderr)
|
|
manifestPath := fs.String("manifest", defaultManifestPath, "path to the runtime bundle manifest")
|
|
outDir := fs.String("out", defaultRuntimeDir, "destination runtime directory")
|
|
if err := fs.Parse(args); err != nil {
|
|
return err
|
|
}
|
|
manifest, err := runtimebundle.LoadManifest(*manifestPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return runtimebundle.Bootstrap(context.Background(), manifest, *manifestPath, *outDir)
|
|
}
|
|
|
|
func pkg(args []string) error {
|
|
fs := flag.NewFlagSet("package", flag.ContinueOnError)
|
|
fs.SetOutput(os.Stderr)
|
|
manifestPath := fs.String("manifest", defaultManifestPath, "path to the runtime bundle manifest")
|
|
runtimeDir := fs.String("runtime-dir", defaultRuntimeDir, "runtime directory to package")
|
|
outArchive := fs.String("out", defaultArchivePath, "output archive path")
|
|
if err := fs.Parse(args); err != nil {
|
|
return err
|
|
}
|
|
manifest, err := runtimebundle.LoadManifest(*manifestPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
sum, err := runtimebundle.Package(*runtimeDir, *outArchive, manifest)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(sum)
|
|
return nil
|
|
}
|
|
|
|
func usage() {
|
|
fmt.Fprintln(os.Stderr, "usage: runtimebundle <fetch|package> [flags]")
|
|
}
|