googlecloud

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRetryPolicy = gax.WithRetry(NewDefaultRetryer)

DefaultRetryPolicy is the default retry policy widely used to access Google Cloud API.

View Source
var NeverTimeout = gax.WithTimeout(1<<63 - 1)

NeverTimeout is gax.CallOption that never reaches the timeout.

Functions

func NewDefaultRetryer

func NewDefaultRetryer() gax.Retryer

NewDefaultRetryer returns the default retryer.

func NewRetryWithCountBudget

func NewRetryWithCountBudget(codes []codes.Code, initialDuration time.Duration, multiplier float32, resetDuration time.Duration, retryCountBudget int, parentRetrier gax.Retryer) *retryWithCountBudget

NewRetryWithCountBudget returns the instance of retryWithCountBudget.

func ValidateResourceNameOnLogEntriesList

func ValidateResourceNameOnLogEntriesList(resourceName string) error

ValidateResourceNameOnLogEntriesList validates the given resource name is valid or not as the argument of the item in resource names to call entries.list.

Types

type CallOptionInjector

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

CallOptionInjector injects call options for a given resource target.

func NewCallOptionInjector

func NewCallOptionInjector(options ...CallOptionInjectorOption) *CallOptionInjector

NewCallOptionInjector creates a new CallOptionInjector with the given options.

func (*CallOptionInjector) InjectToCall

func (c *CallOptionInjector) InjectToCall(call headerProvider, container ResourceContainer)

InjectToCall injects call options into the given call request. This is used for any clients under google.golang.org/api

func (*CallOptionInjector) InjectToCallContext

func (c *CallOptionInjector) InjectToCallContext(ctx context.Context, container ResourceContainer) context.Context

InjectToCallContext injects call options into given context. This is used for any clients under cloud.google.com/go

type CallOptionInjectorOption

type CallOptionInjectorOption interface {
	// ApplyToCallContext applies the call option to the given context.
	// This is typically used for clients from `cloud.google.com/go`.
	ApplyToCallContext(ctx context.Context, container ResourceContainer) context.Context
	// ApplyToRawHTTPHeader applies the call option to the given HTTP header.
	// This is typically used for clients from `google.golang.org/api`.
	ApplyToRawHTTPHeader(header http.Header, container ResourceContainer)
}

CallOptionInjectorOption defines an interface for options that can inject call options into a context or raw HTTP header.

type ClientFactory

type ClientFactory struct {
	ClientOptions    []ClientFactoryOptionsModifiers
	ContextModifiers []ClientFactoryContextModifiers

	ContainerClusterManagerClientOptions    []ClientFactoryOptionsModifiers
	GKEHubMembershipClientOptions           []ClientFactoryOptionsModifiers
	GKEMultiCloudAWSClustersClientOptions   []ClientFactoryOptionsModifiers
	GKEMultiCloudAzureClustersClientOptions []ClientFactoryOptionsModifiers
	LoggingClientOptions                    []ClientFactoryOptionsModifiers
	RegionsClientOptions                    []ClientFactoryOptionsModifiers
	ComposerServiceOptions                  []ClientFactoryOptionsModifiers
	GKEOnPremServiceOptions                 []ClientFactoryOptionsModifiers
}

ClientFactory generates a context used for generating the google cloud client. This type creates the instance of API clients centrally, it uses `cloud.google.com/go` package when the SDK supports the service, if not, it uses `google.golang.org/api` package for the service(e.g, Cloud Composer).

func NewClientFactory

func NewClientFactory(options ...ClientFactoryOption) (*ClientFactory, error)

NewClientFactory creates a new ClientFactory with the given options. It applies each option to the factory and returns an error if any option fails.

func (*ClientFactory) ComposerService

func (s *ClientFactory) ComposerService(ctx context.Context, c ResourceContainer, opts ...option.ClientOption) (*composer.Service, error)

ComposerService returns the client for composer.googleapis.com from given context and the resource container. Cloud Composer has no package defined by 'cloud.google.com/go', this method returns the low level API client from 'google.golang.org/api/composer/v1'

func (*ClientFactory) ContainerClusterManagerClient

