mirror of https://github.com/perkeep/perkeep.git
Merge "osutil,deploy: on GCE, deploy with enough scope to log on GCL"
This commit is contained in:
commit
91c0467302
|
@ -48,6 +48,7 @@ import (
|
|||
compute "google.golang.org/api/compute/v1"
|
||||
storage "google.golang.org/api/storage/v1"
|
||||
"google.golang.org/cloud"
|
||||
"google.golang.org/cloud/logging"
|
||||
cloudstorage "google.golang.org/cloud/storage"
|
||||
)
|
||||
|
||||
|
@ -87,6 +88,7 @@ var (
|
|||
func NewOAuthConfig(clientID, clientSecret string) *oauth2.Config {
|
||||
return &oauth2.Config{
|
||||
Scopes: []string{
|
||||
logging.Scope,
|
||||
compute.DevstorageFull_controlScope,
|
||||
compute.ComputeScope,
|
||||
"https://www.googleapis.com/auth/sqlservice",
|
||||
|
@ -377,6 +379,7 @@ func (d *Deployer) createInstance(computeService *compute.Service, ctx *context.
|
|||
{
|
||||
Email: "default",
|
||||
Scopes: []string{
|
||||
logging.Scope,
|
||||
compute.DevstorageFull_controlScope,
|
||||
compute.ComputeScope,
|
||||
"https://www.googleapis.com/auth/sqlservice",
|
||||
|
|
|
@ -1048,6 +1048,7 @@ This tool helps you create your own private Camlistore instance running on Googl
|
|||
<li>APIs and auth > APIs > Google Cloud Storage</li>
|
||||
<li>APIs and auth > APIs > Google Cloud Storage JSON API</li>
|
||||
<li>APIs and auth > APIs > Google Compute Engine</li>
|
||||
<li>APIs and auth > APIs > Google Cloud Logging API</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</td></tr>
|
||||
|
|
|
@ -77,6 +77,20 @@ func LogWriter() (w io.Writer) {
|
|||
log.Printf("Error getting project ID: %v", err)
|
||||
return
|
||||
}
|
||||
scopes, _ := metadata.Scopes("default")
|
||||
haveScope := func(scope string) bool {
|
||||
for _, x := range scopes {
|
||||
if x == scope {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
if !haveScope(logging.Scope) {
|
||||
log.Printf("when this Google Compute Engine VM instance was created, it wasn't granted enough access to use Google Cloud Logging (Scope URL: %v).", logging.Scope)
|
||||
return
|
||||
}
|
||||
|
||||
hc, err := google.DefaultClient(oauth2.NoContext)
|
||||
if err != nil {
|
||||
log.Printf("Error creating default GCE OAuth2 client: %v", err)
|
||||
|
|
Loading…
Reference in New Issue