Skip to content

Commit

Permalink
chore!: remove architecture from maru (#173)
Browse files Browse the repository at this point in the history
## Description

Removes the architecture concept from Maru - right now this is not used
internal to Maru and causes breakage when vendored into apps like UDS
CLI.

> [!CAUTION]
> ⚠️ **BREAKING CHANGE** - this is technically a breaking change
for any users of the MARU_ARCH variable - this was not widely publicized
in docs and likely made little sense to users so usage is expected to
have been minimal (though still technically breaking).

## Related Issue

Fixes #N/A

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [X] Other (security config, docs update, etc)

## Checklist before merging

- [X] Test, docs, adr added or updated as needed
- [X] [Contributor Guide
Steps](https://github.com/defenseunicorns/maru-runner/blob/main/CONTRIBUTING.md)
followed
  • Loading branch information
Racer159 authored Nov 22, 2024
1 parent 71f0068 commit 30c7a92
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 39 deletions.
1 change: 0 additions & 1 deletion src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func init() {
v.SetDefault(V_TMP_DIR, "")

rootCmd.PersistentFlags().StringVarP(&logLevelString, "log-level", "l", v.GetString(V_LOG_LEVEL), lang.RootCmdFlagLogLevel)
rootCmd.PersistentFlags().StringVarP(&config.CLIArch, "architecture", "a", v.GetString(V_ARCHITECTURE), lang.RootCmdFlagArch)
rootCmd.PersistentFlags().BoolVar(&message.NoProgress, "no-progress", v.GetBool(V_NO_PROGRESS), lang.RootCmdFlagNoProgress)
rootCmd.PersistentFlags().BoolVar(&skipLogFile, "no-log-file", v.GetBool(V_NO_LOG_FILE), lang.RootCmdFlagSkipLogFile)
rootCmd.PersistentFlags().StringVar(&config.TempDirectory, "tmpdir", v.GetString(V_TMP_DIR), lang.RootCmdFlagTempDir)
Expand Down
24 changes: 1 addition & 23 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
// Package config contains configuration strings for maru
package config

import (
"runtime"
)

const (
// TasksYAML is the string for the default tasks.yaml
TasksYAML = "tasks.yaml"
Expand All @@ -17,9 +13,6 @@ const (
)

var (
// CLIArch is the computer architecture of the device executing the CLI commands
CLIArch string

// CLIVersion track the version of the CLI
CLIVersion = "unset"

Expand All @@ -39,24 +32,9 @@ var (
// MaxStack is the maximum stack size for task references
MaxStack = 2048

extraEnv = map[string]string{"MARU": "true", "MARU_ARCH": GetArch()}
extraEnv = map[string]string{"MARU": "true"}
)

// GetArch returns the arch based on a priority list with options for overriding.
func GetArch(archs ...string) string {
// List of architecture overrides.
priority := append([]string{CLIArch}, archs...)

// Find the first architecture that is specified.
for _, arch := range priority {
if arch != "" {
return arch
}
}

return runtime.GOARCH
}

// AddExtraEnv adds a new envirmentment variable to the extraEnv to make it available to actions
func AddExtraEnv(key string, value string) {
extraEnv[key] = value
Expand Down
12 changes: 0 additions & 12 deletions src/test/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
// MaruE2ETest Struct holding common fields most of the tests will utilize.
type MaruE2ETest struct {
MaruBinPath string
Arch string
ApplianceMode bool
ApplianceModeKeep bool
RunClusterTests bool
Expand Down Expand Up @@ -57,17 +56,6 @@ func (e2e *MaruE2ETest) CleanFiles(files ...string) {
}
}

// GetMismatchedArch determines what architecture our tests are running on,
// and returns the opposite architecture.
func (e2e *MaruE2ETest) GetMismatchedArch() string {
switch e2e.Arch {
case "arm64":
return "amd64"
default:
return "arm64"
}
}

// GetLogFileContents gets the log file contents from a given run's std error.
func (e2e *MaruE2ETest) GetLogFileContents(t *testing.T, stdErr string) string {
get, err := helpers.MatchRegex(logRegex, stdErr)
Expand Down
2 changes: 0 additions & 2 deletions src/test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"path"
"testing"

"github.com/defenseunicorns/maru-runner/src/config"
"github.com/defenseunicorns/maru-runner/src/test"
)

Expand Down Expand Up @@ -50,7 +49,6 @@ func doAllTheThings(m *testing.M) (int, error) {
var err error

// Set up constants in the global variable that all the tests are able to access
e2e.Arch = config.GetArch()
e2e.MaruBinPath = path.Join("build", test.GetCLIName())
e2e.ApplianceMode = os.Getenv(applianceModeEnvVar) == "true"
e2e.ApplianceModeKeep = os.Getenv(applianceModeKeepEnvVar) == "true"
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ func TestTaskRunner(t *testing.T) {
t.Parallel()
stdOut, stdErr, err := e2e.Maru("run", "env-from-file", "--file", "src/test/tasks/tasks.yaml")
require.NoError(t, err, stdOut, stdErr)
require.Contains(t, stdErr, e2e.Arch)
require.Contains(t, stdErr, "not-a-secret")
require.Contains(t, stdErr, "3000")
require.Contains(t, stdErr, "$env/**/*var with#special%chars!")
Expand Down

0 comments on commit 30c7a92

Please sign in to comment.