Documentation
¶
Index ¶
Constants ¶
View Source
const (
// ConfigEnvPrefix is the prefix applied to environment variables for configuring Auth0.
ConfigEnvPrefix = "GOOGLE_CLOUD_"
)
Variables ¶
View Source
var InitErrorClient = func(ctx context.Context) error { err := sync.OnceValue(func() error { cfg, err := LoadConfig() if err != nil { return fmt.Errorf("load config: %w", err) } errorClient, err = errorreporting.NewClient(ctx, cfg.ProjectID, errorreporting.Config{ ServiceName: cfg.Service, ServiceVersion: config.GetVersion(), OnError: func(err error) { slogctx.FromCtx(ctx).Error("Create new error client failed.", slog.Any("error", err)) }, }) if err != nil { return fmt.Errorf("load error reporting client: %w", err) } slogctx.FromCtx(ctx).Info("GCP error client created.") return nil })() if err != nil { return err } return nil }
View Source
var LoadConfig = sync.OnceValues(func() (*Config, error) { if err := config.Load(ConfigEnvPrefix, &cfg); err != nil { return nil, fmt.Errorf("google: unable to load config: %w", err) } if cfg.ProjectID == "" { cfg.ProjectID, _ = queryMetadataServer("/computeMetadata/v1/project/project-id") } cfg.InstanceID, _ = queryMetadataServer("/computeMetadata/v1/instance/id") if err := validation.Validate.Struct(cfg); err != nil { return nil, fmt.Errorf("google: unable to validate config: %w", err) } slog.Info("GCP config loaded.") return &cfg, nil })
LoadConfig loads the auth0 configuration and ensures this is only done one time, no matter how many times it is called.
Functions ¶
func ReportError ¶ added in v0.75.0
ReportError reports an error to the Cloud Console. The error client autopopulates the error context of the error. For more details about the context see: https://cloud.google.com/error-reporting/reference/rest/v1beta1/ErrorContext.
Types ¶
type Config ¶
type Config struct {
// ProjectID is the project ID. Sourced from the environment, otherwise the internal metadata server.
ProjectID string `koanf:"project" validate:"required"`
// InstanceID is the ID of the instances. Sourced from the internal metadata server. Will be an empty string if not
// running in GCP.
InstanceID string
// Service is the service name. Sourced from the instance environment, otherwise an empty string if not running in
// GCP.
Service string
// Revision is the service revision. Sourced from the instance environment, otherwise an empty string if not running
// in GCP.
Revision string
// BillingAccountID is the ID of the billing account.
BillingAccountID string `koanf:"billingaccountid"`
// APIKey is an API key to use with various Google Cloud APIs
APIKey string `koanf:"apikey"`
}
Config contains the pubsub configuration options.
func (*Config) GetBillingAccountName ¶ added in v0.79.1
GetBillingAccountName gets the billing account name in the canonical format used by the Google APIs.
Click to show internal directories.
Click to hide internal directories.