Skip to content

Commit

Permalink
Merge pull request #2873 from terraform-providers/storage/list_container
Browse files Browse the repository at this point in the history
Correctly List Storage Containers
  • Loading branch information
tombuildsstuff authored Feb 12, 2019
2 parents 2f30b15 + 27fea31 commit c6108f3
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions azurerm/resource_arm_storage_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,30 @@ func resourceArmStorageContainerRead(d *schema.ResourceData, meta interface{}) e
return nil
}

containers, err := blobClient.ListContainers(storage.ListContainersParameters{
var container *storage.Container
listParams := storage.ListContainersParameters{
Prefix: id.containerName,
Timeout: 90,
})
if err != nil {
return fmt.Errorf("Failed to retrieve storage containers in account %q: %s", id.containerName, err)
}

var container *storage.Container
for _, cont := range containers.Containers {
if cont.Name == id.containerName {
container = &cont
for {
resp, err := blobClient.ListContainers(listParams)
if err != nil {
return fmt.Errorf("Failed to retrieve storage resp in account %q: %s", id.containerName, err)
}

for _, c := range resp.Containers {
if c.Name == id.containerName {
container = &c
break
}
}

if resp.NextMarker == "" {
break
}

listParams.Marker = resp.NextMarker
}

if container == nil {
Expand Down

0 comments on commit c6108f3

Please sign in to comment.