Skip to content

Commit

Permalink
handle not found errors correctly in read.
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-henderson committed Jul 8, 2019
1 parent b67adb9 commit 5d7f478
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1156,14 +1156,11 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro
name := containerClusterFullName(project, location, clusterName)
cluster, err := config.clientContainerBeta.Projects.Locations.Clusters.Get(name).Do()
if err != nil {
return err
return handleNotFoundError(err, d, fmt.Sprintf("Container Cluster %q", d.Get("name").(string)))
}
if cluster.Status == "ERROR" || cluster.Status == "DEGRADED" {
return fmt.Errorf("Cluster %q has status %q with message %q", d.Get("name"), cluster.Status, cluster.StatusMessage)
}
if err != nil {
return handleNotFoundError(err, d, fmt.Sprintf("Container Cluster %q", d.Get("name").(string)))
}

d.Set("name", cluster.Name)
if err := d.Set("network_policy", flattenNetworkPolicy(cluster.NetworkPolicy)); err != nil {
Expand Down

0 comments on commit 5d7f478

Please sign in to comment.