syncer

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Type               CredentialsType
	ServiceAccountJSON []byte
	ImpersonateConfig  *ImpersonateConfig
}

func NewADCCredentials

func NewADCCredentials() *Credentials

func NewServiceAccountImpersonate

func NewServiceAccountImpersonate(targetServiceAccount string, delegates []string) *Credentials

func NewServiceAccountJSONCredentials

func NewServiceAccountJSONCredentials(json []byte) *Credentials

func (*Credentials) TokenSource

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

TokenSource create oauth2.TokenSource for Credentials. Note: We can specify scopes needed for spanner-autoscaler but it does increase maintenance cost. We should already use least privileged Google Service Accounts so it use cloudPlatformScope.

type CredentialsType

type CredentialsType int
const (
	CredentialsTypeADC CredentialsType = iota
	CredentialsTypeServiceAccountJSON
	CredentialsTypeImpersonation
)

type ImpersonateConfig

type ImpersonateConfig struct {
	TargetServiceAccount string
	Delegates            []string
}

type Option

type Option func(*syncer)

func WithClock

func WithClock(clock utilclock.Clock) Option

func WithInterval

func WithInterval(interval time.Duration) Option

func WithLog

func WithLog(log logr.Logger) Option

type Syncer

type Syncer interface {
	// Start starts synchronization of resource status.
	Start()
	// Stop stops synchronization of resource status.
	Stop()

	// HasCredentials checks whether the existing credentials of the syncer, match the provided one or not
	HasCredentials(credentials *Credentials) bool
	UpdateInstance(ctx context.Context, desiredProcessingUnits int) error
}

Syncer represents a worker synchronizing a SpannerAutoscaler object status.

func New

func New(
	ctx context.Context,
	ctrlClient ctrlclient.Client,
	namespacedName types.NamespacedName,
	credentials *Credentials,
	recorder record.EventRecorder,
	spannerClient spanner.Client,
	metricsClient metrics.Client,
	opts ...Option,
) (Syncer, error)

New returns a new Syncer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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