Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
fix: replace / with - in anonymous ephemeral volume names (manager-sp…
Browse files Browse the repository at this point in the history
…ecific)

Signed-off-by: Thorsten Klein <[email protected]>
  • Loading branch information
iwilltry42 committed Nov 23, 2023
1 parent 62927ea commit 10bde5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/internal.acorn.io/v1/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ func parseVolumeDefinition(anonName, s string) (VolumeBinding, error) {
if u.Scheme == "ephemeral" {
result.Class = u.Scheme
if result.Volume == "" {
result.Volume = anonName
result.Volume = strings.ReplaceAll(anonName, "/", "-") // While a path-style name is OK in runtime, it breaks as resource name in manager
}
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/appdefinition/appdefinition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"testing"

"cuelang.org/go/cue/errors"
Expand Down Expand Up @@ -1380,8 +1381,8 @@ volumes: {
assert.Equal(t, v1.AccessModes{"readWriteMany", "readWriteOnce"}, appSpec.Volumes["uri"].AccessModes)
assert.Equal(t, v1.Quantity(""), appSpec.Volumes["uri-sub"].Size)
assert.Nil(t, appSpec.Volumes["uri-sub"].AccessModes)
assert.Equal(t, "ephemeral", appSpec.Volumes["s/left/var/anon-ephemeral-vol"].Class)
assert.Equal(t, "ephemeral", appSpec.Volumes["s/left/var/anon-ephemeral2-vol"].Class)
assert.Equal(t, "ephemeral", appSpec.Volumes["s-left-var-anon-ephemeral-vol"].Class)
assert.Equal(t, "ephemeral", appSpec.Volumes["s-left-var-anon-ephemeral2-vol"].Class)
assert.Equal(t, "ephemeral", appSpec.Volumes["eph"].Class)
assert.Len(t, typed.SortedKeys(appSpec.Volumes), 11)

Expand All @@ -1396,9 +1397,9 @@ volumes: {
assert.Equal(t, "", sidecar.Dirs["/var/uri-vol"].SubPath)
assert.Equal(t, "uri-sub", sidecar.Dirs["/var/uri-sub-vol"].Volume)
assert.Equal(t, "sub", sidecar.Dirs["/var/uri-sub-vol"].SubPath)
assert.Equal(t, filepath.Join("s", "left", "var", "anon-ephemeral-vol"), sidecar.Dirs["/var/anon-ephemeral-vol"].Volume)
assert.Equal(t, strings.ReplaceAll(filepath.Join("s", "left", "var", "anon-ephemeral-vol"), "/", "-"), sidecar.Dirs["/var/anon-ephemeral-vol"].Volume)
assert.Equal(t, "", sidecar.Dirs["/var/anon-ephemeral-vol"].SubPath)
assert.Equal(t, filepath.Join("s", "left", "var", "anon-ephemeral2-vol"), sidecar.Dirs["/var/anon-ephemeral2-vol"].Volume)
assert.Equal(t, strings.ReplaceAll(filepath.Join("s", "left", "var", "anon-ephemeral2-vol"), "/", "-"), sidecar.Dirs["/var/anon-ephemeral2-vol"].Volume)
assert.Equal(t, "", sidecar.Dirs["/var/anon-ephemeral2-vol"].SubPath)
assert.Equal(t, "eph", sidecar.Dirs["/var/named-ephemeral-vol"].Volume)
assert.Equal(t, "", sidecar.Dirs["/var/named-ephemeral-vol"].SubPath)
Expand Down

0 comments on commit 10bde5f

Please sign in to comment.