metadata

package
v0.0.0-...-32f485c Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetadataFetcherRetryConfig = util.RetryConfig{
	RetryNum:      5,
	RetryInterval: time.Millisecond * 20,
}
View Source
var (
	NewMetadataFetcher = func(opts options.CommonOptions) *MetadataFetcher {
		return &MetadataFetcher{
			client: http.Client{
				Timeout: opts.HttpRequestTimeout,
			},
			baseUrl:     opts.MetadataURL,
			timeNow:     time.Now,
			retryConfig: MetadataFetcherRetryConfig,
		}
	}
)

Allows for unit tests to inject a mock constructor

Functions

func SetMockMetadataFetcher

func SetMockMetadataFetcher(baseUrl string, now time.Time)

Injects the mock constructor into source code. Mock metadata fetcher only created when source code calls constructor.

Types

type MetadataFetcher

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

func NewMockMetadataFetcher

func NewMockMetadataFetcher(baseUrl string, now time.Time) *MetadataFetcher

Creates a mock metadata fetcher and returns the mock instance

func (*MetadataFetcher) FetchAccessToken

func (mf *MetadataFetcher) FetchAccessToken() (string, time.Duration, error)

func (*MetadataFetcher) FetchConfigId

func (mf *MetadataFetcher) FetchConfigId() (string, error)

func (*MetadataFetcher) FetchGCPAttributes

func (mf *MetadataFetcher) FetchGCPAttributes() (*scpb.GcpAttributes, error)

func (*MetadataFetcher) FetchIdentityJWTToken

func (mf *MetadataFetcher) FetchIdentityJWTToken(audience string) (string, time.Duration, error)

func (*MetadataFetcher) FetchProjectId

func (mf *MetadataFetcher) FetchProjectId() (string, error)

func (*MetadataFetcher) FetchRolloutStrategy

func (mf *MetadataFetcher) FetchRolloutStrategy() (string, error)

func (*MetadataFetcher) FetchServiceName

func (mf *MetadataFetcher) FetchServiceName() (string, error)

Jump to

Keyboard shortcuts

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