Skip to content

Commit

Permalink
Add additional device naming formats to formatPartition template fu…
Browse files Browse the repository at this point in the history
…nc (#771)

## Description


This allows for using the formatPartition func for more device types. `vd*` is a device created by virtio. `hd*` for legacy IDE hard disks.

Also use `hello-world` image instead of `alpine` in the `TestDockerImageNotPresent` unit test.

## Why is this needed



Fixes: #770 

## How Has This Been Tested?





## How are existing users impacted? What migration steps/scripts do we need?





## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
  • Loading branch information
mergify[bot] authored Jul 17, 2023
2 parents 7c4c6a0 + 7b5ba2b commit 1a0edeb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/agent/runtime/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestDockerImageNotPresent(t *testing.T) {
t.Fatalf("Received unexpected error: %v", err)
}

image := "alpine"
image := "hello-world"

images, err := clnt.ImageList(context.Background(), types.ImageListOptions{
Filters: filters.NewArgs(filters.Arg("reference", image)),
Expand Down
3 changes: 2 additions & 1 deletion internal/workflow/template_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ var templateFuncs = map[string]interface{}{
//
// formatPartition("/dev/nvme0n1", 0) -> /dev/nvme0n1p1
// formatPartition("/dev/sda", 1) -> /dev/sda1
// formatPartition("/dev/vda", 2) -> /dev/vda2
func formatPartition(dev string, partition int) string {
switch {
case strings.HasPrefix(dev, "/dev/nvme"):
return fmt.Sprintf("%vp%v", dev, partition)
case strings.HasPrefix(dev, "/dev/sd"):
case strings.HasPrefix(dev, "/dev/sd"), strings.HasPrefix(dev, "/dev/vd"), strings.HasPrefix(dev, "/dev/hd"):
return fmt.Sprintf("%v%v", dev, partition)
}
return dev
Expand Down

0 comments on commit 1a0edeb

Please sign in to comment.