Skip to content

Commit

Permalink
make fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Feb 12, 2019
1 parent a79f8eb commit 27fea31
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions azurerm/resource_arm_storage_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,30 @@ func resourceArmStorageContainerRead(d *schema.ResourceData, meta interface{}) e
return nil
}

var container *storage.Container
listParams := storage.ListContainersParameters{
Prefix: id.containerName,
Timeout: 90,
}

resp := blobClient.GetContainerReference(id.containerName)
if err != nil {
return fmt.Errorf("Failed to retrieve storage resp in account %q: %s", id.containerName, err)
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 All @@ -191,18 +211,18 @@ func resourceArmStorageContainerRead(d *schema.ResourceData, meta interface{}) e
d.Set("resource_group_name", resourceGroup)

// for historical reasons, "private" above is an empty string in the API
if resp.Properties.PublicAccess == storage.ContainerAccessTypePrivate {
if container.Properties.PublicAccess == storage.ContainerAccessTypePrivate {
d.Set("container_access_type", "private")
} else {
d.Set("container_access_type", string(resp.Properties.PublicAccess))
d.Set("container_access_type", string(container.Properties.PublicAccess))
}

output := make(map[string]interface{})

output["last_modified"] = resp.Properties.LastModified
output["lease_status"] = resp.Properties.LeaseStatus
output["lease_state"] = resp.Properties.LeaseState
output["lease_duration"] = resp.Properties.LeaseDuration
output["last_modified"] = container.Properties.LastModified
output["lease_status"] = container.Properties.LeaseStatus
output["lease_state"] = container.Properties.LeaseState
output["lease_duration"] = container.Properties.LeaseDuration

if err := d.Set("properties", output); err != nil {
return fmt.Errorf("Error setting `properties`: %+v", err)
Expand Down

0 comments on commit 27fea31

Please sign in to comment.