From deb9cd01de503baadc6c41ec4fbbe99b04db6ba3 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 31 Mar 2025 14:22:58 -0600 Subject: chore: export step env vars with each command --- magefiles/step.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'magefiles/step.go') diff --git a/magefiles/step.go b/magefiles/step.go index 0270802..25cf23b 100644 --- a/magefiles/step.go +++ b/magefiles/step.go @@ -46,7 +46,8 @@ func (s Step) Setup() { } func (s Step) Install() error { - return sh.Run( + return sh.RunWithV( + s.env(), "step", "certificate", "install", @@ -57,11 +58,8 @@ func (s Step) Install() error { func (s Step) Server(ctx context.Context) error { mg.SerialDeps(s.Setup) - env := map[string]string{ - "STEPPATH": s.path(), - } return sh.RunWithV( - env, + s.env(), "step-ca", s.pathPlus("config/ca.json"), "--password-file="+s.pathPlus("password.txt"), @@ -94,7 +92,8 @@ func (s Step) createCA() error { return nil } - return sh.Run( + return sh.RunWithV( + s.env(), "step", "ca", "init", @@ -122,7 +121,7 @@ func (s Step) enableACMEProvisioner() error { provisioners := items["authority"].(map[string]interface{})["provisioners"].([]interface{}) if len(provisioners) < 2 { - return sh.Run("step", "ca", "provisioner", "add", "acme", "--type", "ACME") + return sh.RunWithV(s.env(), "step", "ca", "provisioner", "add", "acme", "--type", "ACME") } return nil } @@ -135,6 +134,14 @@ func (s Step) path() string { return env.Fetch("STEPPATH", filepath.Join(x.Must(os.Getwd()), "/tmp/step")) } +func (s Step) env() map[string]string { + return map[string]string{ + "STEPPATH": s.path(), + "HOST": "localhost", + "PORT": "8081", + } +} + func (s Step) pathPlus(path string) string { return filepath.Join(s.path(), path) } -- cgit v1.2.3