skmetadata

package
v0.0.0-...-e0ff526 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: BSD-3-Clause Imports: 18 Imported by: 2

Documentation

Overview

Package skmetadata provides helper functions to implement the meta data server for the Skolo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupServer

func SetupServer(r chi.Router, pm ProjectMetadata, im InstanceMetadata, tokenMapping map[string]*ServiceAccountToken)

SetupServer adds handlers to the given router which mimic the API of the GCE metadata server.

func ValidateToken

func ValidateToken(tok *oauth2.Token) error

ValidateToken returns an error if the given token is not valid.

Types

type InstanceMetadata

type InstanceMetadata interface {
	Get(string, string) (string, error)
}

InstanceMetadata is an interface which supports retrieval of instance-level metadata values by instance name and key.

type ProjectMetadata

type ProjectMetadata interface {
	Get(string) (string, error)
}

ProjectMetadata is an interface which supports retrieval of project-level metadata values by key.

type ServiceAccountToken

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

ServiceAccountToken is a struct used for caching an access token for a service account.

func NewServiceAccountToken

func NewServiceAccountToken(fp string, isKeyFile bool) (*ServiceAccountToken, error)

NewServiceAccountToken returns a ServiceAccountToken based on the contents of the given file. If 'isKeyFile' is true then the given file is assumed to be the keyfile of a service account and it is used to to retrieve short-lived tokens continuously. If 'isKeyFile' is false the given file is assumed to contain the token (updated by another process) and it will be loaded continuously.

func (*ServiceAccountToken) Get

func (t *ServiceAccountToken) Get() (*oauth2.Token, error)

Get returns the current value of the access token.

func (*ServiceAccountToken) Update

func (t *ServiceAccountToken) Update() error

UpdateFromFile updates the ServiceAccountToken from the given file.

func (*ServiceAccountToken) UpdateLoop

func (t *ServiceAccountToken) UpdateLoop(ctx context.Context)

UpdateLoop updates the ServiceAccountToken from the given file on a timer.

Jump to

Keyboard shortcuts

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