mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 09:36:44 +00:00
![Dominik Lekse](/assets/img/avatar_default.png)
* Added access_token field to google_client_config data source * Refined documentation of google_client_config
47 lines
848 B
Go
47 lines
848 B
Go
package google
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
)
|
|
|
|
func dataSourceGoogleClientConfig() *schema.Resource {
|
|
return &schema.Resource{
|
|
Read: dataSourceClientConfigRead,
|
|
Schema: map[string]*schema.Schema{
|
|
"project": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
|
|
"region": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
},
|
|
|
|
"access_token": {
|
|
Type: schema.TypeString,
|
|
Computed: true,
|
|
Sensitive: true,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func dataSourceClientConfigRead(d *schema.ResourceData, meta interface{}) error {
|
|
config := meta.(*Config)
|
|
|
|
d.SetId(time.Now().UTC().String())
|
|
d.Set("project", config.Project)
|
|
d.Set("region", config.Region)
|
|
|
|
token, err := config.tokenSource.Token()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
d.Set("access_token", token.AccessToken)
|
|
|
|
return nil
|
|
}
|