gcp

package
v0.0.0-...-401afe1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

package gcp provides utilities for working with GCP

Index

Constants

View Source
const (
	// CredentialDirPermMode unix permission max suitable for directory storing credentials
	CredentialDirPermMode = 0700
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedCredentialHelper

type CachedCredentialHelper struct {
	CredentialHelper CredentialHelper
	TokenCache       TokenCache
	Log              logr.Logger
}

CachedCredentialHelper is a credential helper that will cache the credential.

func (*CachedCredentialHelper) GetOAuthConfig

func (h *CachedCredentialHelper) GetOAuthConfig() *oauth2.Config

func (*CachedCredentialHelper) GetTokenSource

func (c *CachedCredentialHelper) GetTokenSource(ctx context.Context) (oauth2.TokenSource, error)

type CredentialHelper

type CredentialHelper interface {
	//GetTokenAndConfig() (*TokenAndConfig, error)
	GetTokenSource(ctx context.Context) (oauth2.TokenSource, error)

	// GetOAuthConfig returns the OAuth2 client configuration
	GetOAuthConfig() *oauth2.Config
}

CredentialHelper defines an interface for getting tokens.

type FileTokenCache

type FileTokenCache struct {
	CacheFile string
	Log       logr.Logger
}

FileTokenCache implements caching to a file.

func (*FileTokenCache) GetToken

func (c *FileTokenCache) GetToken() (*oauth2.Token, error)

func (*FileTokenCache) Save

func (c *FileTokenCache) Save(token *oauth2.Token) error

Save saves a token to a file path.

type SecretCache

type SecretCache struct {
	Project string
	Secret  string
	Version string
	Log     logr.Logger
	// contains filtered or unexported fields
}

SecretCache implements a cache for an OAuth2 credential using GCP secret manager

func NewSecretCache

func NewSecretCache(project string, secret string, version string) (*SecretCache, error)

func (*SecretCache) GetToken

func (c *SecretCache) GetToken() (*oauth2.Token, error)

func (*SecretCache) Save

func (c *SecretCache) Save(token *oauth2.Token) error

Save saves a token to a file path.

type TokenCache

type TokenCache interface {
	GetToken() (*oauth2.Token, error)
	Save(token *oauth2.Token) error
}

TokenCache defines an interface for caching tokens

type WebFlowHelper

type WebFlowHelper struct {
	Log logr.Logger
	// contains filtered or unexported fields
}

WebFlowHelper helps get credentials using the webflow.

func NewWebFlowHelper

func NewWebFlowHelper(oAuthClientFile string, scopes []string) (*WebFlowHelper, error)

NewWebFlowHelper constructs a new web flow helper. oAuthClientFile should be the path to a credentials.json downloaded from the API console.

func (*WebFlowHelper) GetOAuthConfig

func (h *WebFlowHelper) GetOAuthConfig() *oauth2.Config

func (*WebFlowHelper) GetTokenSource

func (h *WebFlowHelper) GetTokenSource(ctx context.Context) (oauth2.TokenSource, error)

GetTokenSource requests a token from the web, then returns the retrieved token.

Directories

Path Synopsis
package gcs provides useful utilities for GCS This package isn't specific to our groups sync.
package gcs provides useful utilities for GCS This package isn't specific to our groups sync.

Jump to

Keyboard shortcuts

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