Files
sesamy-cli/pkg/config/googleapi.go
2026-03-17 16:56:54 +01:00

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
}