func WaitFor(predicate func() (bool, error)) error {
	for i := 0; i < 300; i++ {
		time.Sleep(1 * time.Second)
		satisfied, err := predicate()
		if err != nil {
			return err
		}
		if satisfied {
			return nil
		}
	}
	return ErrTimeout
}
WaitFor polls a predicate function once per second to wait for a certain state to arrive.
package tools
import (
	"crypto/rand"
	"errors"
	mrand "math/rand"
	"os"
	"time"
	"github.com/rackspace/gophercloud"
)
var ErrTimeout = errors.New("Timed out")
func OnlyRS(original gophercloud.AuthOptions) gophercloud.AuthOptions {
	if os.Getenv("RS_AUTH_URL") == "" {
		original.IdentityEndpoint = ""
	}
	if os.Getenv("RS_USERNAME") == "" {
		original.Username = ""
	}
	if os.Getenv("RS_PASSWORD") == "" {
		original.Password = ""
	}
	if os.Getenv("RS_API_KEY") == "" {
		original.APIKey = ""
	}
	return original
}