auth

package
v0.0.0-...-238917c Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitGSUtil

func InitGSUtil(workDir string) error

InitGSUtil instantiates a workDir to be authenticated with gsutil This is primarily used for local testing, and should not be relied upon for production usage.

func InitLUCIAuth

func InitLUCIAuth(workDir string) error

InitLUCIAuth instantiates a workDir to be authenticated with LUCI credentials on this machine.

func InitNoAuth

func InitNoAuth(workDir string) error

InitNoAuth instantiates a workDir to use an unauthenticated HTTP client.

func InitServiceAccountAuth

func InitServiceAccountAuth(svcAccountFile, workDir string) error

InitServiceAccountAuth instantiates a workDir to be authenticated with the given serviceAccountFile.

func LoadAuthOpt

func LoadAuthOpt(workDir string) (*authOpt, error)

LoadAuthOpt will load a serialized *authOpt from disk and return it. If there is not one, it will return nil.

Types

type AuthOpt

type AuthOpt interface {
	// Validate returns an error if this is not a valid authenticated interface nil, otherwise.
	Validate() error
	// GetHTTPClient returns an authenticated goldclient.HTTPClient (which for non-mocked
	// implementations will be an http.Client)
	GetHTTPClient() (httpclient.HTTPClient, error)
	// SetDryRun will toggle actually uploading to GCS or not. This should be set before
	// any calls to GetGCSUploader
	SetDryRun(isDryRun bool)
	// GetGCSUploader returns an authenticated goldclient.GCSUploader, the interface for
	// uploading to GCS.
	GetGCSUploader(context.Context) (gcsuploader.GCSUploader, error)

	// GetImageDownloader returns an authenticated goldclient.ImageDownloader, the interface for
	// downloading from GCS.
	GetImageDownloader() (imagedownloader.ImageDownloader, error)
}

The AuthOpt interface adds a layer of abstraction around getting authenticated clients that can make certain requests over the wire. This being an interface makes for easier mocking than just the raw struct.

Jump to

Keyboard shortcuts

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