Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass UDS_ARCHITECTURE to runner #506

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"
Loading