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 ¶
ValidateToken returns an error if the given token is not valid.
Types ¶
type InstanceMetadata ¶
InstanceMetadata is an interface which supports retrieval of instance-level metadata values by instance name and key.
type ProjectMetadata ¶
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.