mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 09:06:44 +00:00
![Nathan McKinley](/assets/img/avatar_default.png)
- Fetch Zone attribute any place where it *was* being fetched from the schema by combination schema / provider-level attribute. - Allow region to be unspecified if zone is specified. - Switch one example to using provider-level zone as an example. - Make provider-level zone optional. (Individual resources will fail if they can't find a zone.) - Add tests for getZone and getRegion.
71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
)
|
|
|
|
func dataSourceGoogleContainerEngineVersions() *schema.Resource {
|
|
return &schema.Resource{
|
|
Read: dataSourceGoogleContainerEngineVersionsRead,
|
|
Schema: map[string]*schema.Schema{
|
|
"project": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
"zone": {
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
},
|
|
"latest_master_version": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"latest_node_version": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
"valid_master_versions": {
|
|
Type: schema.TypeList,
|
|
Computed: true,
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
},
|
|
"valid_node_versions": {
|
|
Type: schema.TypeList,
|
|
Computed: true,
|
|
Elem: &schema.Schema{Type: schema.TypeString},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func dataSourceGoogleContainerEngineVersionsRead(d *schema.ResourceData, meta interface{}) error {
|
|
config := meta.(*Config)
|
|
|
|
project, err := getProject(d, config)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
zone, err := getZone(d, meta.(*Config))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
resp, err := config.clientContainer.Projects.Zones.GetServerconfig(project, zone).Do()
|
|
if err != nil {
|
|
return fmt.Errorf("Error retrieving available container cluster versions: %s", err.Error())
|
|
}
|
|
|
|
d.Set("valid_master_versions", resp.ValidMasterVersions)
|
|
d.Set("valid_node_versions", resp.ValidNodeVersions)
|
|
d.Set("latest_master_version", resp.ValidMasterVersions[0])
|
|
d.Set("latest_node_version", resp.ValidNodeVersions[0])
|
|
|
|
d.SetId(time.Now().UTC().String())
|
|
|
|
return nil
|
|
}
|