conn

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Unlicense Imports: 12 Imported by: 0

Documentation

Overview

This package provides wrappers to make it easier to get an authenticated connection to GCP services.

Index

Constants

View Source
const ZuluTime = "2006-01-02T15:04:05Z"

Variables

This section is empty.

Functions

func EnvDuration

func EnvDuration(envVar, defaultDur string) time.Duration

func ErrorCode

func ErrorCode(err error) int

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

func GcloudAccessClient(ctx context.Context) (*http.Client, error)

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

func GoogleClient(
	ctx context.Context, scopes ...string,
) (*http.Client, error)

Uses DefaultClient() (from golang.org/x/oauth2/google) to obtain authentication for GCP services. If that fails, then falls back to GcloudAccessClient().

func MustGoogleClient

func MustGoogleClient() *http.Client

Calls GoogleClient() but, if that fails, it reports the error and exits.

func TimeAsString

func TimeAsString(when time.Time) string

func Timeout

func Timeout(pCtx *context.Context, dur time.Duration) context.CancelFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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