MCPcopy Index your code
hub / github.com/perkeep/perkeep / checkGeoKey

Function checkGeoKey

server/perkeepd/perkeepd.go:362–375  ·  view source on GitHub ↗

checkGeoKey returns nil if we have a Google Geocoding API key file stored in the config dir. Otherwise it returns instruction about it as the error.

()

Source from the content-addressed store, hash-verified

360// checkGeoKey returns nil if we have a Google Geocoding API key file stored
361// in the config dir. Otherwise it returns instruction about it as the error.
362func checkGeoKey() error {
363 if _, err := geocode.GetAPIKey(); err == nil {
364 return nil
365 }
366 keyPath, err := geocode.GetAPIKeyPath()
367 if err != nil {
368 return fmt.Errorf("error getting Geocoding API key path: %v", err)
369 }
370 if env.OnGCE() {
371 keyPath = strings.TrimPrefix(keyPath, "/gcs/")
372 return fmt.Errorf("using OpenStreetMap for location related requests. To use the Google Geocoding API, create a key (see https://developers.google.com/maps/documentation/geocoding/get-api-key ) and save it in your VM's configuration bucket as: %v", keyPath)
373 }
374 return fmt.Errorf("using OpenStreetMap for location related requests. To use the Google Geocoding API, create a key (see https://developers.google.com/maps/documentation/geocoding/get-api-key ) and save it in Perkeep's configuration directory as: %v", keyPath)
375}
376
377func main() {
378 flag.Parse()

Callers 1

mainFunction · 0.85

Calls 3

GetAPIKeyFunction · 0.92
GetAPIKeyPathFunction · 0.92
OnGCEFunction · 0.92

Tested by

no test coverage detected