mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 09:06:44 +00:00
![Matt Morrison](/assets/img/avatar_default.png)
* Add google_kubernetes_cluster datasource Add documentation for google_kubernetes_cluster datasource Rename datasource to google_container_cluster To be consistent with the equivalent resource. Rename datasource in docs. google_kubernetes_cluster -> google_container_cluster. Also add reference in google.erb file. WIP Datasource read needs to set an ID, then call resource read func Add additional cluster attributes to datasource schema * Generate datasource schema from resource Datasource documentation also updated. * add test for datasourceSchemaFromResourceSchema * Code review changes
30 lines
728 B
Go
30 lines
728 B
Go
package google
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
)
|
|
|
|
func dataSourceGoogleContainerCluster() *schema.Resource {
|
|
// Generate datasource schema from resource
|
|
dsSchema := datasourceSchemaFromResourceSchema(resourceContainerCluster().Schema)
|
|
|
|
// Set 'Required' schema elements
|
|
addRequiredFieldsToSchema(dsSchema, "name", "zone")
|
|
|
|
// Set 'Optional' schema elements
|
|
addOptionalFieldsToSchema(dsSchema, "project")
|
|
|
|
return &schema.Resource{
|
|
Read: datasourceContainerClusterRead,
|
|
Schema: dsSchema,
|
|
}
|
|
}
|
|
|
|
func datasourceContainerClusterRead(d *schema.ResourceData, meta interface{}) error {
|
|
clusterName := d.Get("name").(string)
|
|
|
|
d.SetId(clusterName)
|
|
|
|
return resourceContainerClusterRead(d, meta)
|
|
}
|