project

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package project provides functionality for retrieving Google Cloud project IDs and related configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ID

func ID(opts ...Options) string

ID retrieves the default Google Cloud project ID based on the provided options.

It uses the following order when searching:

  1. Common environment variables like GCP_PROJECT, GCLOUD_PROJECT, GOOGLE_CLOUD_PROJECT.
  2. The DefaultApplicationCredentials method from the golang.org/x/oauth2/google package.
  3. The default project configured in `gcloud` CLI.

If the project ID is empty and the Strict option is enabled, `ID()` panics.

Types

type Options

type Options struct {
	// Default: 30s.
	Timeout time.Duration

	// Scopes is the list OAuth scopes.
	Scopes []string

	// If true, ID() panics when no default project ID is found.
	Strict bool
}

Options represents the configuration options for the ID function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL