Skip to content

Commit

Permalink
fix: pass UDS_ARCHITECTURE to runner (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
decleaver committed Mar 14, 2024
1 parent 394f09b commit b376df5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/cmd/vendored.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ var runnerCmd = &cobra.Command{
os.Args = os.Args[1:] // grab 'run' and onward from the CLI args
runnerConfig.CmdPrefix = "uds" // use vendored Zarf inside the runner
runnerConfig.EnvPrefix = "uds"
// The maru runner init gets called before the uds-cli init, which looks for RUN_ARCHITECTURE because the EnvPrefix
// that we set above is not called yet. So in order to set the architecture if passing in UDS_ARCHITECTURE we must set it here.
archValue := os.Getenv("UDS_ARCHITECTURE")
if archValue != "" {
runnerConfig.CLIArch = archValue
}
runnerCLI.RootCmd().SetArgs(os.Args)
runnerCLI.Execute()
},
Expand Down
16 changes: 15 additions & 1 deletion src/test/e2e/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ func TestTaskRunner(t *testing.T) {
})

t.Run("test task to load env vars using the envPath key", func(t *testing.T) {
t.Parallel()
stdOut, stdErr, err := e2e.UDS("run", "env-from-file", "--file", "src/test/tasks/tasks.yaml")
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, e2e.Arch)
Expand All @@ -349,4 +348,19 @@ func TestTaskRunner(t *testing.T) {
require.NotContains(t, stdErr, "default")
require.Contains(t, stdErr, "env-var")
})
t.Run("test that ARCHITECTURE env var is getting passed to runner", func(t *testing.T) {
os.Setenv("UDS_ARCHITECTURE", "amd64")
stdOut, stdErr, err := e2e.UDS("run", "echo-architecture", "--file", "src/test/tasks/tasks.yaml")
require.NoError(t, err, stdOut, stdErr)
require.NotContains(t, stdErr, "arm64")
require.Contains(t, stdErr, "amd64")

os.Setenv("UDS_ARCHITECTURE", "arm64")
stdOut, stdErr, err = e2e.UDS("run", "echo-architecture", "--file", "src/test/tasks/tasks.yaml")
require.NoError(t, err, stdOut, stdErr)
require.NotContains(t, stdErr, "amd64")
require.Contains(t, stdErr, "arm64")

os.Setenv("UDS_ARCHITECTURE", "")
})
}
4 changes: 4 additions & 0 deletions src/test/tasks/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,7 @@ tasks:
actions:
- cmd: cat ${COOL_FILE}
dir: ${COOL_DIR}
- name: echo-architecture
description: Echos the architecture being used for the task by the runner
actions:
- cmd: echo "${UDS_ARCH}"

0 comments on commit b376df5

Please sign in to comment.