mirror of
https://github.com/foomo/sesamy-cli.git
synced 2026-06-28 14:10:09 +00:00
23 lines
671 B
Go
23 lines
671 B
Go
package config
|
|
|
|
import (
|
|
googleapioption "google.golang.org/api/option"
|
|
)
|
|
|
|
type GoogleAPI struct {
|
|
Credentials string `json:"credentials" yaml:"credentials"`
|
|
CredentialsFile string `json:"credentialsFile" yaml:"credentialsFile"`
|
|
RequestQuota int `json:"requestQuota" yaml:"requestQuota"`
|
|
}
|
|
|
|
func (c GoogleAPI) GetClientOption() googleapioption.ClientOption {
|
|
var ret googleapioption.ClientOption
|
|
if c.CredentialsFile != "" {
|
|
ret = googleapioption.WithAuthCredentialsFile(googleapioption.ServiceAccount, c.CredentialsFile)
|
|
} else {
|
|
ret = googleapioption.WithAuthCredentialsJSON(googleapioption.ServiceAccount, []byte(c.Credentials))
|
|
}
|
|
|
|
return ret
|
|
}
|