github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/blockstorage/v3/volumes/util.go (about) 1 package volumes 2 3 import ( 4 "context" 5 6 "github.com/vnpaycloud-console/gophercloud/v2" 7 ) 8 9 // WaitForStatus will continually poll the resource, checking for a particular status. 10 func WaitForStatus(ctx context.Context, c *gophercloud.ServiceClient, id, status string) error { 11 return gophercloud.WaitFor(ctx, func(ctx context.Context) (bool, error) { 12 current, err := Get(ctx, c, id).Extract() 13 if err != nil { 14 return false, err 15 } 16 17 if current.Status == status { 18 return true, nil 19 } 20 21 return false, nil 22 }) 23 }