mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-06 17:16:44 +00:00
![ishashchuk](/assets/img/avatar_default.png)
* Datasource for retrieving GCS service account * Removing duplicated argument * Gofmt post resolving conflicts * Addressing review comment
30 lines
672 B
Go
30 lines
672 B
Go
package google
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
)
|
|
|
|
func dataSourceGoogleStorageProjectServiceAccount() *schema.Resource {
|
|
return &schema.Resource{
|
|
Read: dataSourceGoogleStorageProjectServiceAccountRead,
|
|
}
|
|
}
|
|
|
|
func dataSourceGoogleStorageProjectServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
|
|
config := meta.(*Config)
|
|
|
|
project, err := getProject(d, config)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
serviceAccount, err := config.clientStorage.Projects.ServiceAccount.Get(project).Do()
|
|
if err != nil {
|
|
return handleNotFoundError(err, d, "GCS service account not found")
|
|
}
|
|
|
|
d.SetId(serviceAccount.EmailAddress)
|
|
|
|
return nil
|
|
}
|