github.com/mistwind/reviewdog@v0.0.0-20230322024206-9cfa11856d58/doghouse/server/storage/datastore.go (about)

     1  package storage
     2  
     3  import (
     4  	"context"
     5  
     6  	"cloud.google.com/go/compute/metadata"
     7  	"cloud.google.com/go/datastore"
     8  )
     9  
    10  // datastoreClient constructs a *datastore.Client using runtime introspection
    11  // to target the current project's datastore.
    12  func datastoreClient(ctx context.Context) (*datastore.Client, error) {
    13  	id, err := metadata.ProjectID()
    14  	if err != nil {
    15  		return nil, err
    16  	}
    17  	return datastore.NewClient(ctx, id)
    18  }