func (s *ClientFactory) ContainerClusterManagerClient(ctx context.Context, c ResourceContainer, opts ...option.ClientOption) (*container.ClusterManagerClient, error)

ContainerClusterManagerClient returns the ClusterManagerClient of container.googleapis.com from given context and the resource container.

func (*ClientFactory) GKEHubMembershipClient

func (s *ClientFactory) GKEHubMembershipClient(ctx context.Context, c ResourceContainer, opts ...option.ClientOption) (*gkehub.GkeHubMembershipClient, error)

GKEHubMembershipClient returns the MembershipClient of gkehub.googleapis.com from given context and the resource container.

func (*ClientFactory) GKEMultiCloudAWSClustersClient

func (s *ClientFactory) GKEMultiCloudAWSClustersClient(ctx context.Context, c ResourceContainer, opts ...option.ClientOption) (*gkemulticloud.AwsClustersClient, error)

GKEMultiCloudAWSClustersClient returns the AwsClusterClient of gkemulticloud.googleapis.com from given context and the resource container.

func (*ClientFactory) GKEMultiCloudAzureClustersClient

func (s *ClientFactory) GKEMultiCloudAzureClustersClient(ctx context.Context, c ResourceContainer, opts ...option.ClientOption) (*gkemulticloud.AzureClustersClient, error)

GKEMultiCloudAzureClustersClient returns the AzureClustersClient of gkemulticloud.googleapis.com from given context and the resource container.

func (*ClientFactory) GKEOnPremService

func (s *ClientFactory) GKEOnPremService(ctx context.Context, c ResourceContainer, opts ...option.ClientOption) (*gkeonprem.Service, error)

GKEOnPremService returns the client for gkeonprem.googleapis.com from the given context and the resource cntainer. GKEOnPrem has no package defined by `cloud.google.com/go`, this method returns the low level API client from '"google.golang.org/api/gkeonprem/v1'.

func (*ClientFactory) LoggingClient

func (s *ClientFactory) LoggingClient(ctx context.Context, c ResourceContainer, opts ...option.ClientOption) (*logging.Client, error)

LoggingClient returns the client for logging.googleapis.com from given context and the resource container.

func (*ClientFactory) RegionsClient

RegionsClient returns the client for listing GCE regions. https://cloud.google.com/compute/docs/reference/rest/v1#rest-resource:-v1.regions

type ClientFactoryContextModifiers

type ClientFactoryContextModifiers = func(ctx context.Context, container ResourceContainer) (context.Context, error)

ClientFactoryContextModifiers defines a function type for modifying the context before creating a Google Cloud client.

type ClientFactoryOption

type ClientFactoryOption = func(s *ClientFactory) error

ClientFactoryOption defines a function type for configuring a ClientFactory.

type ClientFactoryOptionsModifiers

type ClientFactoryOptionsModifiers = func(opts []option.ClientOption, container ResourceContainer) ([]option.ClientOption, error)

ClientFactoryOptionsModifiers defines a function type for modifying the client options before creating a Google Cloud client.

type ProjectResourceContainer

type ProjectResourceContainer interface {
	ResourceContainer
	ProjectID() string
}

ProjectResourceContainer is an interface that represents a Google Cloud project resource container.

func Project

func Project(projectID string) ProjectResourceContainer

Project creates a new ResourceContainer for a Google Cloud project with the given project ID.

type ResourceContainer

type ResourceContainer interface {
	// GetType returns the type of the resource container.
	GetType() ResourceContainerType
	// Identifier returns a unique string identifier for the resource container.
	Identifier() string
}

ResourceContainer is an interface that represents a container for Google Cloud resources (e.g., project, organization, folder, or billing account). ClientFactory receives a resource container to generate a client. This is needed because KHI can use multiple clients when it needs to gather logs or resource info from multiple projects.

type ResourceContainerType

type ResourceContainerType int

ResourceContainerType represents the type of a Google Cloud resource container.

const (
	// ResourceContainerInvalid represents an ResourceContainerInvalid resource container type. This is used for test mock types.
	ResourceContainerInvalid ResourceContainerType = iota
	// ResourceContainerProject represents a Google Cloud ResourceContainerProject resource container.
	ResourceContainerProject ResourceContainerType = iota
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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