Documentation ¶
Overview ¶
This package provides wrappers to make it easier to get an authenticated connection to GCP services.
Index ¶
- Constants
- func EnvDuration(envVar, defaultDur string) time.Duration
- func ErrorCode(err error) int
- func GcloudAccessClient(ctx context.Context) (*http.Client, error)
- func GcloudDefaultProject() string
- func GoogleClient(ctx context.Context, scopes ...string) (*http.Client, error)
- func MustGoogleClient() *http.Client
- func TimeAsString(when time.Time) string
- func Timeout(pCtx *context.Context, dur time.Duration) context.CancelFunc
Constants ¶
const ZuluTime = "2006-01-02T15:04:05Z"
Variables ¶
This section is empty.
Functions ¶
func EnvDuration ¶
func ErrorCode ¶
Returns 200 if `err` is `nil`. If `err` is a googleapi.Error, then returns the HTTP status code from it. Otherwise, returns 0.
func GcloudAccessClient ¶
Runs the gcloud command to get the access token that it uses and makes a connection that uses that for auth to GCP services. Token will not be renewed so this access will only work for a relatively short time.
func GcloudDefaultProject ¶
func GcloudDefaultProject() string
Runs the gcloud command to get the project name that gcloud will connect to by default.
func GoogleClient ¶
Uses DefaultClient() (from golang.org/x/oauth2/google) to obtain authentication for GCP services. If that fails, then falls back to GcloudAccessClient().
func MustGoogleClient ¶
Calls GoogleClient() but, if that fails, it reports the error and exits.
func TimeAsString ¶
Types ¶
This section is empty.