mirror of
https://github.com/docker/compose.git
synced 2025-07-24 06:04:57 +02:00
Fix nil pointer when creating volume with “” storage account
Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
parent
7e534153f3
commit
7eda96bea4
@ -92,10 +92,9 @@ func (cs *aciVolumeService) Create(ctx context.Context, options interface{}) (vo
|
|||||||
account, err := accountClient.GetProperties(ctx, cs.aciContext.ResourceGroup, opts.Account, "")
|
account, err := accountClient.GetProperties(ctx, cs.aciContext.ResourceGroup, opts.Account, "")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
w.Event(event(opts.Account, progress.Done, "Use existing"))
|
w.Event(event(opts.Account, progress.Done, "Use existing"))
|
||||||
|
} else if !account.HasHTTPStatus(http.StatusNotFound) {
|
||||||
|
return volumes.Volume{}, err
|
||||||
} else {
|
} else {
|
||||||
if account.StatusCode != http.StatusNotFound {
|
|
||||||
return volumes.Volume{}, err
|
|
||||||
}
|
|
||||||
result, err := accountClient.CheckNameAvailability(ctx, storage.AccountCheckNameAvailabilityParameters{
|
result, err := accountClient.CheckNameAvailability(ctx, storage.AccountCheckNameAvailabilityParameters{
|
||||||
Name: to.StringPtr(opts.Account),
|
Name: to.StringPtr(opts.Account),
|
||||||
Type: to.StringPtr("Microsoft.Storage/storageAccounts"),
|
Type: to.StringPtr("Microsoft.Storage/storageAccounts"),
|
||||||
@ -137,7 +136,7 @@ func (cs *aciVolumeService) Create(ctx context.Context, options interface{}) (vo
|
|||||||
w.Event(errorEvent(opts.Fileshare))
|
w.Event(errorEvent(opts.Fileshare))
|
||||||
return volumes.Volume{}, errors.Wrapf(errdefs.ErrAlreadyExists, "Azure fileshare %q already exists", opts.Fileshare)
|
return volumes.Volume{}, errors.Wrapf(errdefs.ErrAlreadyExists, "Azure fileshare %q already exists", opts.Fileshare)
|
||||||
}
|
}
|
||||||
if fileShare.StatusCode != http.StatusNotFound {
|
if !fileShare.HasHTTPStatus(http.StatusNotFound) {
|
||||||
w.Event(errorEvent(opts.Fileshare))
|
w.Event(errorEvent(opts.Fileshare))
|
||||||
return volumes.Volume{}, err
|
return volumes.Volume{}, err
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,15 @@ func TestContainerRunVolume(t *testing.T) {
|
|||||||
accountName = "e2e" + strconv.Itoa(int(time.Now().UnixNano()))
|
accountName = "e2e" + strconv.Itoa(int(time.Now().UnixNano()))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
t.Run("check empty volume name validity", func(t *testing.T) {
|
||||||
|
invalidName := ""
|
||||||
|
res := c.RunDockerOrExitError("volume", "create", "--storage-account", invalidName, "--fileshare", fileshareName)
|
||||||
|
res.Assert(t, icmd.Expected{
|
||||||
|
ExitCode: 1,
|
||||||
|
Err: `parameter=accountName constraint=MinLength value="" details: value length must be greater than or equal to 3`,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("check volume name validity", func(t *testing.T) {
|
t.Run("check volume name validity", func(t *testing.T) {
|
||||||
invalidName := "some-storage-123"
|
invalidName := "some-storage-123"
|
||||||
res := c.RunDockerOrExitError("volume", "create", "--storage-account", invalidName, "--fileshare", fileshareName)
|
res := c.RunDockerOrExitError("volume", "create", "--storage-account", invalidName, "--fileshare", fileshareName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user