Commit f7065e0

mo khan <mo@mokhan.ca>
2025-03-29 03:40:05
chore: extract magefiles directory
1 parent 9d4cc3d
Changed files (1)
magefiles
magefile.go → magefiles/magefile.go
@@ -5,6 +5,7 @@ package main
 
 import (
 	"context"
+	"os"
 	"path/filepath"
 
 	"github.com/magefile/mage/mg"
@@ -63,6 +64,32 @@ func Authzd() error {
 	return sh.RunWithV(env, "go", "run", "./cmd/authzd/main.go")
 }
 
+// Start NATS server
+func Nats() error {
+	return sh.RunV(
+		"nats-server",
+		"--addr=127.0.0.1",
+		"--port=4222",
+		"--http_port=8222",
+		"--pid=tmp/pids/nats.pid",
+		"--jetstream",
+		"--store_dir=tmp/nats/store",
+	)
+}
+
+// Start CA
+func CertificateAuthority() error {
+	env := map[string]string{
+		"STEPPATH": filepath.Join(x.Must(os.Getwd()), "/tmp/step"),
+	}
+	return sh.RunWithV(
+		env,
+		"step-ca",
+		"$STEPPATH/config/ca.json",
+		"--password-file=$STEPPATH/password.txt",
+	)
+}
+
 // Generate gRPC from protocal buffers
 func Protos() error {
 	for _, file := range x.Must(filepath.Glob("./protos/*.proto")) {
@@ -86,7 +113,7 @@ func Protos() error {
 
 // Run All the servers
 func Servers(ctx context.Context) {
-	mg.CtxDeps(ctx, Idp, UI, Api, Authzd, Gateway)
+	mg.CtxDeps(ctx, CertificateAuthority, Nats, Idp, UI, Api, Authzd, CertificateAuthority, Gateway)
 }
 
 // Run the end to end tests