gcp

package
v0.41.6 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const GCP_TOKEN_URL = "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token"

GCP_TOKEN_URL is the default GCP metadata endpoint used for authentication.

Variables

This section is empty.

Functions

func ValidHost

func ValidHost(host string) bool

ValidHost returns if a given host is a valid GCR host.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a GCP GCR client which can log into the registry and return authorization information.

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new GCR client with default configurations.

func (*Client) Login

func (c *Client) Login(ctx context.Context, autoLogin bool, image string, ref name.Reference) (authn.Authenticator, error)

Login attempts to get the authentication material for GCR. The caller can ensure that the passed image is a valid GCR image using ValidHost().

func (*Client) LoginWithExpiry

func (c *Client) LoginWithExpiry(ctx context.Context, autoLogin bool, image string, ref name.Reference) (authn.Authenticator, time.Time, error)

Login attempts to get the authentication material for GCR. It returns the authentication material and the expiry time of the token. The caller can ensure that the passed image is a valid GCR image using ValidHost().

func (*Client) OIDCLogin deprecated

func (c *Client) OIDCLogin(ctx context.Context) (authn.Authenticator, error)

OIDCLogin attempts to get the authentication material for GCR from the token url set in the client.

Deprecated: Use LoginWithExpiry instead.

func (*Client) WithTokenSource added in v0.41.6

func (c *Client) WithTokenSource(ts oauth2.TokenSource) *Client

WithTokenSource sets a custom token source for the client.

type Option

type Option func(*Client)

Option is a functional option for configuring the client.

func WithProxyURL

func WithProxyURL(proxyURL *url.URL) Option

WithProxyURL sets the proxy URL for the client.

Jump to

Keyboard shortcuts

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