gsutil

package
v0.0.0-...-d60a78d Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Overview

Package gsutil implements a hacky shim that makes gsutil use LUCI local auth.

It constructs a special .boto config file that instructs gsutil to use local HTTP endpoint as token_uri (it's the one that exchanges OAuth2 refresh token for an access token). This endpoint is implemented on top of LUCI auth.

Thus gsutil thinks it's using 3-legged OAuth2 flow, while in fact it is getting the token through LUCI protocols.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// Source is used to obtain OAuth2 tokens.
	Source oauth2.TokenSource
	// StateDir is where to drop new .boto file and where to keep gsutil state.
	StateDir string
	// Port is a local TCP port to bind to or 0 to allow the OS to pick one.
	Port int
	// contains filtered or unexported fields
}

Server runs a local server that handles requests to token_uri.

It also manages a directory with gsutil state, since part of the state is the cached OAuth2 token that we don't want to put into default global ~/.gsutil state directory.

func (*Server) Start

func (s *Server) Start(ctx context.Context) (botoCfg string, err error)

Start launches background goroutine with the serving loop and prepares .boto.

Returns absolute path to new .boto file. It is always inside StateDir. Caller is responsible for creating StateDir (and later deleting it, if necessary).

The provided context is used as base context for request handlers and for logging. The server must be eventually stopped with Stop().

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop closes the listening socket, notifies pending requests to abort and stops the internal serving goroutine.

Safe to call multiple times. Once stopped, the server cannot be started again (make a new instance of Server instead).

Uses the given context for the deadline when waiting for the serving loop to stop.

Jump to

Keyboard shortcuts

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