Skip to content

Commit

Permalink
chore: test getArch (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanHoladay authored May 20, 2024
1 parent 9050b07 commit 33de138
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ As an example: `uds remove uds-bundle-<name>.tar.zst --packages init,nginx`
The `uds logs` command can be used to view the most recent logs of a bundle operation. Note that depending on your OS temporary directory and file settings, recent logs are purged after a certain amount of time, so this command may return an error if the logs are no longer available.

## Bundle Architecture and Multi-Arch Support
There are several ways to specify the architecture of a bundle:
There are several ways to specify the architecture of a bundle according to the following precedence:
1. Setting `--architecture` or `-a` flag during `uds ...` operations: `uds create <dir> --architecture arm64`
2. Setting the `metadata.architecture` key in a `uds-bundle.yaml`
3. Setting a `UDS_ARCHITECTURE` environment variable
4. Setting the `options.architecture` key in a `uds-config.yaml`
2. Setting a `UDS_ARCHITECTURE` environment variable
3. Setting the `options.architecture` key in a `uds-config.yaml`
4. Setting the `metadata.architecture` key in a `uds-bundle.yaml`

Note that the setting the `--architecture` flag takes precedence over all other methods of specifying the architecture.
This means that setting the `--architecture` flag takes precedence over all other methods of specifying the architecture.

UDS CLI supports multi-arch bundles. This means you can push bundles with different architectures to the same remote OCI repository, at the same tag. For example, you can push both an `amd64` and `arm64` bundle to `ghcr.io/<org>/<bundle name>:0.0.1`.

Expand Down
48 changes: 48 additions & 0 deletions src/cmd/cmd_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package cmd

import (
"testing"

"github.com/defenseunicorns/uds-cli/src/config"
"github.com/defenseunicorns/uds-cli/src/types"
"github.com/stretchr/testify/require"
)

func TestSettingArchitecture(t *testing.T) {
testCases := []struct {
name string
cliArch string
bundle *types.UDSBundle
expectedVal string
}{
{
name: "CLIArch takes precedence",
cliArch: "archFromFlag",
bundle: &types.UDSBundle{
Metadata: types.UDSMetadata{
Architecture: "setFromMetadata",
},
},
expectedVal: "archFromFlag",
},
{
name: "Metadata.Arch",
cliArch: "",
bundle: &types.UDSBundle{
Metadata: types.UDSMetadata{
Architecture: "setFromMetadata",
},
},
expectedVal: "setFromMetadata",
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
b := tc.bundle
config.CLIArch = tc.cliArch
b.Build.Architecture = config.GetArch(b.Metadata.Architecture)
require.Equal(t, tc.expectedVal, b.Build.Architecture)
})
}
}

0 comments on commit 33de138

Please sign in to comment.