// returns a state with no error if the state is a resting state, and the last state with an error otherwise
returns a state with no error if the state is a resting state, and the last state with an error otherwise
// returns a state with no error if the state is a resting state and the last state with an error otherwise
func containerClusterAwaitRestingState(config *Config, project, location, clusterName string, timeout time.Duration) (state string, err error) {
	err = resource.Retry(timeout, func() *resource.RetryError {
		name := containerClusterFullName(project, location, clusterName)
		clusterGetCall := config.clientContainerBeta.Projects.Locations.Clusters.Get(name)
		if config.UserProjectOverride {
			clusterGetCall.Header().Add("X-Goog-User-Project", project)
		}
		cluster, gErr := clusterGetCall.Do()
		if gErr != nil {
			return resource.NonRetryableError(gErr)
		}
		state = cluster.Status
		switch stateType := containerClusterRestingStates[cluster.Status]; stateType {
		case ReadyState:
			log.Printf("[DEBUG] Cluster %q has status %q with message %q.", clusterName, state, cluster.StatusMessage)
			return nil
		case ErrorState:
			log.Printf("[DEBUG] Cluster %q has error state %q with message %q.", clusterName, state, cluster.StatusMessage)
			return nil
		default:
			return resource.RetryableError(fmt.Errorf("Cluster %q has state %q with message %q", clusterName, state, cluster.StatusMessage))
		}
	})
	return state, err
}
func containerClusterAwaitRestingState ( config * Config , project , location , clusterName string , timeout time . Duration ) ( state string , err error ) { err = resource . Retry ( timeout , func ( ) * resource . RetryError { name := containerClusterFullName ( project , location , clusterName ) clusterGetCall := config . clientContainerBeta . Projects . Locations . Clusters . Get ( name ) if config . UserProjectOverride { clusterGetCall . Header ( ) . Add ( " " , project ) } cluster , gErr := clusterGetCall . Do ( ) if gErr != nil { return resource . NonRetryableError ( gErr ) } state = cluster . Status switch stateType := containerClusterRestingStates [ cluster . Status ] ; stateType { case ReadyState : log . Printf ( " " , clusterName , state , cluster . StatusMessage ) return nil case ErrorState : log . Printf ( " " , clusterName , state , cluster . StatusMessage ) return nil default : return resource . RetryableError ( fmt . Errorf ( " " , clusterName , state , cluster . StatusMessage ) ) } } ) return state , err }
returns a state with no error if the state is a resting state, and the last state with an error otherwise
returns a state with no error if the state is a resting state and the last state with an error otherwise