diff --git a/aci/convert/convert.go b/aci/convert/convert.go index d35b410b9..12289f562 100644 --- a/aci/convert/convert.go +++ b/aci/convert/convert.go @@ -207,7 +207,7 @@ func (p projectAciHelper) getAciFileVolumes(ctx context.Context, helper login.St if v.Driver == azureFileDriverName { shareName, ok := v.DriverOpts[volumeDriveroptsShareNameKey] if !ok { - return nil, nil, fmt.Errorf("cannot retrieve share name for Azurefile") + return nil, nil, fmt.Errorf("cannot retrieve fileshare name for Azurefile") } accountName, ok := v.DriverOpts[volumeDriveroptsAccountNameKey] if !ok { diff --git a/aci/convert/volume.go b/aci/convert/volume.go index cfffca598..60daac3bb 100644 --- a/aci/convert/volume.go +++ b/aci/convert/volume.go @@ -42,8 +42,8 @@ func GetRunVolumes(volumes []string) (map[string]types.VolumeConfig, []types.Ser Name: vi.name, Driver: azureFileDriverName, DriverOpts: map[string]string{ - volumeDriveroptsAccountNameKey: vi.username, - volumeDriveroptsShareNameKey: vi.share, + volumeDriveroptsAccountNameKey: vi.storageAccount, + volumeDriveroptsShareNameKey: vi.fileshare, }, } sv := types.ServiceVolumeConfig{ @@ -58,29 +58,30 @@ func GetRunVolumes(volumes []string) (map[string]types.VolumeConfig, []types.Ser } type volumeInput struct { - name string - username string - share string - target string + name string + storageAccount string + fileshare string + target string } func (v *volumeInput) parse(name string, s string) error { v.name = name - tokens := strings.Split(s, "@") - if len(tokens) < 2 || tokens[0] == "" { - return errors.Wrapf(errdefs.ErrParsingFailed, "volume specification %q does not include a storage account before '@'", v) + tokens := strings.Split(s, ":") + source := tokens[0] + sourceTokens := strings.Split(source, "/") + if len(sourceTokens) < 2 || sourceTokens[0] == "" { + return errors.Wrapf(errdefs.ErrParsingFailed, "volume specification %q does not include a storage account before '/'", v) } - v.username = tokens[0] - remaining := tokens[1] - tokens = strings.Split(remaining, ":") - if tokens[0] == "" { - return errors.Wrapf(errdefs.ErrParsingFailed, "volume specification %q does not include a storage file share after '@'", v) + v.storageAccount = sourceTokens[0] + if sourceTokens[1] == "" { + return errors.Wrapf(errdefs.ErrParsingFailed, "volume specification %q does not include a storage file fileshare after '/'", v) } - v.share = tokens[0] + v.fileshare = sourceTokens[1] + if len(tokens) > 1 { v.target = tokens[1] } else { - v.target = "/run/volumes/" + v.share + v.target = "/run/volumes/" + v.fileshare } return nil } diff --git a/aci/convert/volume_test.go b/aci/convert/volume_test.go index b3bdebcdd..fd35c93bb 100644 --- a/aci/convert/volume_test.go +++ b/aci/convert/volume_test.go @@ -30,9 +30,9 @@ const ( func TestGetRunVolumes(t *testing.T) { volumeStrings := []string{ - "myuser1@myshare1:/my/path/to/target1", - "myuser2@myshare2:/my/path/to/target2", - "myuser3@mydefaultsharename", // Use default placement at '/run/volumes/' + "myuser1/myshare1:/my/path/to/target1", + "myuser2/myshare2:/my/path/to/target2", + "myuser3/mydefaultsharename", // Use default placement at '/run/volumes/' } var goldenVolumeConfigs = map[string]types.VolumeConfig{ "volume-0": { @@ -89,16 +89,16 @@ func TestGetRunVolumes(t *testing.T) { } func TestGetRunVolumesMissingFileShare(t *testing.T) { - _, _, err := GetRunVolumes([]string{"myaccount@"}) - assert.ErrorContains(t, err, "does not include a storage file share after '@'") + _, _, err := GetRunVolumes([]string{"myaccount/"}) + assert.ErrorContains(t, err, "does not include a storage file fileshare after '/'") } func TestGetRunVolumesMissingUser(t *testing.T) { - _, _, err := GetRunVolumes([]string{"@myshare"}) - assert.ErrorContains(t, err, "does not include a storage account before '@'") + _, _, err := GetRunVolumes([]string{"/myshare"}) + assert.ErrorContains(t, err, "does not include a storage account before '/'") } func TestGetRunVolumesNoShare(t *testing.T) { _, _, err := GetRunVolumes([]string{"noshare"}) - assert.ErrorContains(t, err, "does not include a storage account before '@'") + assert.ErrorContains(t, err, "does not include a storage account before '/'") } diff --git a/aci/volumes.go b/aci/volumes.go index 250f0ffa5..46d01c182 100644 --- a/aci/volumes.go +++ b/aci/volumes.go @@ -167,7 +167,7 @@ func errorEvent(resource string) progress.Event { } func (cs *aciVolumeService) Delete(ctx context.Context, id string, options interface{}) error { - tokens := strings.Split(id, "@") + tokens := strings.Split(id, "/") if len(tokens) != 2 { return errors.New("wrong format for volume ID : should be storageaccount@fileshare") } @@ -219,7 +219,7 @@ func toVolume(account storage.Account, fileShareName string) volumes.Volume { // VolumeID generate volume ID from azure storage accoun & fileshare func VolumeID(storageAccount string, fileShareName string) string { - return fmt.Sprintf("%s@%s", storageAccount, fileShareName) + return fmt.Sprintf("%s/%s", storageAccount, fileShareName) } func defaultStorageAccountParams(aciContext store.AciContext) storage.AccountCreateParameters { diff --git a/cli/cmd/volume/list_test.go b/cli/cmd/volume/list_test.go index a6a1e73d0..f981f0d76 100644 --- a/cli/cmd/volume/list_test.go +++ b/cli/cmd/volume/list_test.go @@ -28,7 +28,7 @@ import ( func TestPrintList(t *testing.T) { secrets := []volumes.Volume{ { - ID: "volume@123", + ID: "volume/123", Description: "volume 123", }, } diff --git a/cli/cmd/volume/testdata/volumes-out.golden b/cli/cmd/volume/testdata/volumes-out.golden index 9a4039ece..61c996793 100644 --- a/cli/cmd/volume/testdata/volumes-out.golden +++ b/cli/cmd/volume/testdata/volumes-out.golden @@ -1,2 +1,2 @@ ID DESCRIPTION -volume@123 volume 123 +volume/123 volume 123 diff --git a/tests/aci-e2e/e2e-aci_test.go b/tests/aci-e2e/e2e-aci_test.go index bd6911b8d..4d7104a3d 100644 --- a/tests/aci-e2e/e2e-aci_test.go +++ b/tests/aci-e2e/e2e-aci_test.go @@ -162,7 +162,7 @@ func TestContainerRunVolume(t *testing.T) { t.Run("create volumes", func(t *testing.T) { c.RunDockerCmd("volume", "create", "--storage-account", accountName, "--fileshare", fileshareName) }) - volumeID = accountName + "@" + fileshareName + volumeID = accountName + "/" + fileshareName t.Cleanup(func() { c.RunDockerCmd("volume", "rm", volumeID) @@ -174,7 +174,7 @@ func TestContainerRunVolume(t *testing.T) { t.Run("create second fileshare", func(t *testing.T) { c.RunDockerCmd("volume", "create", "--storage-account", accountName, "--fileshare", "dockertestshare2") }) - volumeID2 := accountName + "@dockertestshare2" + volumeID2 := accountName + "/dockertestshare2" t.Run("list volumes", func(t *testing.T) { res := c.RunDockerCmd("volume", "ls")